@sustaina/shared-ui 1.3.0 → 1.3.1
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 +1 -273
- package/README.md.local-bak +273 -0
- package/dist/index.css +128 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1997 -138
- package/dist/index.d.ts +1997 -138
- package/dist/index.js +18932 -4528
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18721 -4584
- package/dist/index.mjs.map +1 -1
- package/package.json +40 -14
package/README.md
CHANGED
|
@@ -1,273 +1 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# 📦 Installation
|
|
4
|
-
|
|
5
|
-
To use `@sustaina/shared-ui` in your project, follow these steps carefully.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Install UI package and required dependencies
|
|
10
|
-
|
|
11
|
-
Make sure you've installed [TailwindCSS](https://tailwindcss.com/docs/installation) and [shadcn/ui](https://ui.shadcn.com/docs/installation/manual) before installing our library. **Don’t skip this.**
|
|
12
|
-
|
|
13
|
-
### 1. Place shadcn/ui styles
|
|
14
|
-
|
|
15
|
-
```css
|
|
16
|
-
@import "tailwindcss";
|
|
17
|
-
@import "tw-animate-css";
|
|
18
|
-
@custom-variant dark (&:is(.dark *));
|
|
19
|
-
|
|
20
|
-
:root {
|
|
21
|
-
--background: oklch(1 0 0);
|
|
22
|
-
--foreground: oklch(0.145 0 0);
|
|
23
|
-
--card: oklch(1 0 0);
|
|
24
|
-
--card-foreground: oklch(0.145 0 0);
|
|
25
|
-
--popover: oklch(1 0 0);
|
|
26
|
-
--popover-foreground: oklch(0.145 0 0);
|
|
27
|
-
--primary: oklch(0.205 0 0);
|
|
28
|
-
--primary-foreground: oklch(0.985 0 0);
|
|
29
|
-
--secondary: oklch(0.97 0 0);
|
|
30
|
-
--secondary-foreground: oklch(0.205 0 0);
|
|
31
|
-
--muted: oklch(0.97 0 0);
|
|
32
|
-
--muted-foreground: oklch(0.556 0 0);
|
|
33
|
-
--accent: oklch(0.97 0 0);
|
|
34
|
-
--accent-foreground: oklch(0.205 0 0);
|
|
35
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
36
|
-
--destructive-foreground: oklch(0.577 0.245 27.325);
|
|
37
|
-
--border: oklch(0.922 0 0);
|
|
38
|
-
--input: oklch(0.922 0 0);
|
|
39
|
-
--ring: oklch(0.708 0 0);
|
|
40
|
-
--chart-1: oklch(0.646 0.222 41.116);
|
|
41
|
-
--chart-2: oklch(0.6 0.118 184.704);
|
|
42
|
-
--chart-3: oklch(0.398 0.07 227.392);
|
|
43
|
-
--chart-4: oklch(0.828 0.189 84.429);
|
|
44
|
-
--chart-5: oklch(0.769 0.188 70.08);
|
|
45
|
-
--radius: 0.625rem;
|
|
46
|
-
--sidebar: oklch(0.985 0 0);
|
|
47
|
-
--sidebar-foreground: oklch(0.145 0 0);
|
|
48
|
-
--sidebar-primary: oklch(0.205 0 0);
|
|
49
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
50
|
-
--sidebar-accent: oklch(0.97 0 0);
|
|
51
|
-
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
52
|
-
--sidebar-border: oklch(0.922 0 0);
|
|
53
|
-
--sidebar-ring: oklch(0.708 0 0);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.dark {
|
|
57
|
-
--background: oklch(0.145 0 0);
|
|
58
|
-
--foreground: oklch(0.985 0 0);
|
|
59
|
-
--card: oklch(0.145 0 0);
|
|
60
|
-
--card-foreground: oklch(0.985 0 0);
|
|
61
|
-
--popover: oklch(0.145 0 0);
|
|
62
|
-
--popover-foreground: oklch(0.985 0 0);
|
|
63
|
-
--primary: oklch(0.985 0 0);
|
|
64
|
-
--primary-foreground: oklch(0.205 0 0);
|
|
65
|
-
--secondary: oklch(0.269 0 0);
|
|
66
|
-
--secondary-foreground: oklch(0.985 0 0);
|
|
67
|
-
--muted: oklch(0.269 0 0);
|
|
68
|
-
--muted-foreground: oklch(0.708 0 0);
|
|
69
|
-
--accent: oklch(0.269 0 0);
|
|
70
|
-
--accent-foreground: oklch(0.985 0 0);
|
|
71
|
-
--destructive: oklch(0.396 0.141 25.723);
|
|
72
|
-
--destructive-foreground: oklch(0.637 0.237 25.331);
|
|
73
|
-
--border: oklch(0.269 0 0);
|
|
74
|
-
--input: oklch(0.269 0 0);
|
|
75
|
-
--ring: oklch(0.439 0 0);
|
|
76
|
-
--chart-1: oklch(0.488 0.243 264.376);
|
|
77
|
-
--chart-2: oklch(0.696 0.17 162.48);
|
|
78
|
-
--chart-3: oklch(0.769 0.188 70.08);
|
|
79
|
-
--chart-4: oklch(0.627 0.265 303.9);
|
|
80
|
-
--chart-5: oklch(0.645 0.246 16.439);
|
|
81
|
-
--sidebar: oklch(0.205 0 0);
|
|
82
|
-
--sidebar-foreground: oklch(0.985 0 0);
|
|
83
|
-
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
84
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
85
|
-
--sidebar-accent: oklch(0.269 0 0);
|
|
86
|
-
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
87
|
-
--sidebar-border: oklch(0.269 0 0);
|
|
88
|
-
--sidebar-ring: oklch(0.439 0 0);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@theme inline {
|
|
92
|
-
--color-background: var(--background);
|
|
93
|
-
--color-foreground: var(--foreground);
|
|
94
|
-
--color-card: var(--card);
|
|
95
|
-
--color-card-foreground: var(--card-foreground);
|
|
96
|
-
--color-popover: var(--popover);
|
|
97
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
98
|
-
--color-primary: var(--primary);
|
|
99
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
100
|
-
--color-secondary: var(--secondary);
|
|
101
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
102
|
-
--color-muted: var(--muted);
|
|
103
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
104
|
-
--color-accent: var(--accent);
|
|
105
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
106
|
-
--color-destructive: var(--destructive);
|
|
107
|
-
--color-destructive-foreground: var(--destructive-foreground);
|
|
108
|
-
--color-border: var(--border);
|
|
109
|
-
--color-input: var(--input);
|
|
110
|
-
--color-ring: var(--ring);
|
|
111
|
-
--color-chart-1: var(--chart-1);
|
|
112
|
-
--color-chart-2: var(--chart-2);
|
|
113
|
-
--color-chart-3: var(--chart-3);
|
|
114
|
-
--color-chart-4: var(--chart-4);
|
|
115
|
-
--color-chart-5: var(--chart-5);
|
|
116
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
117
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
118
|
-
--radius-lg: var(--radius);
|
|
119
|
-
--radius-xl: calc(var(--radius) + 4px);
|
|
120
|
-
--color-sidebar: var(--sidebar);
|
|
121
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
122
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
123
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
124
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
125
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
126
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
127
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@layer base {
|
|
131
|
-
* {
|
|
132
|
-
@apply border-border outline-ring/50;
|
|
133
|
-
}
|
|
134
|
-
body {
|
|
135
|
-
@apply bg-background text-foreground;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### 2. Install library
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
npm install @sustaina/shared-ui
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
### Peer Dependencies
|
|
149
|
-
|
|
150
|
-
You must manually install these peer dependencies in your host project:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
npm install react react-dom react-hook-form
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Supported versions:
|
|
157
|
-
|
|
158
|
-
```json
|
|
159
|
-
{
|
|
160
|
-
"peerDependencies": {
|
|
161
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
162
|
-
"react-dom": "^18.0.0 || ^19.0.0",
|
|
163
|
-
"react-hook-form": "^7.61.1"
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
> ⚠️ If your project doesn't match the version ranges above, you may get runtime or type errors.
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## 3. Add `@sustaina/shared-ui` to your CSS
|
|
173
|
-
|
|
174
|
-
To make styling work with our components, add this to your `index.css` or root CSS file:
|
|
175
|
-
|
|
176
|
-
```css
|
|
177
|
-
... omit code
|
|
178
|
-
@import "@sustaina/shared-ui/styles.css"; /* this include styles/theme.css already */
|
|
179
|
-
@source "../../node_modules/@sustaina/shared-ui/dist"; /* depend your root CSS file locate. */
|
|
180
|
-
... omit code
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
# Usage
|
|
186
|
-
|
|
187
|
-
Import `@sustaina/shared-ui` components within your React component files:
|
|
188
|
-
|
|
189
|
-
```tsx
|
|
190
|
-
import { Button } from "@sustaina/shared-ui";
|
|
191
|
-
|
|
192
|
-
export default function MyComponent() {
|
|
193
|
-
return <Button color="primary">Click me!</Button>;
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
# Developer Notes
|
|
200
|
-
|
|
201
|
-
## Git Flow
|
|
202
|
-
|
|
203
|
-
### How to developed
|
|
204
|
-
|
|
205
|
-
We follow a **`feature/xxx` → `dev` → `prod`** workflow:
|
|
206
|
-
|
|
207
|
-
- Developed on `feature/xxx` or `bugfix/xxx` or any what you want. Then **merge request** to `dev`
|
|
208
|
-
- Only `prod` branch triggers **npm package publishing**.
|
|
209
|
-
- To publish a new version:
|
|
210
|
-
- Create a **merge request from `dev` to `prod`**, or
|
|
211
|
-
- Contact your lead developer or maintainer to perform the merge.
|
|
212
|
-
|
|
213
|
-
### Versioning & Commits
|
|
214
|
-
|
|
215
|
-
We use **semantic versioning**:
|
|
216
|
-
|
|
217
|
-
- `patch` → bug fixes (`fix: description`)
|
|
218
|
-
- `minor` → new features (`feat: description`)
|
|
219
|
-
- All other commit types (e.g., `docs`, `chore`, `refactor`) **do not trigger a version change**.
|
|
220
|
-
|
|
221
|
-
**<em>no major change for now just use `patch` and `minor`</em>**
|
|
222
|
-
|
|
223
|
-
## CSS and Custom Styling
|
|
224
|
-
|
|
225
|
-
- **Prefer Tailwind classes inline** whenever possible.
|
|
226
|
-
- If additional CSS is needed, include it in your components.
|
|
227
|
-
- **Important:** After running `npm run build`, always check `dist/index.css` to ensure your custom styles are included in the final build.
|
|
228
|
-
|
|
229
|
-
- **Use `styles/theme.css` for global customizations**:
|
|
230
|
-
- Store custom shorthand colors, CSS variables, or utility classes here.
|
|
231
|
-
- <span style="color:red; font-weight:bold; text-decoration:underline; font-style:italic;">These styles will be available to consumers when they import the library `Go check step 3`.</span>
|
|
232
|
-
- Example:
|
|
233
|
-
```css
|
|
234
|
-
@theme {
|
|
235
|
-
--color-sus-primary-1: #000;
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
- **Reference:** [Tailwind Theme Variable Namespaces](https://tailwindcss.com/docs/theme#theme-variable-namespaces)
|
|
239
|
-
|
|
240
|
-
## Including External Files in the Build
|
|
241
|
-
|
|
242
|
-
- **Add your files to `copy-files-to-dist.js`**:
|
|
243
|
-
- This script handles copying files into the `dist` folder during the build process.
|
|
244
|
-
- Example entry:
|
|
245
|
-
```js
|
|
246
|
-
const filesToCopy = [
|
|
247
|
-
{
|
|
248
|
-
from: "./src/styles/theme.css",
|
|
249
|
-
to: "./dist/index.css",
|
|
250
|
-
mode: "prepend" // "replace" | "append" | "prepend"
|
|
251
|
-
}
|
|
252
|
-
];
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
- **How `mode` works:**
|
|
256
|
-
- `"replace"` → overwrite the destination file completely.
|
|
257
|
-
- `"append"` → add content at the end of the destination file.
|
|
258
|
-
- `"prepend"` → add content at the beginning of the destination file.
|
|
259
|
-
- This script handles copying files into the `dist` folder during the build process.
|
|
260
|
-
- After copying files, you can export them for consumers.
|
|
261
|
-
- Add `exports` your file in `package.json`
|
|
262
|
-
```json
|
|
263
|
-
"exports": {
|
|
264
|
-
".": {
|
|
265
|
-
"require": "./dist/index.js",
|
|
266
|
-
"import": "./dist/index.mjs",
|
|
267
|
-
"types": "./dist/index.d.ts"
|
|
268
|
-
},
|
|
269
|
-
"./styles.css": "./dist/index.css",
|
|
270
|
-
"./helpers": "./dist/helpers.js"
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
- **Note:** This will happen automatically when you run `npm run build`.
|
|
1
|
+
# sustaina-share-ui
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Sustaina - Shared UI
|
|
2
|
+
|
|
3
|
+
# 📦 Installation
|
|
4
|
+
|
|
5
|
+
To use `@sustaina/shared-ui` in your project, follow these steps carefully.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install UI package and required dependencies
|
|
10
|
+
|
|
11
|
+
Make sure you've installed [TailwindCSS](https://tailwindcss.com/docs/installation) and [shadcn/ui](https://ui.shadcn.com/docs/installation/manual) before installing our library. **Don’t skip this.**
|
|
12
|
+
|
|
13
|
+
### 1. Place shadcn/ui styles
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
@import "tailwindcss";
|
|
17
|
+
@import "tw-animate-css";
|
|
18
|
+
@custom-variant dark (&:is(.dark *));
|
|
19
|
+
|
|
20
|
+
:root {
|
|
21
|
+
--background: oklch(1 0 0);
|
|
22
|
+
--foreground: oklch(0.145 0 0);
|
|
23
|
+
--card: oklch(1 0 0);
|
|
24
|
+
--card-foreground: oklch(0.145 0 0);
|
|
25
|
+
--popover: oklch(1 0 0);
|
|
26
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
27
|
+
--primary: oklch(0.205 0 0);
|
|
28
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
29
|
+
--secondary: oklch(0.97 0 0);
|
|
30
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
31
|
+
--muted: oklch(0.97 0 0);
|
|
32
|
+
--muted-foreground: oklch(0.556 0 0);
|
|
33
|
+
--accent: oklch(0.97 0 0);
|
|
34
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
35
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
36
|
+
--destructive-foreground: oklch(0.577 0.245 27.325);
|
|
37
|
+
--border: oklch(0.922 0 0);
|
|
38
|
+
--input: oklch(0.922 0 0);
|
|
39
|
+
--ring: oklch(0.708 0 0);
|
|
40
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
41
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
42
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
43
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
44
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
45
|
+
--radius: 0.625rem;
|
|
46
|
+
--sidebar: oklch(0.985 0 0);
|
|
47
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
48
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
49
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
50
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
51
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
52
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
53
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dark {
|
|
57
|
+
--background: oklch(0.145 0 0);
|
|
58
|
+
--foreground: oklch(0.985 0 0);
|
|
59
|
+
--card: oklch(0.145 0 0);
|
|
60
|
+
--card-foreground: oklch(0.985 0 0);
|
|
61
|
+
--popover: oklch(0.145 0 0);
|
|
62
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
63
|
+
--primary: oklch(0.985 0 0);
|
|
64
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
65
|
+
--secondary: oklch(0.269 0 0);
|
|
66
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
67
|
+
--muted: oklch(0.269 0 0);
|
|
68
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
69
|
+
--accent: oklch(0.269 0 0);
|
|
70
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
71
|
+
--destructive: oklch(0.396 0.141 25.723);
|
|
72
|
+
--destructive-foreground: oklch(0.637 0.237 25.331);
|
|
73
|
+
--border: oklch(0.269 0 0);
|
|
74
|
+
--input: oklch(0.269 0 0);
|
|
75
|
+
--ring: oklch(0.439 0 0);
|
|
76
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
77
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
78
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
79
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
80
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
81
|
+
--sidebar: oklch(0.205 0 0);
|
|
82
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
83
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
84
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
85
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
86
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
87
|
+
--sidebar-border: oklch(0.269 0 0);
|
|
88
|
+
--sidebar-ring: oklch(0.439 0 0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@theme inline {
|
|
92
|
+
--color-background: var(--background);
|
|
93
|
+
--color-foreground: var(--foreground);
|
|
94
|
+
--color-card: var(--card);
|
|
95
|
+
--color-card-foreground: var(--card-foreground);
|
|
96
|
+
--color-popover: var(--popover);
|
|
97
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
98
|
+
--color-primary: var(--primary);
|
|
99
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
100
|
+
--color-secondary: var(--secondary);
|
|
101
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
102
|
+
--color-muted: var(--muted);
|
|
103
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
104
|
+
--color-accent: var(--accent);
|
|
105
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
106
|
+
--color-destructive: var(--destructive);
|
|
107
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
108
|
+
--color-border: var(--border);
|
|
109
|
+
--color-input: var(--input);
|
|
110
|
+
--color-ring: var(--ring);
|
|
111
|
+
--color-chart-1: var(--chart-1);
|
|
112
|
+
--color-chart-2: var(--chart-2);
|
|
113
|
+
--color-chart-3: var(--chart-3);
|
|
114
|
+
--color-chart-4: var(--chart-4);
|
|
115
|
+
--color-chart-5: var(--chart-5);
|
|
116
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
117
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
118
|
+
--radius-lg: var(--radius);
|
|
119
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
120
|
+
--color-sidebar: var(--sidebar);
|
|
121
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
122
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
123
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
124
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
125
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
126
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
127
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@layer base {
|
|
131
|
+
* {
|
|
132
|
+
@apply border-border outline-ring/50;
|
|
133
|
+
}
|
|
134
|
+
body {
|
|
135
|
+
@apply bg-background text-foreground;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Install library
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm install @sustaina/shared-ui
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### Peer Dependencies
|
|
149
|
+
|
|
150
|
+
You must manually install these peer dependencies in your host project:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm install react react-dom react-hook-form
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Supported versions:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"peerDependencies": {
|
|
161
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
162
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
163
|
+
"react-hook-form": "^7.61.1"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
> ⚠️ If your project doesn't match the version ranges above, you may get runtime or type errors.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 3. Add `@sustaina/shared-ui` to your CSS
|
|
173
|
+
|
|
174
|
+
To make styling work with our components, add this to your `index.css` or root CSS file:
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
... omit code
|
|
178
|
+
@import "@sustaina/shared-ui/styles.css"; /* this include styles/theme.css already */
|
|
179
|
+
@source "../../node_modules/@sustaina/shared-ui/dist"; /* depend your root CSS file locate. */
|
|
180
|
+
... omit code
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
# Usage
|
|
186
|
+
|
|
187
|
+
Import `@sustaina/shared-ui` components within your React component files:
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { Button } from "@sustaina/shared-ui";
|
|
191
|
+
|
|
192
|
+
export default function MyComponent() {
|
|
193
|
+
return <Button color="primary">Click me!</Button>;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
# Developer Notes
|
|
200
|
+
|
|
201
|
+
## Git Flow
|
|
202
|
+
|
|
203
|
+
### How to developed
|
|
204
|
+
|
|
205
|
+
We follow a **`feature/xxx` → `dev` → `prod`** workflow:
|
|
206
|
+
|
|
207
|
+
- Developed on `feature/xxx` or `bugfix/xxx` or any what you want. Then **merge request** to `dev`
|
|
208
|
+
- Only `prod` branch triggers **npm package publishing**.
|
|
209
|
+
- To publish a new version:
|
|
210
|
+
- Create a **merge request from `dev` to `prod`**, or
|
|
211
|
+
- Contact your lead developer or maintainer to perform the merge.
|
|
212
|
+
|
|
213
|
+
### Versioning & Commits
|
|
214
|
+
|
|
215
|
+
We use **semantic versioning**:
|
|
216
|
+
|
|
217
|
+
- `patch` → bug fixes (`fix: description`)
|
|
218
|
+
- `minor` → new features (`feat: description`)
|
|
219
|
+
- All other commit types (e.g., `docs`, `chore`, `refactor`) **do not trigger a version change**.
|
|
220
|
+
|
|
221
|
+
**<em>no major change for now just use `patch` and `minor`</em>**
|
|
222
|
+
|
|
223
|
+
## CSS and Custom Styling
|
|
224
|
+
|
|
225
|
+
- **Prefer Tailwind classes inline** whenever possible.
|
|
226
|
+
- If additional CSS is needed, include it in your components.
|
|
227
|
+
- **Important:** After running `npm run build`, always check `dist/index.css` to ensure your custom styles are included in the final build.
|
|
228
|
+
|
|
229
|
+
- **Use `styles/theme.css` for global customizations**:
|
|
230
|
+
- Store custom shorthand colors, CSS variables, or utility classes here.
|
|
231
|
+
- <span style="color:red; font-weight:bold; text-decoration:underline; font-style:italic;">These styles will be available to consumers when they import the library `Go check step 3`.</span>
|
|
232
|
+
- Example:
|
|
233
|
+
```css
|
|
234
|
+
@theme {
|
|
235
|
+
--color-sus-primary-1: #000;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
- **Reference:** [Tailwind Theme Variable Namespaces](https://tailwindcss.com/docs/theme#theme-variable-namespaces)
|
|
239
|
+
|
|
240
|
+
## Including External Files in the Build
|
|
241
|
+
|
|
242
|
+
- **Add your files to `copy-files-to-dist.js`**:
|
|
243
|
+
- This script handles copying files into the `dist` folder during the build process.
|
|
244
|
+
- Example entry:
|
|
245
|
+
```js
|
|
246
|
+
const filesToCopy = [
|
|
247
|
+
{
|
|
248
|
+
from: "./src/styles/theme.css",
|
|
249
|
+
to: "./dist/index.css",
|
|
250
|
+
mode: "prepend" // "replace" | "append" | "prepend"
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- **How `mode` works:**
|
|
256
|
+
- `"replace"` → overwrite the destination file completely.
|
|
257
|
+
- `"append"` → add content at the end of the destination file.
|
|
258
|
+
- `"prepend"` → add content at the beginning of the destination file.
|
|
259
|
+
- This script handles copying files into the `dist` folder during the build process.
|
|
260
|
+
- After copying files, you can export them for consumers.
|
|
261
|
+
- Add `exports` your file in `package.json`
|
|
262
|
+
```json
|
|
263
|
+
"exports": {
|
|
264
|
+
".": {
|
|
265
|
+
"require": "./dist/index.js",
|
|
266
|
+
"import": "./dist/index.mjs",
|
|
267
|
+
"types": "./dist/index.d.ts"
|
|
268
|
+
},
|
|
269
|
+
"./styles.css": "./dist/index.css",
|
|
270
|
+
"./helpers": "./dist/helpers.js"
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
- **Note:** This will happen automatically when you run `npm run build`.
|
package/dist/index.css
CHANGED
|
@@ -21,14 +21,134 @@
|
|
|
21
21
|
--color-sus-gray-3: #eaeaea;
|
|
22
22
|
--color-sus-gray-4: #f7fcf9;
|
|
23
23
|
--color-sus-gray-5: #41875c;
|
|
24
|
+
--color-sus-gray-6: #a7adb8;
|
|
25
|
+
--color-sus-blue-1: #3b69b1;
|
|
26
|
+
--color-sus-blue-2: #1598b0;
|
|
27
|
+
--color-sus-blue-3: #6084c1;
|
|
24
28
|
--color-sus-primary-1-hover: rgba(50, 100, 70, 1);
|
|
25
29
|
--color-sus-primary-2-hover: #8db89c;
|
|
26
30
|
--color-sus-primary-3-hover: #eff5f1;
|
|
27
31
|
--color-sus-primary-1-active: #dfeae3;
|
|
28
32
|
--color-sus-secondary-hover: #907b46;
|
|
33
|
+
|
|
34
|
+
/* update ui 22-12-2025 */
|
|
35
|
+
--color-sus-main-accent: #379a2a;
|
|
36
|
+
--color-sus-main-gray: #000000;
|
|
37
|
+
--color-sus-main-background: #ffffff;
|
|
38
|
+
--color-sus-primary-green-1: #fbfefa;
|
|
39
|
+
--color-sus-primary-green-2: #f5fbf4;
|
|
40
|
+
--color-sus-primary-green-3: #e8f7e6;
|
|
41
|
+
--color-sus-primary-green-4: #d9f1d5;
|
|
42
|
+
--color-sus-primary-green-5: #c7eac2;
|
|
43
|
+
--color-sus-primary-green-6: #b0dfaa;
|
|
44
|
+
--color-sus-primary-green-7: #92d089;
|
|
45
|
+
--color-sus-primary-green-8: #64bc59;
|
|
46
|
+
--color-sus-primary-green-9: #379a2a;
|
|
47
|
+
--color-sus-primary-green-10: #338b27;
|
|
48
|
+
--color-sus-primary-green-11: #268019;
|
|
49
|
+
--color-sus-primary-green-12: #203d1c;
|
|
50
|
+
--color-sus-secondary-green-1: #fdfefc;
|
|
51
|
+
--color-sus-secondary-green-2: #f6faf7;
|
|
52
|
+
--color-sus-secondary-green-3: #eaf5ee;
|
|
53
|
+
--color-sus-secondary-green-4: #dceee3;
|
|
54
|
+
--color-sus-secondary-green-5: #cee6d6;
|
|
55
|
+
--color-sus-secondary-green-6: #bcd9c7;
|
|
56
|
+
--color-sus-secondary-green-7: #a4c8b0;
|
|
57
|
+
--color-sus-secondary-green-8: #80b292;
|
|
58
|
+
--color-sus-secondary-green-9: #82b495;
|
|
59
|
+
--color-sus-secondary-green-10: #77a989;
|
|
60
|
+
--color-sus-secondary-green-11: #48785b;
|
|
61
|
+
--color-sus-secondary-green-12: #28392e;
|
|
62
|
+
--color-sus-secondary-gray-1: #fcfcfc;
|
|
63
|
+
--color-sus-secondary-gray-2: #f9f9f9;
|
|
64
|
+
--color-sus-secondary-gray-3: #f0f0f0;
|
|
65
|
+
--color-sus-secondary-gray-4: #e8e8e8;
|
|
66
|
+
--color-sus-secondary-gray-5: #e1e1e1;
|
|
67
|
+
--color-sus-secondary-gray-6: #d9d9d9;
|
|
68
|
+
--color-sus-secondary-gray-7: #cecece;
|
|
69
|
+
--color-sus-secondary-gray-8: #bbbbbb;
|
|
70
|
+
--color-sus-secondary-gray-9: #8c8c8c;
|
|
71
|
+
--color-sus-secondary-gray-10: #818181;
|
|
72
|
+
--color-sus-secondary-gray-11: #636363;
|
|
73
|
+
--color-sus-secondary-gray-12: #1f1f1f;
|
|
74
|
+
--color-sus-alert-positive-1: #92d08b;
|
|
75
|
+
--color-sus-alert-positive-2: #64bc59;
|
|
76
|
+
--color-sus-alert-positive-3: #37742f;
|
|
77
|
+
--color-sus-alert-info-1: #6f9deb;
|
|
78
|
+
--color-sus-alert-info-2: #2e70e2;
|
|
79
|
+
--color-sus-alert-info-3: #144190;
|
|
80
|
+
--color-sus-alert-warning-1: #fffbe6;
|
|
81
|
+
--color-sus-alert-warning-2: #fff3b8;
|
|
82
|
+
--color-sus-alert-warning-3: #ffeb8a;
|
|
83
|
+
--color-sus-alert-warning-4: #ffe45c;
|
|
84
|
+
--color-sus-alert-warning-5: #ffdd2f;
|
|
85
|
+
--color-sus-alert-warning-6: #fed503;
|
|
86
|
+
--color-sus-alert-warning-7: #d1af01;
|
|
87
|
+
--color-sus-alert-warning-8: #a38800;
|
|
88
|
+
--color-sus-alert-warning-9: #756200;
|
|
89
|
+
--color-sus-alert-warning-10: #463c01;
|
|
90
|
+
--color-sus-alert-warning-11: #1a1500;
|
|
91
|
+
--color-sus-alert-negative-1: #fbeaeb;
|
|
92
|
+
--color-sus-alert-negative-2: #f3c4c5;
|
|
93
|
+
--color-sus-alert-negative-3: #ea9f9f;
|
|
94
|
+
--color-sus-alert-negative-4: #e2787a;
|
|
95
|
+
--color-sus-alert-negative-5: #da5256;
|
|
96
|
+
--color-sus-alert-negative-6: #c32a2c;
|
|
97
|
+
--color-sus-alert-negative-7: #ad2527;
|
|
98
|
+
--color-sus-alert-negative-8: #871d1e;
|
|
99
|
+
--color-sus-alert-negative-9: #611516;
|
|
100
|
+
--color-sus-alert-negative-10: #3b0c0d;
|
|
101
|
+
--color-sus-alert-negative-11: #150405;
|
|
102
|
+
--color-sus-button-accent-1: #cecece;
|
|
103
|
+
--color-sus-button-accent-2: #8b8b8b;
|
|
104
|
+
--color-sus-button-accent-3: #646464;
|
|
105
|
+
--color-sus-button-red-1: #ec8f83;
|
|
106
|
+
--color-sus-button-red-2: #bf3630;
|
|
107
|
+
--color-sus-button-red-3: #bb0b0e;
|
|
108
|
+
--color-sus-button-yellow-1: #ffe470;
|
|
109
|
+
--color-sus-button-yellow-2: #ffd503;
|
|
110
|
+
--color-sus-button-yellow-3: #f0c000;
|
|
111
|
+
--color-sus-button-yellowdark-1: #b9a874;
|
|
112
|
+
--color-sus-button-yellowdark-2: #a49053;
|
|
113
|
+
--color-sus-button-yellowdark-3: #8b7a46;
|
|
114
|
+
--color-sus-button-green-1: #a3c8b0;
|
|
115
|
+
--color-sus-button-green-2: #82b495;
|
|
116
|
+
--color-sus-button-green-3: #48785b;
|
|
117
|
+
--color-sus-button-blue-1: #89a9dd;
|
|
118
|
+
--color-sus-button-blue-2: #6084c1;
|
|
119
|
+
--color-sus-button-blue-3: #5177b8;
|
|
120
|
+
--color-sus-button-black-1: #616161;
|
|
121
|
+
--color-sus-button-black-2: #303030;
|
|
122
|
+
--color-sus-button-black-3: #000000;
|
|
123
|
+
|
|
124
|
+
/* animate */
|
|
125
|
+
--animate-sus-spinner: sus-spinner 1s linear infinite;
|
|
126
|
+
@keyframes sus-spinner {
|
|
127
|
+
0% {
|
|
128
|
+
opacity: 1;
|
|
129
|
+
}
|
|
130
|
+
10% {
|
|
131
|
+
opacity: 0.7;
|
|
132
|
+
}
|
|
133
|
+
20% {
|
|
134
|
+
opacity: 0.3;
|
|
135
|
+
}
|
|
136
|
+
35% {
|
|
137
|
+
opacity: 0.2;
|
|
138
|
+
}
|
|
139
|
+
50% {
|
|
140
|
+
opacity: 0.1;
|
|
141
|
+
}
|
|
142
|
+
75% {
|
|
143
|
+
opacity: 0.05;
|
|
144
|
+
}
|
|
145
|
+
100% {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
29
149
|
}
|
|
30
150
|
|
|
31
|
-
/* src/
|
|
151
|
+
/* src/styles/index.css */
|
|
32
152
|
.clear-button {
|
|
33
153
|
width: 15px;
|
|
34
154
|
height: 15px;
|
|
@@ -61,4 +181,11 @@
|
|
|
61
181
|
padding: 0;
|
|
62
182
|
aspect-ratio: 1/1;
|
|
63
183
|
}
|
|
184
|
+
.hide-scrollbar {
|
|
185
|
+
-ms-overflow-style: none;
|
|
186
|
+
scrollbar-width: none;
|
|
187
|
+
}
|
|
188
|
+
.hide-scrollbar::-webkit-scrollbar {
|
|
189
|
+
display: none;
|
|
190
|
+
}
|
|
64
191
|
/*# sourceMappingURL=index.css.map */
|
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/styles/index.css"],"sourcesContent":[".clear-button {\n width: 15px;\n height: 15px;\n font-weight: bold;\n border-radius: 50%;\n background-color: black;\n color: white;\n border: 1px solid black;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.15s ease;\n padding: 0;\n cursor: pointer;\n}\n\n.clear-button:hover {\n background-color: #333; /* เข้มขึ้นเวลา hover */\n}\n\n.clear-button .icon {\n width: 13px;\n height: 13px;\n}\n\n.circle-btn {\n width: 24px; /* small size */\n height: 24px; /* same as width */\n border-radius: 50%; /* perfect circle */\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0; /* remove default button padding */\n aspect-ratio: 1/1; /* force square, prevents oval */\n}\n\n.hide-scrollbar {\n -ms-overflow-style: none; /* IE, Edge */\n scrollbar-width: none; /* Firefox */\n}\n\n.hide-scrollbar::-webkit-scrollbar {\n display: none; /* Chrome, Safari */\n}\n"],"mappings":";AAAA,CAAC;AACC,SAAO;AACP,UAAQ;AACR,eAAa;AACb,iBAAe;AACf,oBAAkB;AAClB,SAAO;AACP,UAAQ,IAAI,MAAM;AAClB,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,cAAY,iBAAiB,MAAM;AACnC,WAAS;AACT,UAAQ;AACV;AAEA,CAhBC,YAgBY;AACX,oBAAkB;AACpB;AAEA,CApBC,aAoBa,CAAC;AACb,SAAO;AACP,UAAQ;AACV;AAEA,CAAC;AACC,SAAO;AACP,UAAQ;AACR,iBAAe;AACf,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,WAAS;AACT,gBAAc,CAAC,CAAC;AAClB;AAEA,CAAC;AACC,sBAAoB;AACpB,mBAAiB;AACnB;AAEA,CALC,cAKc;AACb,WAAS;AACX;","names":[]}
|