lucentia-ui 0.1.3 → 0.1.4
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.
- package/README.md +152 -0
- package/dist/components/Button/Button.module.css +20 -2
- package/dist/components/Button/Button.stories.js +3 -3
- package/dist/components/Input/Input.module.css +2 -4
- package/dist/components/Input/Input.stories.js +1 -1
- package/dist/components/Select/Select.module.css +4 -1
- package/dist/components/ThemeProvider/ThemeProvider.module.css +8 -4
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# lucentia-ui
|
|
2
|
+
|
|
3
|
+
Minimal React UI components with design tokens & theme support.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install lucentia-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add lucentia-ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- React 18+
|
|
24
|
+
- CSS Modules 対応環境(Next.js / Vite / CRA など)
|
|
25
|
+
|
|
26
|
+
## 基本の使い方(必須)
|
|
27
|
+
|
|
28
|
+
### 1.ThemeProvider をアプリのルートに配置
|
|
29
|
+
|
|
30
|
+
※lucentia-ui は ThemeProvider が必須です
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { ThemeProvider } from "lucentia-ui";
|
|
34
|
+
|
|
35
|
+
export default function App() {
|
|
36
|
+
return <ThemeProvider theme="light">{/* your app */}</ThemeProvider>;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 利用可能なテーマ
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
type Theme = "light" | "dark";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
<ThemeProvider theme="dark">
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2.コンポーネントをそのまま使う
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Button, Checkbox, Radio } from "lucentia-ui";
|
|
54
|
+
|
|
55
|
+
export default function Example() {
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<Button variant="primary">Save</Button>
|
|
59
|
+
<Checkbox label="Accept terms" />
|
|
60
|
+
<Radio label="Option A" />
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- 追加の CSS import は不要
|
|
67
|
+
- ThemeProvider 配下であればスタイルは自動適用
|
|
68
|
+
|
|
69
|
+
### なぜ ThemeProvider が必要なのか?
|
|
70
|
+
|
|
71
|
+
lucentia-ui のコンポーネントは
|
|
72
|
+
CSS Variables(Design Tokens) に依存しています。
|
|
73
|
+
|
|
74
|
+
```css
|
|
75
|
+
.theme.light {
|
|
76
|
+
--color-background: #ffffff;
|
|
77
|
+
--color-text: #111111;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
ThemeProvider は:
|
|
82
|
+
|
|
83
|
+
- .theme.light / .theme.dark を付与
|
|
84
|
+
- CSS Variables を有効化
|
|
85
|
+
- コンポーネント CSS を安全に動作させる
|
|
86
|
+
|
|
87
|
+
という役割を持ちます。
|
|
88
|
+
|
|
89
|
+
### テーマ切り替え例
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { useState } from "react";
|
|
93
|
+
import { ThemeProvider, Button } from "lucentia-ui";
|
|
94
|
+
|
|
95
|
+
export default function App() {
|
|
96
|
+
const [theme, setTheme] = useState<"light" | "dark">("light");
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ThemeProvider theme={theme}>
|
|
100
|
+
<Button onClick={() => setTheme(theme === "light" ? "dark" : "light")}>
|
|
101
|
+
Toggle theme
|
|
102
|
+
</Button>
|
|
103
|
+
</ThemeProvider>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## コンポーネント設計方針
|
|
109
|
+
|
|
110
|
+
- **HTML ネイティブ要素を尊重**
|
|
111
|
+
- **props extends HTMLAttributes**
|
|
112
|
+
- **状態・色・サイズは Design Tokens に依存**
|
|
113
|
+
- **Tailwind / inline style 不使用**
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 提供コンポーネント
|
|
118
|
+
|
|
119
|
+
- Button
|
|
120
|
+
- Checkbox
|
|
121
|
+
- Radio
|
|
122
|
+
- Input
|
|
123
|
+
- Select
|
|
124
|
+
- Switch
|
|
125
|
+
- Modal
|
|
126
|
+
|
|
127
|
+
詳細は **Storybook** を参照してください。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 注意事項
|
|
132
|
+
|
|
133
|
+
- **ThemeProvider を使わない場合**
|
|
134
|
+
→ CSS Variables が未定義になり表示が崩れます
|
|
135
|
+
|
|
136
|
+
- **CSS の上書きは非推奨**
|
|
137
|
+
(Tokens 拡張を想定)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 将来予定
|
|
142
|
+
|
|
143
|
+
- system theme 対応
|
|
144
|
+
- Theme 拡張 API
|
|
145
|
+
- アニメーション Token
|
|
146
|
+
- a11y 強化
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
.button {
|
|
2
2
|
font-family: var(--font);
|
|
3
3
|
font-weight: 500;
|
|
4
|
-
border:
|
|
4
|
+
border: 2px solid transparent;
|
|
5
5
|
cursor: pointer;
|
|
6
6
|
|
|
7
|
-
border-radius: var(--radius-
|
|
7
|
+
border-radius: var(--radius-sm);
|
|
8
8
|
|
|
9
9
|
box-shadow: var(--shadow-sm);
|
|
10
10
|
transition: box-shadow 0.2s ease, opacity 0.2s ease, background 0.25s ease-in-out,
|
|
@@ -17,23 +17,39 @@
|
|
|
17
17
|
color: var(--color-on-surface);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
|
|
21
|
+
|
|
20
22
|
.primary {
|
|
21
23
|
background: var(--color-primary-container);
|
|
22
24
|
color: var(--color-on-primary-container);
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
.primary:hover:not(:disabled) {
|
|
28
|
+
border: 2px solid var(--color-primary);
|
|
29
|
+
box-shadow: 0 0 4px var(--color-on-primary), 0 0 4px var(--color-primary), 0 0 8px var(--color-primary);
|
|
30
|
+
}
|
|
25
31
|
|
|
26
32
|
.secondary {
|
|
27
33
|
background: var(--color-secondary-container);
|
|
28
34
|
color: var(--color-on-secondary-container);
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
.secondary:hover:not(:disabled) {
|
|
38
|
+
border: 2px solid var(--color-secondary);
|
|
39
|
+
box-shadow: 0 0 4px var(--color-on-secondary), 0 0 4px var(--color-secondary), 0 0 8px var(--color-secondary);
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
|
|
32
43
|
.error {
|
|
33
44
|
background: var(--color-error-container);
|
|
34
45
|
color: var(--color-on-error-container);
|
|
35
46
|
}
|
|
36
47
|
|
|
48
|
+
.error:hover:not(:disabled) {
|
|
49
|
+
border: 2px solid var(--color-error);
|
|
50
|
+
box-shadow: 0 0 4px var(--color-on-error), 0 0 4px var(--color-error), 0 0 8px var(--color-error);
|
|
51
|
+
}
|
|
52
|
+
|
|
37
53
|
|
|
38
54
|
/* ===== Size ===== */
|
|
39
55
|
|
|
@@ -49,6 +65,8 @@
|
|
|
49
65
|
|
|
50
66
|
/* ===== State ===== */
|
|
51
67
|
|
|
68
|
+
|
|
69
|
+
|
|
52
70
|
.button:active:not(:disabled),
|
|
53
71
|
.button[data-state="pressed"] {
|
|
54
72
|
box-shadow: none;
|
|
@@ -31,11 +31,11 @@ const meta = {
|
|
|
31
31
|
export default meta;
|
|
32
32
|
export const Default = {};
|
|
33
33
|
export const State = {
|
|
34
|
-
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap:
|
|
34
|
+
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 32 }, children: [_jsx(Button, { variant: "default", children: "Default" }), _jsx(Button, { variant: "default", "data-state": "pressed", children: "Pressed" }), _jsx(Button, { variant: "default", disabled: true, children: "Disabled" })] })),
|
|
35
35
|
};
|
|
36
36
|
export const Variants = {
|
|
37
|
-
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap:
|
|
37
|
+
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 32 }, children: [_jsx(Button, { variant: "default", children: "Default" }), _jsx(Button, { variant: "primary", children: "Primary" }), _jsx(Button, { variant: "secondary", children: "Secondary" }), _jsx(Button, { variant: "error", children: "Error" })] })),
|
|
38
38
|
};
|
|
39
39
|
export const Sizes = {
|
|
40
|
-
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap:
|
|
40
|
+
render: () => (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 32 }, children: [_jsx(Button, { size: "sm", children: "Small" }), _jsx(Button, { size: "md", children: "Medium" })] })),
|
|
41
41
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
border-radius: var(--radius-sm);
|
|
5
5
|
border: 2px solid var(--color-surface);
|
|
6
6
|
outline: none;
|
|
7
|
-
box-shadow: var(--shadow-sm-in)
|
|
7
|
+
box-shadow: var(--shadow-sm-in);
|
|
8
8
|
|
|
9
9
|
background: var(--color-surface-container);
|
|
10
10
|
color: var(--color-on-surface);
|
|
@@ -12,21 +12,19 @@
|
|
|
12
12
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/* ===== Focus ===== */
|
|
16
15
|
|
|
16
|
+
/* ===== Focus ===== */
|
|
17
17
|
.input:focus {
|
|
18
18
|
outline: none;
|
|
19
19
|
border: 2px solid var(--color-primary);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/* ===== Error ===== */
|
|
23
|
-
|
|
24
23
|
.error {
|
|
25
24
|
border: 2px solid var(--color-error);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
/* ===== Disabled ===== */
|
|
29
|
-
|
|
30
28
|
.input:disabled {
|
|
31
29
|
opacity: 0.5;
|
|
32
30
|
cursor: not-allowed;
|
|
@@ -12,6 +12,6 @@ export const Default = {
|
|
|
12
12
|
};
|
|
13
13
|
export const State = {
|
|
14
14
|
render: () => {
|
|
15
|
-
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap:
|
|
15
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 32 }, children: [_jsx(Input, { placeholder: "Default State", state: "default" }), _jsx(Input, { placeholder: "Error State", state: "error" }), _jsx(Input, { placeholder: "Disabled State", disabled: true })] }));
|
|
16
16
|
},
|
|
17
17
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
.select {
|
|
2
2
|
font-family: var(--font);
|
|
3
3
|
padding: var(--space-sm) var(--space-md);
|
|
4
|
+
border: 2px solid transparent;
|
|
4
5
|
border-radius: var(--radius-sm);
|
|
5
6
|
box-shadow: var(--shadow-sm);
|
|
6
7
|
|
|
7
|
-
background
|
|
8
|
+
background: var(--color-surface-container);
|
|
8
9
|
color: var(--color-on-surface);
|
|
9
10
|
|
|
10
11
|
appearance: none;
|
|
@@ -22,6 +23,8 @@
|
|
|
22
23
|
cursor: pointer;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
|
|
27
|
+
|
|
25
28
|
select:has(option[value=""]:checked) {
|
|
26
29
|
color: var(--color-on-surface);
|
|
27
30
|
}
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
--color-border: #6f7979;
|
|
34
34
|
--color-scrim: rgba(129, 129, 129, 0.25);
|
|
35
35
|
|
|
36
|
-
/* ===== Effect ===== */
|
|
37
|
-
--blur: blur(8px);
|
|
38
|
-
|
|
39
36
|
--color-shadow-l: rgba(255, 255, 255, 1);
|
|
40
37
|
--color-shadow-d: rgba(0, 0, 0, 0.2);
|
|
41
38
|
|
|
39
|
+
/* ===== Effect ===== */
|
|
40
|
+
--blur: blur(8px);
|
|
41
|
+
|
|
42
42
|
--shadow-sm: -2px -2px 4px 2px var(--color-shadow-l),
|
|
43
43
|
2px 2px 4px 2px var(--color-shadow-d);
|
|
44
44
|
|
|
@@ -101,12 +101,16 @@
|
|
|
101
101
|
|
|
102
102
|
--color-surface-container: #262d2d;
|
|
103
103
|
--color-border: #889392;
|
|
104
|
-
--color-scrim: rgba(0, 0, 0, 0.
|
|
104
|
+
--color-scrim: rgba(0, 0, 0, 0.25);
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
--color-shadow-l: rgba(255, 255, 255, 0.25);
|
|
108
108
|
--color-shadow-d: rgba(0, 0, 0, 1);
|
|
109
109
|
|
|
110
|
+
|
|
111
|
+
/* ===== Effect ===== */
|
|
112
|
+
--blur: blur(8px);
|
|
113
|
+
|
|
110
114
|
--shadow-sm: -2px -2px 4px 2px var(--color-shadow-l),
|
|
111
115
|
2px 2px 4px 4px var(--color-shadow-d);
|
|
112
116
|
|