0.12.2 • Published 6 years ago

component-ui v0.12.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

component-ui

Simple components for React. Bring your own CSS reset.

Install with NPM

npm install --save component-ui

Import or include the CSS

CSS

@import '/your/path/to/component-ui/dist/index.css';

HTML

<link rel="stylesheet" href="/your/path/to/component-ui/dist/index.css">

Components

Button

PropertyTypeDescription
classNameStringCSS class passed into the button element
clickFunctionHandles the onClick event on the button
confirmBooleanApplies confirm styles to the button
disabledBooleanDisables the button
primaryBooleanApplies primary styles to the button
submitBooleanButton will submit when placed in forms
warningBooleanApplies warning styles to the button
import React from 'react';
import { Button } from 'component-ui';

const ButtonExamples = (props) => (
  <div>
    <Button className="button-example">Button with className</Button>
    <Button click={props.click}>Button with click handler</Button>
    <Button confirm disabled>Confirm Disabled</Button>
    <Button primary>Primary</Button>
    <Button submit>Submit</Button>
    <Button warning>Warning</Button>
  </div>
);

Flex

PropertyTypeDescription
alignStringAligns the children within the component
basisNumberPercent of the parent Flex used for size
classNameStringCSS class passed into the element
growBooleanFills the space available in the parent
hiddenBooleanHides the component (display: none)
hideStringHides the component for the screen size
hideXsBooleanHidden for Extra Small to Small screens
hideSmBooleanHidden for Small to Medium screens
hideMdBooleanHidden for Medium to Large screens
hideLgBooleanHidden for Large to Extra Large screens
layoutStringDirection to layout the children within
overflowBooleanAllows scrolling of overflowing content
showStringShows the component for the screen size
shrinkBooleanShrinks to allow siblings to fit parent
wrapBooleanAllows wrapping the children to fit
import React from 'react';
import { Flex } from 'component-ui';

/*
align:
  start    | start-{center, end, around, between}
  center   | center-{start, end, around, between}
  end      | end-{start, center, around, between}
  stretch  | stretch-{start, center, end, around, between}
  baseline | baseline-{start, center, end, around, between}
hide/show:
  xs, gt-xs, lt-xs | extra small (320px), greater than, less than
  sm, gt-sm, lt-sm | small (480px), greater than, less than
  md, gt-md, lt-md | medium (768px), greater than, less than
  lg, gt-lg, lt-lg | large (1024px), greater than, less than
  xl, gt-xl, lt-xl | extra large (1280px), greater than, less than
*/
const FlexExamples = () => (
  <Flex align="start-center" className="flex-example" layout="row">
    <Flex align="stretch-start" basis={50} hide="gt-md" layout="column">
      <p>Content</p>
    </Flex>
    <Flex align="center-end" grow hideLg layout="column">
      <p>Content</p>
    </Flex>
    <Flex align="center-start" layout="column" overflow shrink>
      <p>Content</p>
    </Flex>
    <Flex align="end" hidden layout="column" overflow show="lt-md" shrink>
      <p>Content</p>
    </Flex>
  </Flex>
);

Grid

PropertyTypeDescription
classNameStringCSS class passed into the element
containerBooleanBecomes a container for Grid components
hiddenBooleanHides the component (display: none)
hideStringHides the component for the screen size
hideXsBooleanHidden for Extra Small to Small screens
hideSmBooleanHidden for Small to Medium screens
hideMdBooleanHidden for Medium to Large screens
hideLgBooleanHidden for Large to Extra Large screens
showStringShows the component for the screen size
xsNumberGrid size (1-12) for Extra Small screens
smNumberGrid size (1-12) for Small screens
mdNumberGrid size (1-12) for Medium screens
lgNumberGrid size (1-12) for Large screens
xlNumberGrid size (1-12) for Extra Large screens
import React from 'react';
import { Grid } from 'component-ui';

/*
hide/show:
  xs, gt-xs, lt-xs | extra small (320px), greater than, less than
  sm, gt-sm, lt-sm | small (480px), greater than, less than
  md, gt-md, lt-md | medium (768px), greater than, less than
  lg, gt-lg, lt-lg | large (1024px), greater than, less than
  xl, gt-xl, lt-xl | extra large (1280px), greater than, less than
*/
const GridExamples = () => (
  <Grid className="grid-example" container>
    <Grid hide="lt-md" xs={12} sm={6} md={4}>
      <p>Content</p>
    </Grid>
    <Grid hideMd xs={12} sm={6} md={4}>
      <p>Content</p>
    </Grid>
    <Grid show="gt-md" xs={12} sm={6} md={4}>
      <p>Content</p>
    </Grid>
  </Grid>
);

Spinner

PropertyTypeDescription
classNameStringCSS class passed into the element
overlayBooleanDisplay as centered full-screen overlay
import React from 'react';
import { Spinner } from 'component-ui';

const SpinnerExample = () => (
  <Spinner className="spinner-example" overlay />
);

Textbox

PropertyTypeDescription
changeFunctionHandles the onChange event on the input
classNameStringCSS class passed into the element
defaultTextStringThe default text for uncontrolled input
disabledBooleanDisables the text input
focusFunctionHandles the onFocus event on the input
labelTextStringOptional label text for the input
nameStringThe name used for the input element
placeholderStringOptional text shown when input is empty
typeStringThe type of the text input
valueStringThe value used for the input value
import React from 'react';
import { Textbox } from 'component-ui';

const TextboxExample = (props) => (
  <Textbox
    change={props.change}
    className="textbox-example"
    focus={props.focus}
    labelText="Book Title"
    name="bookTitle"
    placeholder="Title of the Book"
    type="text"
    value={props.bookTitle}
  />
);

Toggle

PropertyTypeDescription
changeFunctionHandles the onChange event on the input
checkedBooleanPassed into the hidden checkbox input
classNameStringCSS class passed into the element
disabledBooleanDisables the toggle input
nameStringThe name used for the input element
valueStringThe value used for the input value
import React from 'react';
import { Toggle } from 'component-ui';

const ToggleExample = (props) => (
  <Toggle
    change={props.change}
    checked
    className="toggle-example"
    disabled
    name="enableTimeTravel"
    value="sureWhyNot"
  />
);

Utils

Each

PropertyTypeDescription
itemsArrayArray of objects to map to components
componentComponentComponent to render for each item
import React from 'react';
import { Each } from 'component-ui';

const items = [
  {
    name: 'Pasta'
  },
  {
    name: 'Pizza'
  }
];

const Item = (props) => <li>{props.name}</li>;

const EachExample = () => (
  <ul>
    <Each items={items} component={Item} />
  </ul>
);

When

PropertyTypeDescription
isBooleanRenders the children if value is truthy
import React from 'react';
import { When } from 'component-ui';

const WhenExample = (props) => (
  <div>
    <When is={props.isExampleReady}>
      <p>Content is rendered</p>
    </When>
    <When is={!props.isExampleReady}>
      <p>Content is not rendered</p>
    </When>
  </div>
);
0.12.2

6 years ago

0.12.1

6 years ago

0.12.0

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago

0.10.2

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago