@dgithiomi/sbui-web 1.0.0 → 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.
package/README.md ADDED
@@ -0,0 +1,320 @@
1
+ # Uniicy UI — Component Library
2
+
3
+ A **React** component library and **interactive playground** for building, previewing, and stress-testing UI used in the Uniicy sports-betting experience. The repo is a **Bun + Turborepo** monorepo: design tokens and shared utilities live in `packages/`, publishable web components live in `components/web`, and the playground in `apps/playground` is the live workbench for developers and QA.
4
+
5
+ ![Uniicy component playground — overview screen](../../docs/images/playground.png)
6
+
7
+ ---
8
+
9
+ ## What’s in this repo
10
+
11
+ | Area | Path | Role |
12
+ | ------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
13
+ | **Web components** | [`components/web`](./components/web) | Atomic React components (`TextArea`, `Tooltip`, …), built with **tsup**, shipped as **`@dgithiomi/sbui-web`** |
14
+ | **Playground** | [`apps/playground`](./apps/playground) | Vite app to browse variants, API tables, and theme modes |
15
+ | **Design tokens** | [`packages/assets`](./packages/assets) | Color primitives, themes (light/dark), shared token source |
16
+ | **Icons** | [`packages/icons`](./packages/icons) | Shared SVG icon components (`@uniicy/icons`) |
17
+ | **Utilities** | [`packages/libs`](./packages/libs) | Shared helpers (e.g. `cn()` via `classnames` + `tailwind-merge`) |
18
+ | **Core** | [`packages/core`](./packages/core) | Shared hooks and utilities for apps in the monorepo |
19
+ | **Consumer docs** | [`docs/consumer-integration-guide.md`](./docs/consumer-integration-guide.md) | Full guide for teams integrating the library in React or Next.js |
20
+
21
+ ---
22
+
23
+ ## Features
24
+
25
+ - **Atomic design** — Components organized as atoms (molecules/organisms planned as the library grows).
26
+ - **Token-driven theming** — Colors from `@uniicy/assets` become CSS variables and Tailwind utilities (`text-fg`, `bg-surface`, `border-outline`, …).
27
+ - **Light & dark** — Theme variables follow `prefers-color-scheme` and a `.dark` class for manual toggling.
28
+ - **Shipped stylesheet** — One import (`@dgithiomi/sbui-web/styles.css`) gives consumers tokens, Tailwind utilities, and component CSS (e.g. tooltip animations).
29
+ - **TypeScript-first** — Props documented in `.types.ts` files; declarations published in `dist/`.
30
+ - **Interactive playground** — Sidebar navigation, variant sections, props tables, and status badges for each component.
31
+
32
+ ---
33
+
34
+ ## Repository structure
35
+
36
+ ```
37
+ sb-component-library/
38
+ ├── apps/
39
+ │ └── playground/ # Vite + React docs / demo app
40
+ ├── components/
41
+ │ └── web/ # @dgithiomi/sbui-web — publishable component library
42
+ │ ├── src/atoms/ # TextArea, Tooltip, …
43
+ │ ├── scripts/ # build-styles.ts (Tailwind → dist/styles.css)
44
+ │ └── dist/ # Built JS + styles.css (after build)
45
+ ├── packages/
46
+ │ ├── assets/ # Design tokens (colors, themes)
47
+ │ ├── icons/ # @uniicy/icons
48
+ │ ├── libs/ # @uniicy/libs (cn, etc.)
49
+ │ └── core/ # Shared hooks
50
+ ├── docs/
51
+ │ ├── consumer-integration-guide.md
52
+ │ └── images/ # README & doc assets
53
+ ├── turbo.json
54
+ └── package.json
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Components (web)
60
+
61
+ | Component | Status | Description |
62
+ | ------------ | ------ | --------------------------------------------------------------------------------------------- |
63
+ | **TextArea** | Stable | Controlled multi-line input with status, character count, clear, addons, and optional tooltip |
64
+ | **Tooltip** | Stable | Accessible overlay with placement, triggers, variants, and animations |
65
+
66
+ More atoms will appear in the playground sidebar as they are added.
67
+
68
+ ---
69
+
70
+ ## Prerequisites
71
+
72
+ - **[Bun](https://bun.sh)** `1.3+` (package manager for this monorepo — use `bun install`, not `npm install`, because of `workspace:*` dependencies)
73
+ - **Node.js** 20+ (for tooling compatibility)
74
+
75
+ ---
76
+
77
+ ## Getting started (contributors & testers)
78
+
79
+ ### 1. Clone and install
80
+
81
+ ```bash
82
+ git clone https://github.com/githiomi/sb-ui.git
83
+ cd sb-component-library # or your local folder name
84
+ bun install
85
+ ```
86
+
87
+ ### 2. Run the playground and library in dev mode
88
+
89
+ From the **repository root**:
90
+
91
+ ```bash
92
+ bun run dev
93
+ ```
94
+
95
+ This uses **Turborepo** to:
96
+
97
+ 1. Build workspace dependencies (`@dgithiomi/sbui-web`, icons, etc.)
98
+ 2. Start **`@dgithiomi/sbui-web`** in watch mode (`tsup --watch`)
99
+ 3. Start the **playground** Vite dev server
100
+
101
+ Open the URL Vite prints (typically `http://localhost:5173`). Use the sidebar to open **TextArea** (and other components as they are added), try variants, and read the API reference at the bottom of each page.
102
+
103
+ ### 3. Build everything
104
+
105
+ ```bash
106
+ bun run build
107
+ ```
108
+
109
+ ### 4. Build only the component library
110
+
111
+ ```bash
112
+ cd components/web
113
+ bun run build # JS + types (styles rebuilt via tsup onSuccess)
114
+ bun run build:styles # stylesheet only, when needed
115
+ ```
116
+
117
+ ---
118
+
119
+ ## How the web library is built
120
+
121
+ Understanding this helps when debugging styling or publishing.
122
+
123
+ 1. **JavaScript** — [`components/web/tsup.config.ts`](./components/web/tsup.config.ts) bundles `index.ts` to `dist/index.mjs` / `.cjs` and generates `dist/index.d.ts`.
124
+ 2. **Styles** — [`components/web/scripts/build-styles.ts`](./components/web/scripts/build-styles.ts):
125
+ - Prepends auto-generated **CSS variables** (light/dark) from tokens
126
+ - Processes [`src/styles.css`](./components/web/src/styles.css) with PostCSS (`postcss-import`, Tailwind, Autoprefixer)
127
+ - Inlines per-component CSS (e.g. [`Tooltip.css`](./components/web/src/atoms/Tooltip/Tooltip.css))
128
+ - Writes **`dist/styles.css`**
129
+ 3. **Watch** — `tsup --watch` runs `build-styles` on success so `dist/styles.css` is not left missing after a clean rebuild.
130
+
131
+ **Adding component CSS:** create `src/atoms/<Component>/<Component>.css` and add `@import "./atoms/<Component>/<Component>.css";` in `src/styles.css`.
132
+
133
+ ---
134
+
135
+ ## Using the library in your app (consumers)
136
+
137
+ The published npm package name is **`@dgithiomi/sbui-web`** (configurable before publish). Consumers need:
138
+
139
+ 1. **Install** the package and React peers
140
+ 2. **Import the stylesheet once** at the app root
141
+ 3. **Import components** from `"@dgithiomi/sbui-web"`
142
+ 4. **(Optional)** Add `@dgithiomi/sbui-web/tailwind-preset` if their app uses the same Tailwind tokens
143
+
144
+ ### Quick start
145
+
146
+ ```bash
147
+ bun add @dgithiomi/sbui-web react react-dom
148
+ # or: npm install @dgithiomi/sbui-web react react-dom
149
+ ```
150
+
151
+ ```tsx
152
+ // main.tsx or app/layout.tsx — import once
153
+ import "@dgithiomi/sbui-web/styles.css";
154
+
155
+ // Your component file
156
+ import { TextArea } from "@dgithiomi/sbui-web";
157
+ import { useState } from "react";
158
+
159
+ export function Notes() {
160
+ const [value, setValue] = useState("");
161
+ return (
162
+ <TextArea
163
+ id="notes"
164
+ value={value}
165
+ onChange={setValue}
166
+ placeholder="Add a note…"
167
+ />
168
+ );
169
+ }
170
+ ```
171
+
172
+ **Next.js (App Router):** put interactive usage in a `"use client"` file and import `@dgithiomi/sbui-web/styles.css` in `app/layout.tsx`.
173
+
174
+ For **React + Vite**, **Next.js Pages/App Router**, Tailwind preset setup, dark mode, troubleshooting, and a pre-publish checklist, see:
175
+
176
+ **[docs/consumer-integration-guide.md](./docs/consumer-integration-guide.md)**
177
+
178
+ ---
179
+
180
+ ## Global provider usage (recommended)
181
+
182
+ `SbuiProvider` is the single top-level wrapper for library features that require React context (Toast now, more features later).
183
+
184
+ ### Why `enableToastProvider` exists
185
+
186
+ - `enableToastProvider` is an **optional boolean prop** on `SbuiProvider`.
187
+ - Default is `true`, so Toast context is mounted automatically.
188
+ - You only set `enableToastProvider={false}` for advanced cases (for example:
189
+ tests, custom host-level toast system, or temporarily disabling Toast behavior).
190
+ - In normal consumer apps, you should **not** set it; keep default behavior.
191
+
192
+ ### One-wrapper setup
193
+
194
+ ```tsx
195
+ // main.tsx / app root
196
+ import { SbuiProvider } from "@dgithiomi/sbui-web";
197
+ import "@dgithiomi/sbui-web/styles.css";
198
+
199
+ export function Root() {
200
+ return (
201
+ <SbuiProvider>
202
+ <App />
203
+ </SbuiProvider>
204
+ );
205
+ }
206
+ ```
207
+
208
+ ### Triggering Toast from components
209
+
210
+ ```tsx
211
+ import { useToast } from "@dgithiomi/sbui-web";
212
+
213
+ export function SaveButton() {
214
+ const { showToast } = useToast();
215
+
216
+ return (
217
+ <button
218
+ onClick={() =>
219
+ showToast({
220
+ variant: "success",
221
+ title: "Saved",
222
+ message: "Your changes were saved.",
223
+ duration: "short",
224
+ })
225
+ }
226
+ >
227
+ Save
228
+ </button>
229
+ );
230
+ }
231
+ ```
232
+
233
+ If `enableToastProvider={false}`, `useToast()` will throw unless you provide `ToastProvider` yourself.
234
+
235
+ ---
236
+
237
+ ## Package exports (`@dgithiomi/sbui-web`)
238
+
239
+ | Import | Description |
240
+ | ------------------------------------- | ----------------------------------- |
241
+ | `@dgithiomi/sbui-web` | React components + TypeScript types |
242
+ | `@dgithiomi/sbui-web/styles.css` | Global stylesheet (required) |
243
+ | `@dgithiomi/sbui-web/tailwind-preset` | Tailwind v3 preset for host apps |
244
+
245
+ **Peer dependencies:** `react`, `react-dom` (^19). `tailwindcss` (^3.4) is optional if the host app uses the preset.
246
+
247
+ ---
248
+
249
+ ## Playground
250
+
251
+ The playground ([`apps/playground`](./apps/playground)) is **not** published to npm. It exists to:
252
+
253
+ - Preview every variant of each component in isolation
254
+ - Document props via shared tables ([`PropsTable`](./apps/playground/src/layouts/shared/PropsTable.tsx))
255
+ - Validate light/dark theming and design tokens end-to-end
256
+ - Give QA a stable URL to regression-test UI before release
257
+
258
+ To run only the playground (after a root install and build):
259
+
260
+ ```bash
261
+ cd apps/playground
262
+ bun run dev
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Theming & tokens
268
+
269
+ - **Source of truth:** [`packages/assets/colors.ts`](./packages/assets/colors.ts)
270
+ - **Tailwind mapping:** [`components/web/tailwind-theme.ts`](./components/web/tailwind-theme.ts)
271
+ - **Semantic utilities:** `text-fg`, `text-link`, `bg-surface`, `bg-canvas`, `border-outline`, etc.
272
+ - **Primitives:** `primary`, `accent`, `success`, `error`, `warning`, `neutral` (with shades)
273
+
274
+ Prefer semantic classes in components so light/dark switches without changing JSX.
275
+
276
+ ---
277
+
278
+ ## Scripts (root)
279
+
280
+ | Command | Description |
281
+ | --------------- | ---------------------------------------------- |
282
+ | `bun run dev` | Start library watch + playground (Turbo) |
283
+ | `bun run build` | Build all packages and apps |
284
+ | `bun run test` | Placeholder — add tests as the library matures |
285
+
286
+ ---
287
+
288
+ ## Publishing (maintainers)
289
+
290
+ Before publishing `@dgithiomi/sbui-web` to npm:
291
+
292
+ 1. Run `bun run build` in `components/web` and verify `dist/` includes JS, types, and `styles.css`.
293
+ 2. Confirm the package tarball has no `workspace:*` dependencies with `npm pack --dry-run`.
294
+ 3. Publish from `components/web` using `npm publish --access public`.
295
+ 4. Install `@dgithiomi/sbui-web` in a separate React/Next.js app and import `@dgithiomi/sbui-web/styles.css` once.
296
+
297
+ See the **Before publishing** section in [docs/consumer-integration-guide.md](./docs/consumer-integration-guide.md).
298
+
299
+ ---
300
+
301
+ ## Roadmap
302
+
303
+ - Additional atoms, molecules, and organisms
304
+ - Native component package (`components/native`)
305
+ - Storybook or visual regression tests
306
+ - Automated npm publish workflow
307
+
308
+ ---
309
+
310
+ ## License
311
+
312
+ **ISC** — see [package.json](./package.json) for author and repository links.
313
+
314
+ ---
315
+
316
+ ## Links
317
+
318
+ - **Repository:** [github.com/githiomi/sb-ui](https://github.com/githiomi/sb-ui)
319
+ - **Issues:** [github.com/githiomi/sb-ui/issues](https://github.com/githiomi/sb-ui/issues)
320
+ - **Integration guide:** [docs/consumer-integration-guide.md](./docs/consumer-integration-guide.md)
@@ -4,7 +4,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
8
14
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
15
  };
10
16
  var __copyProps = (to, from, except, desc) => {
@@ -25,7 +31,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
31
  ));
26
32
 
27
33
  export {
34
+ __require,
28
35
  __commonJS,
29
36
  __toESM
30
37
  };
31
- //# sourceMappingURL=chunk-3QS3WKRC.mjs.map
38
+ //# sourceMappingURL=chunk-LZOMFHX3.mjs.map