1.1.75 • Published 4 years ago

coad-ui v1.1.75

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

Coad-UI

Component library based on React and Styled Components. For this moment it provides basic custom components, such as Button, Input, Select, Checkbox, Radio buttons etc.

Installing coad-ui

To install coad-ui run:

 npm install coad-ui

Using coad-ui

CoadUIProvider

In order to use components from coad-ui you have to wrap your app into .

Besides, you may pass your custom theme as a prop to have components according to your theme.

The theme should have the following structure:

interface ITheme {
  name: string;
  colors: {
    primary: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
    secondary: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
    tertiary: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
    success: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
    warning: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
    error: {
      default: string;
      opacity75: string;
      opacity50: string;
      opacity25: string;
      opacity15: string;
    };
  };
  neutralColors: {
    black: {
      default: string;
      opacity75: string;
      medium: string;
      light: string;
    };
    dark: {
      default: string;
      medium: string;
      light: string;
    };
    medium: string;
    light: string;
    white: string;
  };
  shadows: {
    soft: string;
    medium: string;
    hard: string;
  };
  fontSizes: {
    XXL: { fontSize: string; lineHeight: string };
    XL: { fontSize: string; lineHeight: string };
    L: { fontSize: string; lineHeight: string };
    M: { fontSize: string; lineHeight: string };
    default: { fontSize: string; lineHeight: string };
    S: { fontSize: string; lineHeight: string };
    XS: { fontSize: string; lineHeight: string };
  };
  fontWeight: {
    regular: { fontFamily: string; fontWeight: number };
    medium: { fontFamily: string; fontWeight: number };
    bold: { fontFamily: string; fontWeight: number };
  };
  borderRadius: {
    semiRound: string;
    round: string;
    rectangle: string;
  };
  mediaQueries: {
    mobilePortrait: string;
    mobileLandscape: string;
    tablet: string;
    laptop: string;
    desktop: string;
  };
}

Usage

import React from 'react';
import styled from 'styled-components';
import { CoadUIProvider } from 'coad-ui';

function App() {
  return (
    <CoadUIProvider>
      <CustomComponents />
    </CoadUIProvider>
  );
}

Properties

PropertyTypeRequiredDefaultDescription
themeIThemenodefault library themeDefines theme

Button

The component provides styled button based on Styled Components. In order to override styles you may extend default Button component:

import styled from 'styled-components';
import { Button } from 'coad-ui';

const CustomButton = styled(Button)``;
...

//or

const CustomButton = styled(Button)`
  &&&{
   //your styles
  }
`;

Or using plain css:

CustomButton.tsx

import Button from 'coad-ui';
import './styled.css';
...
const CustomButton = (props) => <Button className='custom-button'/>;
...

styles.css

.custom-button.custom-button.custom-button {
  ...;
}

Usage

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

const MyComponent = () => (
  <Button
    variant="outline"
    color="primary"
    fontSize="M"
    fontType="medium"
    shape="semiRound"
    onClick={handleClick}>
    Click
  </Button>
);

Button with Icon Use styled icons from here

<Button>
  <CreditCardAlt size="1.5em" />
  <span>Pay</span>
</Button>

Properties

PropertyTypeRequiredDefaultPossible valuesDescription
variantstringno'raised''raised', 'outline', 'text'Defines style of background color
disabledbooleannofalseEnable/Disable onClick
blockbooleannofalseIt makes the button full width
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for select and options
shapestringno'rectangle''semiRound', 'round', 'rectangle'Defines border radius
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight
onClick(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => voidno-Handler for onClick event

Checkbox and CheckboxGroup

Checkbox and CheckboxGroup

The component provides styled select based on Styled Components with several options. In order to override styles you may extend default Checkbox or CheckboxGroup components:

import styled from 'styled-components';
import { Checkbox, CheckboxGroup } from 'coad-ui';

const StyledCheckbox = styled(Checkbox)`
  margin-left: 10rem;
  &:checked {
    border: 1px solid red;
    background-color: red;
  }
`;

const StyledCheckboxGroup = styled(CheckboxGroup)`
  width: 300px;
  input {
    &:checked {
      border: 1px solid red;
      background-color: red;
    }
  }
`;

//or

const StyledCheckbox = styled(Checkbox)`
  &&& {
    your styles
  }
`;

const StyledCheckboxGroup = styled(CheckboxGroup)`
  &&& {
    your styles
  }
`;

...

Or using plain css:

/CustomCheckbox.tsx

import { Checkbox, CheckboxGroup } from 'coad-ui';
import './styled.css';

const CustomCheckbox = (props) => <Checkbox className='custom-checkbox'/>;
const CustomCheckboxGroup = (props) => <CheckboxGroup items={items} className='custom-checkbox-group'/>;
...

/styles.css

.custom-checkbox.custom-checkbox.custom-checkbox {
  ...;
}

.custom-checkbox-group.custom-checkbox-group.custom-checkbox-group {
  ...;
}

Usage of single Checkbox

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

const MyCheckbox = () => (
  <Checkbox
    label="Checkbox"
    name="checkbox"
    color="primary"
    fontSize="M"
    fontType="bold"
    onChange={(e) => handleChange(e)}
  />
);

Usage of grouped CheckboxGroup

import React from 'react';
import { CheckboxGroup } from 'coad-ui';

const items = [
  {
    value: 'option1',
    label: 'Option'
  },
  {
    value: 'option2',
    label: 'Option',
    isDefaultChecked: true
  },
  {
    value: 'option3',
    label: 'Option',
    isDisabled: true
  }
];

const MyCheckboxGroup = () => (
  <MyCheckboxGroup
    label="CheckboxGroup"
    groupName="checkboxGroup"
    items={items}
    color="primary"
    fontSize="M"
    fontType="bold"
    onChange={(values) => handleChange(values)}
  />
);

Properties of Checkbox

PropertyTypeRequiredDefaultPossible valuesDescription
namestringno--Defines name of checkbox
onChange(event) => void)no--Handler for onChange event
valuestring or numberno--Defines value of checkbox
labelstringno--Defines label of component
isDefaultCheckedbooleannofalse-Defines if component is checked by default
disabledbooleannofalse-Enable/Disable onClick
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for checkbox
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight

Properties of CheckboxGroup

PropertyTypeRequiredDefaultPossible valuesDescription
groupNamestringno--Defines name of checkbox group
labelstringno--Defines label of component
onChange(values: { value: string: boolean }) => voidno--Handler for onChange event
itemsarray of objects: {value: string or number; label: string; isDefaultChecked?: boolean;}yes--The data passed to checkbox options
disabledbooleannofalse-Enable/Disable onClick
columnbooleannofalse-Defines column/row direction
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for select and options
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight

Input

Input

The component provides styled input based on Styled Components. In order to override styles you may extend default Input component:

import styled from 'styled-components';
import {Input} from 'coad-ui';

const StyledInput = styled(Input)`
  input {
    border: 2px solid red;
    color: blue;
    margin-left: 2rem;
  }
`;

// or

const StyledInput = styled(Input)`
  &&& {
    your styles
  }
`;
...

Or using plain css:

/CustomInput.tsx

import Input from 'coad-ui';
import './styled.css';
...
const CustomInput = (props) => <Input className='custom-Input'/>;
...

/styles.css

.custom-Input.custom-Input.custom-Input {
  ...;
}

Usage

import React from 'react';
import { Input } from 'coad-ui';

const MyComponent = () => (
  <Input
    label="Input label"
    placeholder="Placeholder"
    fontSize="M"
    fontType="medium"
    shape="semiRound"
    onChange={handleChange}
  />
);

Properties

PropertyTypeRequiredDefaultPossible valuesDescription
labelstringno--Descriptive label that appears above the Input.
placeholderstringno--Placeholder to display initially
textareabooleanno--Enables textarea type
defaultValuestringno--Default value
valuestringno--Current value
messagestringno--Input message
maxLengthnumberno--Max length of input value
colorstringno-'primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for Input
shapestringno'rectangle''semiRound', 'round', 'rectangle'Defines border-radius of Input
widthstringno'250px'-Defines width of Input
marginstringno0-Defines Input margin
blockbooleannofalse'-Defines properties: display: block, width: 100%
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight
disabledbooleannofalse-Enable/Disable onClick
onChange(e: React.ChangeEvent) => void;no--Handler for onChange event
onClick(e: React.SyntheticEvent) => voidno--Handler for onClick event

RadioButton and RadioButtonGroup

RadioButton and RadioButtonGroup

The component provides styled select based on Styled Components with several options. In order to override styles you may extend default RadioButton or RadioButtonGroup components:

import styled from 'styled-components';
import { RadioButton, RadioButtonGroup } from 'coad-ui';

const StyledRadioButton = styled(RadioButton)`
  &:before {
    background-color: red;
  }
  &:after {
    border: 1px solid red;
  }
`;

const StyledRadioButtonGroup = styled(RadioButtonGroup)`
  width: 300px;
  input {
    &:before {
      background-color: red;
    }
    &:after {
      border: 1px solid red;
    }
  }
`;

// or

const StyledRadioButton = styled(RadioButton)`
  &&& {
    your styles
  }
`;

const StyledRadioButtonGroup = styled(RadioButtonGroup)`
  &&& {
    your styles
  }
`;
...

Or using plain css:

/CustomRadioButton.tsx

import { RadioButton, RadioButtonGroup } from 'coad-ui';
import './styled.css';

const CustomRadioButton = (props) => <RadioButton className='custom-radio-button'/>;
const CustomRadioButtonGroup = (props) => <RadioButtonGroup items={items} className='custom-radio-button-group'/>;
...

/styles.css

.custom-radio-button.custom-radio-button.custom-radio-button {
  ...;
}

.custom-radio-button-group.custom-radio-button-group.custom-radio-button-group {
  ...;
}

Usage of single RadioButton

import React from 'react';
import { RadioButton } from 'coad-ui';

const MyRadioButton = () => (
  <RadioButton
    label="RadioButton"
    name="radioButton"
    color="primary"
    fontSize="M"
    fontType="bold"
    onChange={(e) => handleChange(e)}
  />
);

Usage of grouped RadioButtonGroup

import React from 'react';
import { RadioButtonGroup } from 'coad-ui';

const items = [
  {
    label: 'Option',
    value: 'option1'
  },
  {
    label: 'Option',
    value: 'option2'
  },
  {
    label: 'Option',
    value: 'option3'
  },
  {
    label: 'Option',
    value: 'option4',
    isDisabled: true
  }
];

const MyRadioButtonGroup = () => (
  <RadioButtonGroup
    label="RadioButtonGroup"
    groupName="radioButtonGroup"
    items={items}
    color="primary"
    fontSize="M"
    fontType="bold"
    onChange={(value) => handleChange(value)}
  />
);

Properties of RadioButton

PropertyTypeRequiredDefaultPossible valuesDescription
namestringno--Defines name of radio button
onChange(event) => void)no--Handler for onChange event
valuestring or numberno--Defines value of radio button
labelstringno--Defines label of component
disabledbooleannofalse-Enable/Disable onClick
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for radio button
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight

Properties of RadioButtonGroup

PropertyTypeRequiredDefaultPossible valuesDescription
groupNamestringno--Defines name of checkbox group
labelstringno--Defines label of component
onChange(value) => voidno--Handler for onChange event
itemsarray of objects: {value: string or number; label: string; }yes--The data passed to checkbox options
defaultValuestringno--Defines value which will be set by default
disabledbooleannofalse-Enable/Disable onClick
columnbooleannofalse-Defines column/row direction
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for select and options
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight

Select

Select

The component provides styled select based on Styled Components with several options. In order to override styles you may extend default Select component:

import styled from 'styled-components';
import {Select} from 'coad-ui';

const StyledSelect = styled(Select)`
  margin: 2rem;
  width: 200px;
`;

// or

const StyledSelect = styled(Select)`
  &&& {
    your styles
  }
`;
...

Or using plain css:

/CustomSelect.tsx

import Select from 'coad-ui';
import './styled.css';
...
const CustomSelect = (props) => <Select options={options} className='custom-select'/>;
...

/styles.css

.custom-select.custom-select.custom-select {
  ...;
}

Usage

import React from 'react';
import { Select } from 'coad-ui';

const MyComponent = () => (
  <Select
    options={options}
    name="Choose option"
    color="primary"
    fontSize="M"
    fontType="bold"
    defaultValue={2}
    onChange={(option) => handleChange(option)}
  />
);

Properties

PropertyTypeRequiredDefaultPossible valuesDescription
optionsarrayyes-array of objects: {key: number or string; value?: string or number; label: string}The data passed to select options
namestringno--The value to display initially
colorstringno'primary''primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for select and options
widthstringno'200px'-Defines width of select
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight
variantstringno'outlined''outlined', 'text'Defines variant of select
defaultValuenumber or stringno--Defines initially selected value from passed options
disabledbooleannofalse-Enable/Disable onClick
blockbooleannofalse-Defines properties: display: block, width: 100%
onChange({label, value}) => void)no--Handler for onChange event
onClick(e: React.SyntheticEvent) => voidno--Handler for onClick event

DatePicker

DatePicker This DatePicker is based on react-datepicker The component provides styled date-picker based on Styled Components. In order to override styles you may extend default DatePicker component:

import styled from 'styled-components';
import {DatePicker} from 'coad-ui';

const StyledDatePicker = styled(DatePicker)`
  border: 2px solid red;
  color: blue;
  margin-left: 2rem;
`;

// or

const StyledDatePicker = styled(DatePicker)`
  &&& {
    your styles
  }
`;
...

Or using plain css:

/CustomDatePicker.tsx

import DatePicker from 'coad-ui';
import './styled.css';
...
const CustomDatePicker = (props) => <DatePicker className='custom-DatePicker'/>;
...

/styles.css

.custom-DatePicker.custom-DatePicker.custom-DatePicker {
  ...;
}

Usage

import React, { useState } from 'react';
import { DatePicker } from 'coad-ui';

const MyComponent = () => (
  const [startDate, setStartDate] = useState<Date | null>(new Date());
  return (
      <DatePicker
        label="Default"
        onChange={(date) => setStartDate(date)}
        placeholderText="Placeholder"
        selected={startDate}
      />
  )
);

Properties

PropertyTypeRequiredDefaultPossible valuesDescription
labelstringno--Descriptive label that appears above the DatePicker.
placeholderTextstringno--Placeholder to display initially
defaultValuestringno--Default value
valuestringno--Current value
messagestringno--Input message
maxLengthnumberno--Max length of input value
colorstringno-'primary', 'secondary', 'tertiary', 'success', 'warning', 'error'Themed color for DatePicker
shapestringno'rectangle''semiRound', 'round', 'rectangle'Defines border-radius of DatePicker
fontSizestringno'default''XS', 'S', 'M', 'L', 'XL', 'XXL', 'default'Defines font-size and line-height
fontTypestringno'regular''regular', 'medium', 'bold'Defines font-weight
disabledbooleannofalse-Enable/
marginstringno0-Defines DatePicker margin
Disable onClick
onChange(e: React.ChangeEvent) => void;no--Handler for onChange event
onClick(e: React.SyntheticEvent) => voidno--Handler for onClick event
1.1.75

4 years ago

1.1.74

4 years ago

1.1.73

4 years ago

1.1.72

4 years ago

1.1.71

4 years ago

1.1.70

4 years ago

1.1.69

4 years ago

1.1.68

4 years ago

1.1.67

4 years ago

1.1.65

4 years ago

1.1.64

4 years ago

1.1.63

4 years ago

1.1.62

4 years ago

1.1.60

4 years ago

1.1.59

4 years ago

1.1.58

4 years ago

1.1.57

4 years ago

1.1.56

4 years ago

1.1.55

4 years ago

1.1.54

4 years ago

1.1.53

4 years ago

1.1.52

4 years ago

1.1.51

4 years ago

1.1.49

4 years ago

1.1.50

4 years ago

1.1.48

4 years ago

1.1.47

4 years ago

1.1.45

4 years ago

1.1.46

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.42

4 years ago

1.1.41

4 years ago

1.1.40

4 years ago

1.1.38

4 years ago

1.1.39

4 years ago

1.1.37

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.34

4 years ago

1.1.32

4 years ago

1.1.31

4 years ago

1.1.29

4 years ago

1.1.28

4 years ago

1.1.30

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.1

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.0.19

4 years ago

1.1.0

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago