5.0.0 • Published 4 years ago

drover-ui v5.0.0

Weekly downloads
404
License
-
Repository
github
Last release
4 years ago

permalink: /index.html

This project was bootstrapped with Create React App. It uses styled-components for customization.

Installation

  • yarn add drover-ui

Use

Wrap the project with the ThemeProvider, ideally, right in App.js, or uppermost component in the project, e.g:

import { ThemeProvider } from 'drover-ui'

const theme = {
  button: {
    ...
  },
  input: {
    ...
  },
  ...
}

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

export default App

The components of this library can be used by importing them with the object deconstruction pattern, e.g:

import { Button } from 'drover-ui'

Customization

Customizing the style of each of the framework's component relies in, React's context API. This means that each component offers a specific set of customizable properties that completely change the components appearance without the user having to understand the structure of the component's Markup and CSS.

In addition to each component-specific theme, there is a general theme that is used as a dependency by most of the components. This is on purpose, as it represents a solution to maintain consistency in style while deeply changing the appearance of an whole app.

To customize a component's theme, you could do:

import React from "react"
import { Button } from "drover-ui"

const customTheme = {
  primary: {
    backgroundColor: 'red',
  },
  secondary: {
    focus: {
      backgroundColor: 'green',
    }
  }
  fontFamily: 'Helvetica'
}

const ButtonWrapper () => (
  <Button customTheme={customTheme} label={"Dummy Button"} />
)

export default ButtonWrapper

Every customizable component of this framework supports a customTheme prop as a way to override its own theme. The available properties to customize are different from component to component. To see which are available you should go to the drover-ui site. You should pick which ones you want to change and create an object with the same structure, but only with the "key-value" pairs of the properties to change.

For customizing the base theme, you should do, e.g:

import { ThemeProvider } from 'drover-ui'

const App = () => (
  <ThemeProvider theme={customTheme}>
    <App />
  </ThemeProvider>
)

export default App

generateBaseTheme receives as argument an object representing the base theme and returns a theme complete with each component's theme updated in order to respect these base rules. The generated theme should be passed down through a ThemeProvider component, but can actually be passed whenever the user uses one of the framework's component, by providing it to the customTheme prop.

Addons

Info

This addon acts as documentation for PropType usage for each component.

To include in a component story please follow those steps:

Import the withInfo method from @storybook/addon-info:

import { withInfo } from '@storybook/addon-info'

The PropTable component is passed a propTableData array of objects as its only argument. Create a stories folder in your component directory and add a storiesPropTableData.js file in your component folder. Then populate the propTableData array with an object for each prop you give to your component. Each object must have the propName, propType, required, defaultValue and description keys respectively. Fill out each object property with their corresponding values, like in the below example:

  export default [
  {
    propName: 'trigger',
    propType: 'any',
    required: true,
    defaultValue: '-',
    description: 'A component to interact with to show trigger an event',
  },
  {
    propName: 'id',
    propType: 'string',
    required: true,
    defaultValue: '-',
    description: 'A required unique ID to assign to the component.',
  },
  {
    propName: 'content',
    propType: 'any',
    required: false,
    defaultValue: '-',
    description: 'Content to display inside of the component.',
  }
]

In your component's .stories.js file, import the array from storiesPropTableData.js like so:

import propTableData from './storiesPropTableData'

Finally, after your storiesOf('MyComponentName', module) method, add the .addDecorator() and .addParameters() methods, to look exactly like the following:

storiesOf('Tooltip', module)
  .addDecorator(withInfo)
  .addParameters({
    info: {
      TableComponent: () => PropTable(propTableData),
      header: false,
    },
  })

Utils

generateBaseTheme(customTheme: BaseTheme): BaseTheme

A function that gets a base theme and generates a complete theme object ready to provide to a ThemeProvider component.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode. Open http://localhost:9009 to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

npm run build

Builds the lib for production to the dist folder. It correctly bundles React in production mode and optimizes the build for the best performance, and is ready to distribute to NPM.

npm run build-storybook

Builds a static web page for production to the storybook-static folder.

npm run deploy-storybook

Push storybook to gh-pages branch site

npm run bump-version:patch

npm run bump-version:minor

npm run bump-version:major

npm run release

Builds the lib and publish to NPM registry

npm test

Launches the test runner in the interactive watch mode and generate snapshots for new stories See the section about running tests for more information.

5.0.0

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.11.2

4 years ago

3.11.1

4 years ago

3.11.0

4 years ago

3.10.0

4 years ago

3.9.2

4 years ago

3.9.1

4 years ago

3.9.0

5 years ago

3.8.3

5 years ago

3.8.2

5 years ago

3.8.1

5 years ago

3.8.0

5 years ago

3.7.2

5 years ago

3.7.1

5 years ago

3.7.0

5 years ago

3.6.7

5 years ago

3.6.6

5 years ago

3.6.5

5 years ago

3.6.4

5 years ago

3.6.3

5 years ago

3.6.2

5 years ago

3.6.1

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.33.0

5 years ago

1.32.0

5 years ago

1.31.0

5 years ago

1.30.0

5 years ago

1.29.0

5 years ago

1.28.3

5 years ago

1.28.2

5 years ago

1.28.1

5 years ago

1.28.0

5 years ago

1.27.3

5 years ago

1.27.2

5 years ago

1.27.1

5 years ago

1.27.0

5 years ago

1.26.1

5 years ago

1.26.0

5 years ago

1.25.2

5 years ago

1.25.1

5 years ago

1.25.0

5 years ago

1.24.1

5 years ago

1.24.0

5 years ago

1.23.0

5 years ago

1.22.3

5 years ago

1.22.2

5 years ago

1.22.1

5 years ago

1.22.0

5 years ago

1.21.0

5 years ago

1.20.1

5 years ago

1.20.0

5 years ago

1.19.2

5 years ago

1.19.1

5 years ago

1.19.0

5 years ago

1.18.0

5 years ago

1.17.0

5 years ago

1.16.0

5 years ago

1.15.3

5 years ago

1.15.2

5 years ago

1.15.1

5 years ago

1.15.0

5 years ago

1.14.0

5 years ago

1.13.0

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.10.7

5 years ago

1.10.6

5 years ago

1.10.5

5 years ago

1.10.3

5 years ago

1.9.4

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.1

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.13

5 years ago

1.7.12

5 years ago

1.7.11

5 years ago

1.7.10

5 years ago

1.7.8

5 years ago

1.7.7

5 years ago

1.7.6

5 years ago

1.7.5

5 years ago

1.7.4

5 years ago

1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago