react-mcu 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +88 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,13 @@
1
1
  [![npm version](https://img.shields.io/npm/v/react-mcu.svg)](https://www.npmjs.com/package/react-mcu)
2
2
  [![](https://img.shields.io/badge/chromatic-171c23.svg?logo=chromatic)](https://www.chromatic.com/library?appId=695eb517cb602e59b4cc045c&branch=main)
3
+ [![](https://img.shields.io/badge/storybook-171c23.svg?logo=storybook)](https://main--695eb517cb602e59b4cc045c.chromatic.com)
3
4
 
4
- Usage:
5
+ It injects `--mcu-*` CSS variables into the page, based on
6
+ [m3 color system](https://m3.material.io/styles/color/roles).
7
+
8
+ https://material-foundation.github.io/material-theme-builder/
9
+
10
+ # Usage
5
11
 
6
12
  ```tsx
7
13
  import { Mcu } from "react-mcu";
@@ -10,17 +16,94 @@ import { Mcu } from "react-mcu";
10
16
  source="#0e1216"
11
17
  scheme="vibrant"
12
18
  contrast={0.5}
13
- customColors=[]
19
+ customColors={[
20
+ { name: "myCustomColor1", hex: "#FF5733", blend: true },
21
+ { name: "myCustomColor2", hex: "#3498DB", blend: false },
22
+ ]}
14
23
  >
15
- <div style={{
24
+ <p style={{
16
25
  backgroundColor: "var(--mcu-surface)",
17
26
  color: "var(--mcu-on-surface)",
18
27
  }}>
19
- Hello, MCU colors!
20
- </div>
28
+ Hello, MCU <span style={{
29
+ backgroundColor: "var(--mcu-my-custom-color1)",
30
+ color: "var(--mcu-my-custom-color2)",
31
+ }}>colors<span>!
32
+ </p>
21
33
  </Mcu>
22
34
  ```
23
35
 
36
+ https://github.com/user-attachments/assets/5b67c961-d7a4-4b64-9356-4ada26bc9be4
37
+
38
+ A `useMcu` hook is also provided:
39
+
40
+ ```tsx
41
+ import { useMcu } from "react-mcu";
42
+
43
+ const { initials, setMcuConfig, getMcuColor } = useMcu();
44
+
45
+ return (
46
+ <button onClick={() => setMcuConfig({ ...initials, source: "#FF5722" })}>
47
+ Change to {getMcuColor("primary", "light")}
48
+ </button>
49
+ );
50
+ ```
51
+
52
+ ## Tailwind
53
+
54
+ Compatible with Tailwind through
55
+ [theme variables](https://tailwindcss.com/docs/theme):
56
+
57
+ ```css
58
+ @theme {
59
+ --color-background: var(--mcu-background);
60
+ --color-on-background: var(--mcu-on-background);
61
+ --color-surface: var(--mcu-surface);
62
+ --color-surface-dim: var(--mcu-surface-dim);
63
+ --color-surface-bright: var(--mcu-surface-bright);
64
+ --color-surface-container-lowest: var(--mcu-surface-container-lowest);
65
+ --color-surface-container-low: var(--mcu-surface-container-low);
66
+ --color-surface-container: var(--mcu-surface-container);
67
+ --color-surface-container-high: var(--mcu-surface-container-high);
68
+ --color-surface-container-highest: var(--mcu-surface-container-highest);
69
+ --color-on-surface: var(--mcu-on-surface);
70
+ --color-on-surface-variant: var(--mcu-on-surface-variant);
71
+ --color-outline: var(--mcu-outline);
72
+ --color-outline-variant: var(--mcu-outline-variant);
73
+ --color-inverse-surface: var(--mcu-inverse-surface);
74
+ --color-inverse-on-surface: var(--mcu-inverse-on-surface);
75
+ --color-primary: var(--mcu-primary);
76
+ --color-on-primary: var(--mcu-on-primary);
77
+ --color-primary-container: var(--mcu-primary-container);
78
+ --color-on-primary-container: var(--mcu-on-primary-container);
79
+ --color-primary-fixed: var(--mcu-primary-fixed);
80
+ --color-primary-fixed-dim: var(--mcu-primary-fixed-dim);
81
+ --color-on-primary-fixed: var(--mcu-on-primary-fixed);
82
+ --color-on-primary-fixed-variant: var(--mcu-on-primary-fixed-variant);
83
+ --color-inverse-primary: var(--mcu-inverse-primary);
84
+ --color-secondary: var(--mcu-secondary);
85
+ --color-on-secondary: var(--mcu-on-secondary);
86
+ --color-secondary-container: var(--mcu-secondary-container);
87
+ --color-on-secondary-container: var(--mcu-on-secondary-container);
88
+ --color-secondary-fixed: var(--mcu-secondary-fixed);
89
+ --color-secondary-fixed-dim: var(--mcu-secondary-fixed-dim);
90
+ --color-on-secondary-fixed: var(--mcu-on-secondary-fixed);
91
+ --color-on-secondary-fixed-variant: var(--mcu-on-secondary-fixed-variant);
92
+ --color-tertiary: var(--mcu-tertiary);
93
+ --color-on-tertiary: var(--mcu-on-tertiary);
94
+ --color-tertiary-container: var(--mcu-tertiary-container);
95
+ --color-on-tertiary-container: var(--mcu-on-tertiary-container);
96
+ --color-tertiary-fixed: var(--mcu-tertiary-fixed);
97
+ --color-tertiary-fixed-dim: var(--mcu-tertiary-fixed-dim);
98
+ --color-on-tertiary-fixed: var(--mcu-on-tertiary-fixed);
99
+ --color-on-tertiary-fixed-variant: var(--mcu-on-tertiary-fixed-variant);
100
+ --color-error: var(--mcu-error);
101
+ --color-on-error: var(--mcu-on-error);
102
+ --color-error-container: var(--mcu-error-container);
103
+ --color-on-error-container: var(--mcu-on-error-container);
104
+ }
105
+ ```
106
+
24
107
  # Dev
25
108
 
26
109
  ## INSTALL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-mcu",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A React component library",
5
5
  "keywords": [
6
6
  "react",