0.6.2 • Published 6 years ago

sand-ui v0.6.2

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

Sand-UI

npm npm GitHub issues

Sand-UI-Logo

UI library for React based on Flat UI style.

Note: In order to change styles from any component, use the style prop. className prop is overwritten so just use it like the documentation below describes to.

Installation

Sand-UI is available from npm as sand-ui:

npm install sand-ui --save

After installation you can get components from sand-ui library:

// require modules (CommonJS)

const sand = require('sand-ui');
const Button = sand.Button;

// import modules (ES6)
import { Button } from 'sand-ui';

But to make it work, you need to wrap your App inside the UIProvider, like:

import React from 'react';
import ReactDOM from 'react-dom';
import { UIProvider } from 'sand-ui';
import App from './App';

ReactDOM.render(
  <UIProvider theme={{primary: '#AAA'}}>
    <App />
  </UIProvider>,
  document.getElementById('root')
);

You can also pass an object as theme prop to change default colors of Sand-UI, the object structure for colors is:

{
  primary: '#34495E',
  secondary: '#1ABC9C',
  font: '#02222B',
  white: '#FFFFFF',
  lightGray: '#EEEEEE',
  green: '#53DF83',
  navy: '#074354',
  orange: '#F69C00',
  yellow: '#F5C700',
  red: '#EF4836',
  blue: '#47D2E9',
  gray: '#bdc3c7'
}

Components

All components are made with :heart: by MedanoSoft team, giving you freedom to pass any props you need to, event style if needed :smile:.

Button

Just like any button, excepting you can pass a link to it.

Example

import React from 'react';
import { Button } from 'sand-ui';

class ButtonExample extends React.Component {

//...

  render() {
    return (
      <Button onClick={() => console.log('Click!')}>Click me!</Button>
    )
  }
}
PropsTypeDescription
typeStringChange button color depending on type. Available: active (default), info, inverse, success, warning, danger, disabled
lightBooleanActivate a light-style button
linkStringThe same as anchor href
styleObjectCustoms styles to add

Checkbox

Checkbox and label, all in one.

Example

import React from 'react';
import { Checkbox } from 'sand-ui';

class CheckboxExample extends React.Component {

//...

  render() {
    return (
      <form>
        <Checkbox checked name="Eggs" />
        <Checkbox name="Chicken" />
        <Checkbox name="Tomatoes" />
        <Checkbox checked name="Milk" />
        <Checkbox checked name="Checkout to-do list" />
      </form>
    )
  }
}
PropsTypeDescription
nameStringCheckbox's label
checkedBooleanWorks active or disabled
onChangeFunctionCalled when checkbox change it's state
disabledBooleanDisable checkbox interaction

Dropdown

List of items like a list-menu, Dropdown is not the same as Select component. Pass an array of items to list prop, it needs to be a list of strings, elements or objects like:

{
  name: 'One', // (string) item name
  link: 'https://github.com/MedanoSoft/sand-ui', // (string) url to link this item
  props: {
    // Props for this item
  }
}

Example

import React from 'react';
import { Dropdown } from 'sand-ui';

class DropdownExample extends React.Component {
  constructor() {
    super();

    this.list = [
      'Twitter',
      'LinkedIn',
      (<br />),
      {
        name: 'GitHub',
        link: 'https://github.com/MedanoSoft',
        props: {
          onClick: () => console.log('GitHub here it goes!')
        }
      }
    ]
  }
//...

  render() {
    return (
        <Dropdown label="Social Media" list={this.list} />
    )
  }
}
PropsTypeDescription
labelStringLabel for flag button
listArrayList of items to show
visibleBooleanToggle list
buttonStyleObjectCustom styles for flag button

Icon

This icon component uses SVG icons from Linearicons, you can use any of those icons passing the icon name without the lnr- prefix, all of those icon names are also described on this Gist and inside this Icon folder :octocat:

Note: Remember to provide any container of this Icon component with a height.

Example

import React from 'react';
import { Icon } from 'sand-ui';

class IconExample extends React.Component {

//...

  render() {
    return (
      <div style={{ height: 200 }}>
        <Icon name="bug" color="#00A86B" />
      </div>
    )
  }
}
PropsTypeDescription
nameStringIcon name from Linearicons
sizeStringDefine icon width
colorStringColor of the icon, you can use an hex color or use any of this words: active, inactive, success, warning, danger, disabled, inverse, error, for Flat UI colorscheme

Navbar

Simple, horizontal nav component with searchbar.

Example

import React from 'react';
import { Navbar } from 'sand-ui';

class NavbarExample extends React.Component {
  constructor(props) {
    super(props);

    //...
    this.handleSearchbar = this.handleSearchbar.bind(this);
  }

//...
  handleSearchbar(val) {
    console.log(`You are looking for ${val}`);
  }
  
  render() {
    return (
        <Navbar
          title="SandUI"
          right={(<span>&hearts;</span>)}
          searchbar
          onSearch={this.handleSearchbar} />
    )
  }
}
PropsTypeDescription
titlenodeNavbar header
middlenodeElement at the middle
rightnodeElement at the right
searchbarbooleanAdd a searchbar on the nav (default: false)
onSearchfunctionCalled when user puts a line break (User hits Intro)
styleobjectCustom styles to add
placeholderstringPlaceholder for insert in searchbar

Pagination

Navigation with this simple pagination component.

Example

import React, { Component } from 'react';
import { Pagination } from 'sand-ui';

class PaginationExample extends Component {
  render() {
    return (
      <Pagination pages={30} onPagination={(index) => console.log(`Switch to page ${index}`)} />
    )
  }
}
PropsTypeDescription
pagesNumberTotal of list options to show, default: 0, which means All
activeNumberIndex of the active list option
onPaginationFunctionCalled when user selects an option, return the option index
onLeftClickFunctionCalled when user selects the left button
onRightClickFunctionCalled when user selects the right button

Progress Bar

Horizontal light bar for showing progress.

Example

import React, { Component } from 'react';
import { Progress } from 'sand-ui';

class ProgressExample extends Component {
  render() {
    return (
      <Progress type="info" percent={15} />
    )
  }
}
PropsTypeDescription
typeStringProgress bar colorscheme. Available: default, info, success, warning, danger, inverse
percentNumberPercent of progress. Default: 25
styleobjectCustom styles to add

Radio

Radio buttons with labels.

Instructions

Give it a name to group all radio buttons of the same type. If not, a default name will be given. Value is unique, and is used as an id.

Example

import React from 'react';
import { Radio } from 'sand-ui';

class RadioExample extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      animal: 'cat'
    };
    // ...
    this.handleRadio = this.handleRadio.bind(this);
  }

//...
  handleRadio(value) {
    this.setState({
      animal: value
    });
  }
  
  render() {
    return (
        <form>
          <Radio name="animals" value="cat" checked={this.state.animal === 'cat'} onChange={this.handleRadio}>Cat</Radio>
          <Radio name="animals" value="dog" checked={this.state.animal === 'dog'} onChange={this.handleRadio}>Dog</Radio>
          <Radio value="dragon" name="animals" disabled>Dragon</Radio>
        </form>
    )
  }
}
PropsTypeDescription
nameStringName of radio group
valueStringValue for radio button
checkedbooleanSelect this radio
disabledbooleanDisable button interaction
onChangeFunctionCalled when radio change it's state

Select

Slider

This is a stylished form of <input type="range" /> see MDN documentation about.

Example

import React from 'react';
import { Slider } from 'sand-ui';

class SliderExample extends React.Component {

  render() {
    return (
      <Slider step={4} />
    );
  }

}
PropsTypeDescription
stepNumberRange separation. Default: 1
styleObjectCustom styles to add
onChangeFunctionCalled when slider change it's state

Switch

Use a switch if you need a playful component for a boolean input value.

Example

import React from 'react';
import { Switch } from 'sand-ui';

class SwitchExample extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      status: true
    };
    // ...
    this.handleSwitch = this.handleSwitch.bind(this);
  }

//...
  handleSwitch(value) {
    this.setState({
      status: value
    });
  }
  
  render() {
    const { status } = this.state;
    return (
        <form>
          <Switch type="box" status={status} onChange={this.handleSwitch} />
        </form>
    )
  }
}
PropsTypeDescription
typeStringStyle of the current switch. Available: 'circle' (default), 'box'.
statusBooleanCurrent checkbox status
onChangeFunctionAction on checkbox status, returns the Switch new state as a boolean.

