@swopstar/react-ui 0.2606.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 +100 -0
- package/dist/index.cjs +194 -0
- package/dist/index.d.ts +734 -0
- package/dist/index.js +29532 -0
- package/dist/style.css +4 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<div align="center"><img src="logo.svg" alt="" width="64" height="64"></div>
|
|
2
|
+
<h1 align="center">swop* react ui</h1>
|
|
3
|
+
|
|
4
|
+
Shared React component library for swop\* projects. Built on [shadcn/ui](https://ui.shadcn.com) (new-york style) and Tailwind v4, with a runtime theme system that generates a full colour palette from a single seed colour.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @swopstar/react-ui
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Requires a `.npmrc` pointing the `@swopstar` scope at GitHub Packages:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
@swopstar:registry=https://npm.pkg.github.com
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import the stylesheet once at your app root:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import '@swopstar/react-ui/style.css'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Wrap your app in `ThemeProvider` with your brand seed colour:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ThemeProvider } from '@swopstar/react-ui'
|
|
30
|
+
|
|
31
|
+
export default function App() {
|
|
32
|
+
return (
|
|
33
|
+
<ThemeProvider seedColor="#DE00EE" mode="auto">
|
|
34
|
+
{/* your app */}
|
|
35
|
+
</ThemeProvider>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Default | Description |
|
|
41
|
+
|------|------|---------|-------------|
|
|
42
|
+
| `seedColor` | `string` | — | Any CSS colour; drives the entire palette |
|
|
43
|
+
| `mode` | `'light' \| 'dark' \| 'auto'` | `'auto'` | `auto` follows `prefers-color-scheme` |
|
|
44
|
+
| `radius` | `number` | `0.875` | Base border radius in rem |
|
|
45
|
+
| `tokens` | `Partial<ThemeTokens>` | — | Per-token overrides applied after generation |
|
|
46
|
+
|
|
47
|
+
### Brand seeds
|
|
48
|
+
|
|
49
|
+
| Project | Seed |
|
|
50
|
+
|---------|------|
|
|
51
|
+
| Master | `#607D8B` |
|
|
52
|
+
| Swopcart | `#EE5300` |
|
|
53
|
+
| Swoptape | `#DE00EE` |
|
|
54
|
+
|
|
55
|
+
### Reading the active theme
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useTheme } from '@swopstar/react-ui'
|
|
59
|
+
|
|
60
|
+
const { isDark, activeTokens, seedColor } = useTheme()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Generating tokens without a provider
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { generateTheme, tokensToVars } from '@swopstar/react-ui'
|
|
67
|
+
|
|
68
|
+
const { light, dark } = generateTheme('#EE5300')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Components
|
|
72
|
+
|
|
73
|
+
`Button` · `Input` · `Card` · `Badge` · `Checkbox` · `Label` · `Separator` · `Select` · `Dialog` · `Popover` · `Tooltip` · `DropdownMenu` · `Tabs`
|
|
74
|
+
|
|
75
|
+
Button variants: `default` · `primary` · `destructive` · `positive` · `warning` · `confirm` · `link`
|
|
76
|
+
|
|
77
|
+
## Colour system
|
|
78
|
+
|
|
79
|
+
The palette is neutral-first. Page surfaces carry no chroma; seed colour appears only on intentional interactive chrome (`primary`, `surface`, `edge`, ring, charts). Fixed semantic colours (`destructive`, `positive`, `warning`, `confirm`) are constant across all brands.
|
|
80
|
+
|
|
81
|
+
All filled components use white foreground and meet WCAG 2 AA contrast (4.5:1 minimum).
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run dev # Storybook on :6006
|
|
87
|
+
npm run build # Type-check + build to dist/
|
|
88
|
+
npm run typecheck # Type-check only
|
|
89
|
+
npm run build-storybook
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Storybook's toolbar exposes **Brand** and **Mode** (Light / Dark / System) globals so every component can be previewed across all three seeds in both colour modes.
|
|
93
|
+
|
|
94
|
+
## Adding components
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx shadcn@latest add <component>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
After adding: audit the generated file and align border/outline classes with the existing pattern in `button.tsx`.
|