lucentia-ui 0.1.2 → 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 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: none;
4
+ border: 2px solid transparent;
5
5
  cursor: pointer;
6
6
 
7
- border-radius: var(--radius-max);
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: 16 }, children: [_jsx(Button, { variant: "default", children: "Default" }), _jsx(Button, { variant: "default", "data-state": "pressed", children: "Pressed" }), _jsx(Button, { variant: "default", disabled: true, children: "Disabled" })] })),
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: 16 }, 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" })] })),
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: 16 }, children: [_jsx(Button, { size: "sm", children: "Small" }), _jsx(Button, { size: "md", children: "Medium" })] })),
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), var(--shadow-sm);
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: 16 }, children: [_jsx(Input, { placeholder: "Default State", state: "default" }), _jsx(Input, { placeholder: "Error State", state: "error" }), _jsx(Input, { placeholder: "Disabled State", disabled: true })] }));
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-color: var(--color-surface-container);
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
  }
@@ -1,13 +1,7 @@
1
1
  import type { Theme } from "./types";
2
- /**
3
- * ThemeProvider
4
- *
5
- * - DOM を描画しない(ラッパー要素なし)
6
- * - html 要素に theme class を直接付与する
7
- * - CSS 変数の定義は styles/theme.css に集約する
8
- */
9
- interface ThemeProviderProps {
2
+ type ThemeProviderProps = {
10
3
  theme?: Theme;
11
- }
12
- export declare function ThemeProvider({ theme }: ThemeProviderProps): null;
4
+ children: React.ReactNode;
5
+ };
6
+ export declare function ThemeProvider({ theme, children, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
13
7
  export {};
@@ -1,11 +1,5 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- export function ThemeProvider({ theme = "light" }) {
4
- useEffect(() => {
5
- const root = document.documentElement;
6
- // 初期化
7
- root.classList.remove("light", "dark");
8
- root.classList.add("theme", theme);
9
- }, [theme]);
10
- return null;
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styles from "./ThemeProvider.module.css";
3
+ export function ThemeProvider({ theme = "light", children, }) {
4
+ return (_jsx("div", { className: `${styles.theme} ${theme === "dark" ? styles.dark : styles.light}`, children: children }));
11
5
  }
@@ -0,0 +1,142 @@
1
+ .theme {
2
+ min-height: 100%;
3
+ }
4
+
5
+
6
+ .light {
7
+ /* font */
8
+ --font: "Noto Sans JP", sans-serif;
9
+
10
+ /* ===== Color ===== */
11
+ --color-primary: #00a1a1;
12
+ --color-on-primary: #ffffff;
13
+ --color-primary-container: #9cf1f0;
14
+ --color-on-primary-container: #004f4f;
15
+
16
+ --color-secondary: #7b9695;
17
+ --color-on-secondary: #ffffff;
18
+ --color-secondary-container: #cce8e7;
19
+ --color-on-secondary-container: #324b4b;
20
+
21
+ --color-error: #ff5449;
22
+ --color-on-error: #ffffff;
23
+ --color-error-container: #ffdad6;
24
+ --color-on-error-container: #93000a;
25
+
26
+ --color-background: #f4fbfa;
27
+ --color-on-background: #161d1d;
28
+
29
+ --color-surface: #f4fbfabf;
30
+ --color-on-surface: #161d1d;
31
+ --color-surface-container: #e9efeebf;
32
+
33
+ --color-border: #6f7979;
34
+ --color-scrim: rgba(129, 129, 129, 0.25);
35
+
36
+ --color-shadow-l: rgba(255, 255, 255, 1);
37
+ --color-shadow-d: rgba(0, 0, 0, 0.2);
38
+
39
+ /* ===== Effect ===== */
40
+ --blur: blur(8px);
41
+
42
+ --shadow-sm: -2px -2px 4px 2px var(--color-shadow-l),
43
+ 2px 2px 4px 2px var(--color-shadow-d);
44
+
45
+ --shadow-sm-in: inset -4px -4px 4px var(--color-shadow-l),
46
+ inset 4px 4px 4px var(--color-shadow-d);
47
+
48
+ --shadow-md: -4px -4px 16px 8px var(--color-shadow-l),
49
+ 4px 4px 16px 8px var(--color-shadow-d);
50
+
51
+
52
+
53
+ /* ===== Radius ===== */
54
+ --radius-sm: 8px;
55
+ --radius-md: 16px;
56
+ --radius-max: 999px;
57
+
58
+ /* ===== Space ===== */
59
+ --space-xs: 4px;
60
+ --space-sm: 8px;
61
+ --space-md: 12px;
62
+ --space-lg: 16px;
63
+ --space-xl: 24px;
64
+ --space-2xl: 32px;
65
+ --space-3xl: 48px;
66
+ --space-4xl: 64px;
67
+ --space-5xl: 96px;
68
+ --gap: 32px;
69
+
70
+ /* ===== Layout ===== */
71
+ --container: 1120px;
72
+ }
73
+
74
+
75
+ .dark{
76
+ --color-primary: #80d5d4;
77
+ --color-on-primary: #003737;
78
+ --color-primary-container: #004f4f;
79
+ --color-on-primary-container: #9cf1f0;
80
+
81
+
82
+ --color-secondary: #b0cccb;
83
+ --color-on-secondary: #1b3534;
84
+ --color-secondary-container: #324b4b;
85
+ --color-on-secondary-container: #cce8e7;
86
+
87
+
88
+ --color-error: #ffb4ab;
89
+ --color-on-error: #690005;
90
+ --color-error-container: #93000a;
91
+ --color-on-error-container: #ffdad6;
92
+
93
+
94
+ --color-background: #2b3a38;
95
+ --color-on-background: #dde4e3;
96
+
97
+
98
+ --color-surface: #1a2120bf;
99
+ --color-on-surface: #dde4e3;
100
+
101
+
102
+ --color-surface-container: #262d2d;
103
+ --color-border: #889392;
104
+ --color-scrim: rgba(0, 0, 0, 0.25);
105
+
106
+
107
+ --color-shadow-l: rgba(255, 255, 255, 0.25);
108
+ --color-shadow-d: rgba(0, 0, 0, 1);
109
+
110
+
111
+ /* ===== Effect ===== */
112
+ --blur: blur(8px);
113
+
114
+ --shadow-sm: -2px -2px 4px 2px var(--color-shadow-l),
115
+ 2px 2px 4px 4px var(--color-shadow-d);
116
+
117
+ --shadow-sm-in: inset -4px -4px 4px var(--color-shadow-l),
118
+ inset 4px 4px 4px var(--color-shadow-d);
119
+
120
+ --shadow-md: -4px -4px 16px 8px var(--color-shadow-l),
121
+ 4px 4px 16px 8px var(--color-shadow-d);
122
+
123
+ /* ===== Radius ===== */
124
+ --radius-sm: 8px;
125
+ --radius-md: 16px;
126
+ --radius-max: 999px;
127
+
128
+ /* ===== Space ===== */
129
+ --space-xs: 4px;
130
+ --space-sm: 8px;
131
+ --space-md: 12px;
132
+ --space-lg: 16px;
133
+ --space-xl: 24px;
134
+ --space-2xl: 32px;
135
+ --space-3xl: 48px;
136
+ --space-4xl: 64px;
137
+ --space-5xl: 96px;
138
+ --gap: 32px;
139
+
140
+ /* ===== Layout ===== */
141
+ --container: 1120px;
142
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  export { ThemeProvider } from "./components/ThemeProvider";
2
2
  export type { Theme } from "./components/ThemeProvider";
3
- import "./styles/reset.css";
4
- import "./styles/base.css";
5
- import "./styles/tokens/index.css";
6
- import "./styles/font.css";
7
3
  export * from "./components/Button";
8
4
  export * from "./components/Checkbox";
9
5
  export * from "./components/Radio";
package/dist/index.js CHANGED
@@ -1,10 +1,5 @@
1
1
  /* ===== Theme ===== */
2
2
  export { ThemeProvider } from "./components/ThemeProvider";
3
- /* ===== Styles ===== */
4
- import "./styles/reset.css";
5
- import "./styles/base.css";
6
- import "./styles/tokens/index.css";
7
- import "./styles/font.css";
8
3
  /* ===== Components ===== */
9
4
  export * from "./components/Button";
10
5
  export * from "./components/Checkbox";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucentia-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Minimal React UI components with design tokens",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",