Tags

For multiple input strings, Tags component! :smile:

Example

import React from 'react';
import { Tags } from 'sand-ui';

class TagsExample extends React.Component {

  render() {
    return (
      <Tags values={['One', 'Two']} onUpdate={(values) => console.log(values)} />
    );
  }

}
PropsTypeDescription
valuesArrayStack of strings as values from user input
listArrayList of possible values, or datalist
onUpdateFunctionAction when values had changed

TextInput

Simple styled text input. Available for any text-like input if you describe it as type prop.

Note: You don't need to add disabled prop if you declare it as className.

Example

import React from 'react';
import { TextInput } from 'sand-ui';

class InputExample extends React.Component {
  constructor(props) {
    super(props);

    this.state = { value: '' };

    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(event) {
  	this.setState({
  		value: event.target.value
  	});
  }

//...

  render() {
    const { value } = this.state;
    return (
      <TextInput placeholder="Jane Doe" type="text" value={value} onChange={this.handleChange} />
    );
  }
}
PropsTypeDescription
typeStringType of input, the default is text. Available: text, number, email, password, date, search
classNameStringChange input color depending on type. Available: active (default), success, error, disabled
iconString or ElementInsert an icon at the left, or the element you desire to
disabledBooleanDisable input interaction
styleObjectCustom styles to add

Grids

In order to make a responsive display, we have integrated a grid system called Flexbox Grid and adapted to React components, now you got a flex-based full grid display.

Container

This component offers a flexible layout for multiple boxes or any other children.

PropsTypeDescription
directionStringBoxes direction, type: row (default), column
reverseBooleanReverse order of the boxes, default: false
fluidBooleanMore fluent and spaced container, default: false
distStringBoxes distribution for minimal screen sizes, type: start, center, end, around(default), between
smDistStringBoxes distribution for small screen sizes, type: start, center, end, around, between
mdDistStringBoxes distribution for medium screen sizes, type: start, center, end, around(default), between
lgDistStringBoxes distribution for large screen sizes, type: start, center, end, around, between
alignStringBox alignment for minimal screen sizes, type: top(default), middle, bottom
smAlignStringBox alignment for small screen sizes, type: top, middle, bottom
mdAlignStringBox alignment for medium screen sizes, type: top, middle, bottom
lgAlignStringBox alignment for large screen sizes, type: top, middle, bottom
styleObjectCustom styles to add

Box

Component with flexible column size (selected from 1 to 12, auto if not defined).

PropsTypeDescription
xsNumberColumn size for minimal screen size, from 1 to 12, default 0(auto)
xsOffsetNumberLeft distance spacing (in columns) for minimal screen size, from 1 to 12, default 0(auto)
smNumberColumn size for small screen size, from 1 to 12, default 0(auto)
smOffsetNumberLeft distance spacing (in columns) for small screen size, from 1 to 12, default 0(auto)
mdNumberColumn size for medium screen size, from 1 to 12, default 0(auto)
mdOffsetNumberLeft distance spacing (in columns) for medium screen size, from 1 to 12, default 0(auto)
lgNumberColumn size for large screen size, from 1 to 12, default 0(auto)
lgOffsetNumberLeft distance spacing (in columns) for large screen size, from 1 to 12, default 0(auto)
styleObjectCustom styles to add

Example

import React from 'react';
import { Container, Box } from 'sand-ui';

class InputExample extends React.Component {
  render() {
    return (
      <Container fluid mdAlign={"middle"} reverse>
        <Box xs={4} md={6} style={{backgroundColor: 'red' }}>
          <p>Hi</p>
        </Box>
        <Box xs={2} md={4} style={{backgroundColor: 'green' }}>
          <p>From a</p>
        </Box>
        <Box style={{backgroundColor: 'blue' }}>
          <p>Box!</p>
        </Box>
      </Container>
    )
  }
}

License

Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") Copyright (c) 1995-2003 by Internet Software Consortium

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

More info about this license here.

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago