0.2.0 • Published 6 months ago

rmcw v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Use

import { Button } from "rmcw";

function MyComponent() {
  return <Button />;
}

What's the library for?

This library provide react wrapper for material design components.

What's different between other wrapper library?

Under this library, the mdc's stats only follow react stats. This mean the mdc's stats would not change until react stats change. This library always sync the react stats and the mdc stats. (By default, mdc usually modify the element's stats automatically that make the mdc element out of control in react framework)

For example:

const [open, setOpen] = React.useState(false);

<Dialog open={open}>{children}</Dialog>;

The dialog would be open when open is true and closed when open is false. And when user click the scrim, this library just only invoke onScrimClick callback and do nothing (dialog will keep open if open is true after click). No one can force you to close the dialog on fixed callback in the library (for example, in rmwc library if you don't close dialog in onClose callback, your react state will out of sync with mwc and component behave will be unpredictable).

If programmer want to close dialog when user click the scrim, the only way is:

const [open, setOpen] = React.useState(false);

<Dialog open={open} onScrimClick={() => setOpen(false)}>
  {children}
</Dialog>;

This library will block most of mdc default behave that keep the dom state sync with react state. Including some input element, the state will keep sync without call Event.preventDefault() conditionally (Checkbox, Radio and etc).

But TextArea and TextField still keep normal react input control style. Use Event.preventDefault() to prevent state change conditionally.

Compatible with React 18

You can enable StrictMode without error or warning message whatever you want. No legacy api use.

Demo

Clone the repo and run the command

npm i
npm run storybook

Components

  • Banner
  • Button
  • Card
  • Checkbox
  • Chip
  • CircularProgress
  • DataTable
  • Dialog
  • Drawer
  • Elevation
  • Fab
  • Icon
  • IconButton
  • LinearProgress
  • ListDivider
  • ListItem
  • Menu
  • Radio
  • Ripple
  • SegmentedButton
  • Select
  • Slider
  • Snackbar
  • Switch
  • Tab
  • TabBar
  • TextArea
  • TextField
  • Tooltip
  • TopAppBar
  • Typography

Additional Components

  • Theme (Unified theme settings and better dark theme support)
function ThemeSwitch() {
  /// false: force light theme
  /// true: force dark theme
  /// undefined: automatically (state from 'window.matchMedia('(prefers-color-scheme: dark)')')
  const [enableDarkTheme, setEnableDarkTheme] = React.useState(undefined);
  return <Theme enableDarkTheme={enableDarkTheme}>{myComponent}</Theme>;
}

Development requirement

If you use webpack, it require sass loader to pack .scss file into project (the project that come from "create-react-app" script already have sass loader).

If you use vite, nothing is required to do.

0.1.35

7 months ago

0.1.36

6 months ago

0.2.0

6 months ago

0.1.33

7 months ago

0.1.34

7 months ago

0.1.32

8 months ago

0.1.31

8 months ago

0.1.30

8 months ago

0.1.29

8 months ago

0.1.28

8 months ago

0.1.27

9 months ago

0.1.26

9 months ago

0.1.25

10 months ago

0.1.24

10 months ago

0.1.23

10 months ago

0.1.22

10 months ago

0.1.21

10 months ago

0.1.20

10 months ago

0.1.19

10 months ago

0.1.18

10 months ago

0.1.17

10 months ago

0.1.16

10 months ago

0.1.15

10 months ago

0.1.14

10 months ago

0.1.13

10 months ago

0.1.12

10 months ago

0.1.11

10 months ago

0.1.10

10 months ago

0.1.9

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago