0.2.2 • Published 2 years ago

@samwindham1/component-library v0.2.2

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

@samwindham1/component-library · npm version

Introduction

This is a themable component library that uses React and styled-components. Simply import the components into your project to style and build your site.

Setup

npm install @samwindham1/component-library --save

Add the ThemeProvider at the top-most level of your app, and supply it your theme overrides.

// app.jsx

import { ThemeProvider } from '@samwindham1/component-library';
import { theme } from './theme';

export const App = () => (
    <ThemeProvider theme={theme}>
        <... />
    </ThemeProvider>
);

Set up your theme overrides (See below for theme structure):

// theme.js
export const theme = {
    color: {
        primary: 'blue'
        ...
    },
    button: {
        color: 'magenta'
        ...
    },
    ...
}

Import and use a component:

// Component.jsx

import { Button } from '@samwindham1/component-library';

const Component = () => (
    <>
        ...
        <Button label={'Label'} onClick={() => {}} />
    </>
);

Components:

Default Props

proptypedefaultdescription
idstringempty stringcustom id
disabledbooleanfalse
classesstringempty stringcustom classnames

Button

proptypedefaultdescription
labelstring
onClick() => voidonClick event function

Checkbox

proptypedefaultdescription
labelstring
checkedbooleanparent component needs to control the state
onChange(value: boolean) => voidonChange function to control the parent state

TextInput

proptypedefaultdescription
valuestringparent component needs to control the state
onChange(value: string) => voidonChange function to control the parent state