2.0.0-beta.5 • Published 8 months ago
@jad-mlb/react-modern-ui v2.0.0-beta.5
React Modern UI
React Modern UI is a small UI library created to group different components that I developped and used in different projects. It was created primarly adopting simplicity and for code reusability.
Installation
npm install @jad-mlb/react-modern-ui
yarn install @jad-mlb/react-modern-uiUsage
Getting started
- Wrap your application in the
ThemeProvidercomponent, even if you don't want to use custom themes.ThemeProvideris important to get all of the colours of the different components.
// ... other imports ...
import { ThemeProvider } from 'react-modern-ui/theme';
// ...
// other components
<ThemeProvider>
<App/>
</ThemeProvider>
// closing tags- Import your favourite components anywhere inside your application
Using custom theme
To use a custom theme you need to define some values for some (or all) of the types of colours used throughout the components.
1. Import and call useTheme hook. This hook returns an object with 2 attributes: theme which is the current theme and dispatch, the function that is used to change this theme.
import { useTheme } from 'react-modern-ui/theme';const {theme, dispatch} = useTheme();- Use the dispatch function to change the values of your colours.
dispatchtakes in its arguments an object with atypeattribute, which can take only 2 values:reset: will reset the theme back to the default valuesset: will set the theme as wanted. For this purpose, an additional attributevaluesis used. Thevaluesattribute resemblesThemeType, except that its different attributes are optional, so that you can set any value you want.
dispatch({type: "set", {mode: "dark"}}) // turns on dark modedispatch({type: "set", {primary: {medium: "ffff00"}}}) // sets primary colour to #ffff00
Documentation
Click here to read the full docs.
Change Log
v1.1.0 is out
Check the change log to see everything new