nish-ui 1.9.0 → 2.0.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 +218 -58
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +71 -0
- package/dist/elements-charts.js +56 -57
- package/dist/elements-data.d.ts +71 -0
- package/dist/elements-data.js +5 -6
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1461 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1686 -667
- package/dist/nish-components.css +4649 -4506
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +243 -4
- package/dist/theme.global.js +356 -89
- package/dist/theme.js +337 -67
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# nish-ui
|
|
2
2
|
|
|
3
3
|
Design tokens, seven themes, flash-free theme switching and accessible React 19 components,
|
|
4
|
-
built for Tailwind 4 and usable from plain CSS and static HTML.
|
|
5
|
-
|
|
4
|
+
built for Tailwind 4 and usable from plain CSS and static HTML. Works in Vite, Next.js (App
|
|
5
|
+
Router and server components), plain HTML and anything that renders React 19.
|
|
6
6
|
|
|
7
7
|
**See every component and token live, in every theme: [design.nish.software](https://design.nish.software)**
|
|
8
8
|
|
|
@@ -13,32 +13,23 @@ behind every `*.nish.software` app.
|
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
npm install nish-ui
|
|
16
|
+
npm install -D tailwindcss @tailwindcss/vite # for the React + Tailwind path (Next.js: @tailwindcss/postcss)
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
- **ESM only.** Node 20.19 or later. `import` works everywhere; `require('nish-ui')` works on
|
|
20
|
+
Node 20.19+ and 22.12+ (they load ES modules from `require`).
|
|
21
|
+
- **React 19** (and react-dom) are optional peers, so a static site or a Node tool that only
|
|
22
|
+
uses the CSS and `nish-ui/theme` never gets React. Tailwind 4 is needed only for
|
|
23
|
+
`nish-ui/tailwind.css`.
|
|
24
|
+
- The package ships built files: no install or build step. Types are bundled.
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install @nish/ui@npm:nish-ui
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The nish.software apps pin that alias to an exact version,
|
|
30
|
-
`"@nish/ui": "npm:nish-ui@X.Y.Z"`. The release fan-out keeps the pin current, so the version is
|
|
31
|
-
never written by hand.
|
|
32
|
-
|
|
33
|
-
### Fallback: without the npm registry
|
|
34
|
-
|
|
35
|
-
Every release tag carries the same built files, so a machine that cannot reach npm can pin the
|
|
36
|
-
tag's tarball, which needs only HTTPS:
|
|
37
|
-
`"@nish/ui": "https://codeload.github.com/nishant/ui/tar.gz/refs/tags/vX.Y.Z"`.
|
|
26
|
+
Browser support: the latest two versions of Chrome, Edge, Firefox and Safari (Safari 16.4 or
|
|
27
|
+
later). The CSS needs `color-mix()`, `:has()`, the `inert` attribute and container queries.
|
|
28
|
+
Older browsers get no polyfills.
|
|
38
29
|
|
|
39
30
|
## Usage
|
|
40
31
|
|
|
41
|
-
### React + Tailwind 4
|
|
32
|
+
### React + Tailwind 4 (Vite)
|
|
42
33
|
|
|
43
34
|
```css
|
|
44
35
|
/* src/index.css */
|
|
@@ -66,6 +57,67 @@ Style with color roles, never raw palette classes: `bg-th-surface text-th-hi bor
|
|
|
66
57
|
They change with the theme. [Getting started](https://design.nish.software/#/getting-started)
|
|
67
58
|
covers the full setup, Electron included.
|
|
68
59
|
|
|
60
|
+
`nish-ui/tailwind.css` scans the package's own components for class names. An app that wants
|
|
61
|
+
Tailwind to scan only the modules it uses imports `nish-ui/tailwind-core.css` (same theme, no
|
|
62
|
+
`@source` line) and adds its own `@source` lines for `node_modules/nish-ui/dist/esm/components/<module>.js`.
|
|
63
|
+
|
|
64
|
+
### Next.js (App Router)
|
|
65
|
+
|
|
66
|
+
Every component module that uses state, effects or browser APIs starts with `"use client"`,
|
|
67
|
+
so you import components straight into a server component. `cn`, `buttonClass`, `Card`,
|
|
68
|
+
`Badge` and the other pure helpers also work there.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// app/layout.tsx
|
|
72
|
+
import 'nish-ui/tailwind.css'; // after @import 'tailwindcss' in your global CSS, or import both there
|
|
73
|
+
import { NishProvider, Toaster } from 'nish-ui';
|
|
74
|
+
|
|
75
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
76
|
+
return (
|
|
77
|
+
// suppressHydrationWarning: theme-init.js sets data-theme on <html> before React hydrates
|
|
78
|
+
<html lang="en" suppressHydrationWarning>
|
|
79
|
+
<head>
|
|
80
|
+
<script src="/theme-init.js" /> {/* copy node_modules/nish-ui/dist/theme-init.js to public/ */}
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<NishProvider>
|
|
84
|
+
{children}
|
|
85
|
+
<Toaster />
|
|
86
|
+
</NishProvider>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
// app/page.tsx: a server component
|
|
95
|
+
import { Button, Card, cn } from 'nish-ui';
|
|
96
|
+
|
|
97
|
+
export default function Page() {
|
|
98
|
+
return (
|
|
99
|
+
<Card className={cn('m-4')}>
|
|
100
|
+
<Button variant="primary">Server-rendered button</Button>
|
|
101
|
+
</Card>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Plain Tailwind in Next.js is `@import 'tailwindcss'; @import 'nish-ui/tailwind.css';` in
|
|
107
|
+
`app/globals.css` with `@tailwindcss/postcss`. Instead of `<script src>` you can inline the file's
|
|
108
|
+
contents with `dangerouslySetInnerHTML`; see Content Security Policy below for the hash.
|
|
109
|
+
|
|
110
|
+
### Server rendering
|
|
111
|
+
|
|
112
|
+
- Every export renders under `renderToString` in Node without touching `window` or `document`,
|
|
113
|
+
and the first client render equals the server render, so hydration does not warn.
|
|
114
|
+
- Overlays (Modal, Drawer, ConfirmDialog, Popover) render nothing on the server and portal into
|
|
115
|
+
`document.body` (or `<NishProvider portalContainer>`) after hydration.
|
|
116
|
+
- Put `suppressHydrationWarning` on `<html>`: `theme-init.js` writes `data-theme`,
|
|
117
|
+
`data-scheme` and `style="color-scheme"` before React runs.
|
|
118
|
+
- Theme state, the overlay stack and the toast store live on `globalThis`, so every entry
|
|
119
|
+
(`nish-ui`, `nish-ui/theme`, `nish-ui/chart`) and every copy of the package on a page share one.
|
|
120
|
+
|
|
69
121
|
### Plain CSS and static HTML
|
|
70
122
|
|
|
71
123
|
Copy the files listed in `dist/files.json` (CSS, `theme-init.js`, `theme.js` and the fonts),
|
|
@@ -91,8 +143,10 @@ then:
|
|
|
91
143
|
.panel { background: var(--nish-surface); color: var(--nish-hi2); }
|
|
92
144
|
```
|
|
93
145
|
|
|
94
|
-
|
|
95
|
-
|
|
146
|
+
The plain CSS is in cascade layers (`nish.base`, `nish.components`), so your own unlayered rules
|
|
147
|
+
win without specificity fights. `nish.min.css` and `nish-components.min.css` are the minified
|
|
148
|
+
copies. A classic-script build (`theme.global.js`, `window.nishTheme`) covers pages that cannot
|
|
149
|
+
use modules. See [Static sites](https://design.nish.software/#/static-sites).
|
|
96
150
|
|
|
97
151
|
### Without React
|
|
98
152
|
|
|
@@ -102,18 +156,18 @@ elements for pages that have no React: `<nish-theme-toggle>`, `<nish-sheet>`,
|
|
|
102
156
|
and Claude artifacts. They use the same `nish-*` classes as above, so link the stylesheets too.
|
|
103
157
|
|
|
104
158
|
```html
|
|
105
|
-
<script src="https://cdn.jsdelivr.net/npm/nish-ui@
|
|
106
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@
|
|
107
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@
|
|
108
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/nish-ui@
|
|
159
|
+
<script src="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/theme-init.js"></script>
|
|
160
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/nish.css">
|
|
161
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/nish-components.css">
|
|
162
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/elements.js"></script>
|
|
109
163
|
|
|
110
164
|
<nish-theme-toggle pill></nish-theme-toggle>
|
|
111
165
|
```
|
|
112
166
|
|
|
113
167
|
With a bundler: `import 'nish-ui/elements';` and `import { toast } from 'nish-ui/elements';`.
|
|
168
|
+
Pin an exact version (`nish-ui@2.0.0`) in production.
|
|
114
169
|
|
|
115
|
-
Each entry file is self-contained
|
|
116
|
-
tags the page uses:
|
|
170
|
+
Each entry file is self-contained, so load only the ones whose tags the page uses:
|
|
117
171
|
|
|
118
172
|
- `elements.js` (`nish-ui/elements`): `<nish-theme-toggle>`, `<nish-sheet>`, `<nish-dialog>`,
|
|
119
173
|
`<nish-bottom-nav>` and `toast()`.
|
|
@@ -124,8 +178,11 @@ tags the page uses:
|
|
|
124
178
|
`<nish-split>`, `<nish-nav-rail>`, `<nish-scroll-row>`, `<nish-section-nav>` and
|
|
125
179
|
`<nish-command-palette>`.
|
|
126
180
|
- `elements-charts.js` (`nish-ui/elements/charts`): `<nish-line-chart>` and `<nish-bar-chart>`.
|
|
181
|
+
- `elements-all.js` (`nish-ui/elements/all`): all four in one file with one copy of Lit, for a
|
|
182
|
+
page that uses elements from several of them.
|
|
127
183
|
|
|
128
|
-
|
|
184
|
+
Words the elements print come from `configureStrings({ ... })`, exported by every entry.
|
|
185
|
+
Most component pages on the docs site have an HTML tab with the markup, running live. More in
|
|
129
186
|
[Static sites](https://design.nish.software/#/static-sites).
|
|
130
187
|
|
|
131
188
|
## Theming
|
|
@@ -136,65 +193,168 @@ the one it is based on.
|
|
|
136
193
|
|
|
137
194
|
- **Before first paint.** `theme-init.js` puts the saved theme on `<html>` before anything
|
|
138
195
|
renders, then the page follows the OS when the choice is `system`.
|
|
139
|
-
- **Across subdomains.** The choice is saved to `localStorage` and, on
|
|
140
|
-
|
|
141
|
-
|
|
196
|
+
- **Across subdomains.** The choice is saved to `localStorage` and, on the domain named by
|
|
197
|
+
`<html data-nish-domain="example.com">`, to a cookie on that domain, so picking Mocha on one
|
|
198
|
+
app opens its sibling apps in Mocha too. `data-nish-storage-key="x"` renames the key.
|
|
142
199
|
- **Scoped.** `<div data-theme="light" data-scheme="light">` themes one subtree.
|
|
143
200
|
- **Your own themes.** `registerThemes({ rose: 'dark' })` plus `[data-theme='rose']` CSS.
|
|
144
201
|
- **Canvas and charts.** `readToken('chart-1')` and `onThemeChange()`, or `nish-ui/chart`.
|
|
202
|
+
- **Tokens as data.** `nish-ui/tokens`, `nish-ui/tokens.json` and the W3C Design Tokens file
|
|
203
|
+
`nish-ui/tokens.dtcg.json`.
|
|
145
204
|
|
|
146
205
|
Every role and its value in each theme: [Color](https://design.nish.software/#/color) and
|
|
147
|
-
[Themes](https://design.nish.software/#/themes).
|
|
206
|
+
[Themes](https://design.nish.software/#/themes). Every theme function:
|
|
207
|
+
[Theming API](https://design.nish.software/#/theming-api).
|
|
208
|
+
|
|
209
|
+
## Content Security Policy
|
|
210
|
+
|
|
211
|
+
`theme-init.js` is the only inline script the package asks for. Allow it with a hash, or with a
|
|
212
|
+
nonce:
|
|
213
|
+
|
|
214
|
+
- Hash: `nish-ui/theme-init.sha256` holds `sha256-...` for the shipped `theme-init.js`. Put it
|
|
215
|
+
in `script-src 'sha256-...'` when you inline the file exactly as shipped. The hash is also in
|
|
216
|
+
`dist/files.json` as `themeInitHash`.
|
|
217
|
+
`theme-init.sha256` covers only the file as shipped. The Vite plugin changes the script (comments
|
|
218
|
+
removed, optional prelude and legacyKey code), so for Vite use the plugin's `hash` property
|
|
219
|
+
(`nishThemeInit().hash`) instead.
|
|
220
|
+
- Nonce: `nishThemeInit({ nonce: '__NISH_CSP_NONCE__' })` in `nish-ui/vite` writes that placeholder
|
|
221
|
+
into the injected tag at build time; have your server replace it with a fresh random value on every
|
|
222
|
+
response. Vite runs the transform once per build, so a fixed real nonce (or a function) is baked into
|
|
223
|
+
the file and gives no protection outside the dev server. In other setups give your own
|
|
224
|
+
`<script nonce>` the file's contents.
|
|
225
|
+
- The components set no inline styles that need `style-src 'unsafe-inline'` beyond CSS custom
|
|
226
|
+
properties on elements, and build their DOM without `innerHTML`, so a Trusted Types policy
|
|
227
|
+
(`require-trusted-types-for 'script'`) passes.
|
|
228
|
+
- Fonts are served from the package (`nish-ui/fonts/*`), and Favicon makes no third-party
|
|
229
|
+
request unless you configure one.
|
|
230
|
+
|
|
231
|
+
## Languages and right-to-left
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
import { NishProvider } from 'nish-ui';
|
|
235
|
+
|
|
236
|
+
<NishProvider locale="de-DE" dir="ltr" strings={{ close: 'Schließen', cancel: 'Abbrechen', search: 'Suchen' }}>
|
|
237
|
+
<App />
|
|
238
|
+
</NishProvider>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- `strings` replaces any of the English defaults (`DEFAULT_STRINGS` lists every key with the
|
|
242
|
+
components that use it); a prop on one component still wins. Providers nest.
|
|
243
|
+
- `locale` feeds `RelativeTime` and chart axes. `setDefaultLocale('de-DE')` from `nish-ui/format`
|
|
244
|
+
sets it for the formatters outside React (default `en-US`, so output is unchanged until you ask).
|
|
245
|
+
- Layout uses logical properties and arrow keys mirror when the element's computed `direction`
|
|
246
|
+
is `rtl`. Set `dir="rtl"` on `<html>` (or any ancestor) and everything follows.
|
|
247
|
+
|
|
248
|
+
## Testing your app
|
|
249
|
+
|
|
250
|
+
- **Vitest** (recommended): works as is. Use the `happy-dom` or `jsdom` environment.
|
|
251
|
+
- **Jest** does not load ES modules from `node_modules` by default. Either run it with
|
|
252
|
+
`--experimental-vm-modules`, or add `transformIgnorePatterns: ['/node_modules/(?!nish-ui)']`
|
|
253
|
+
with a transform for `.js` files (babel-jest or `@swc/jest`).
|
|
254
|
+
- No setup is needed for `matchMedia`, `ResizeObserver` or storage; the components guard their use.
|
|
255
|
+
- Overlays portal to `document.body`; query with `screen`, not `container`.
|
|
148
256
|
|
|
149
257
|
## What's in it
|
|
150
258
|
|
|
151
|
-
More than
|
|
259
|
+
More than 100 components, each with live stories, props and guidelines on the
|
|
152
260
|
[docs site](https://design.nish.software/#/components):
|
|
153
261
|
|
|
154
262
|
- **Actions and inputs:** Button, IconButton, Input, Textarea, Select, Combobox, Checkbox,
|
|
155
|
-
Switch, Segmented, Chip, SearchInput,
|
|
156
|
-
|
|
157
|
-
- **
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
263
|
+
Switch, RadioGroup, Slider, TagInput, FileDropzone, NumberField, Segmented, Chip, SearchInput,
|
|
264
|
+
Field, FieldGroup, Label
|
|
265
|
+
- **Feedback:** Toast, Callout, Spinner, Skeleton, Progress, EmptyState, ErrorState, StatusDot,
|
|
266
|
+
Meter, LoadingBar, ConnectionBanner, AppErrorBoundary
|
|
267
|
+
- **Overlays:** Modal, Drawer, ConfirmDialog, Popover, DropdownMenu, Tooltip, CommandPalette,
|
|
268
|
+
Portal
|
|
269
|
+
- **Settings:** SettingsSection, SettingRow, ServiceTokensSection (list and revoke service
|
|
270
|
+
tokens)
|
|
271
|
+
- **Layout and navigation:** AppShell (bottom bar, rail and a collapsible sidebar), AppHeader,
|
|
272
|
+
BottomNav, NavRail, MoreSheet, SectionNav, Tabs, Pagination, Breadcrumbs, Accordion,
|
|
273
|
+
Disclosure, PageHeader, PageContainer, SectionHeader, Card, Separator, StickyBar,
|
|
274
|
+
StickyActionBar, ScrollRow
|
|
275
|
+
- **Data and display:** Table, ResponsiveTable, FilterBar, Stat, Badge, Avatar, AvatarGroup,
|
|
276
|
+
Kbd, KeyValueList, ListRow, LinkCard, Favicon, RelativeTime, CopyButton, LineChart, BarChart,
|
|
277
|
+
Sparkline, ChartLegend, RangeBar, MediaRow, ActivityFeed, Inbox, VisuallyHidden
|
|
278
|
+
- **Flow and canvas:** SplitStage, WorkflowBoard, StepBar, FlowSteps, AgentNode, AnimatedList,
|
|
279
|
+
TickerText, SystemCanvas
|
|
280
|
+
- **Runtime:** NishProvider (strings, locale, direction, portal container), hooks such as
|
|
281
|
+
`useMediaQuery`, `useLocalStorage`, `useUrlState` and `useResource`
|
|
164
282
|
|
|
165
283
|
Entry points:
|
|
166
284
|
|
|
167
285
|
| Import | What |
|
|
168
286
|
|---|---|
|
|
169
287
|
| `nish-ui` | React components, hooks, theme functions |
|
|
170
|
-
| `nish-ui/tailwind.css` | Tailwind 4 theme
|
|
171
|
-
| `nish-ui/
|
|
172
|
-
| `nish-ui/
|
|
173
|
-
| `nish-ui/
|
|
288
|
+
| `nish-ui/tailwind.css` | Tailwind 4 theme, base styles, component scan |
|
|
289
|
+
| `nish-ui/tailwind-core.css` | The same without the component scan |
|
|
290
|
+
| `nish-ui/nish.css` | The theme and base styles without Tailwind |
|
|
291
|
+
| `nish-ui/nish-components.css` | `.nish-btn`, `.nish-card` and the other classes |
|
|
292
|
+
| `nish-ui/theme` | Theme switching and static-page helpers, React-free |
|
|
293
|
+
| `nish-ui/format` | Money, percent, date formatters (locale-aware) |
|
|
174
294
|
| `nish-ui/chart` | Chart colors for any library |
|
|
295
|
+
| `nish-ui/tokens` | Token data for Node and build tools |
|
|
296
|
+
| `nish-ui/tokens.json` | The same as JSON, and `tokens.dtcg.json` for design tools |
|
|
297
|
+
| `nish-ui/system-canvas` | The node-and-edge canvas component |
|
|
298
|
+
| `nish-ui/split-layout` | Split-pane layout math, React-free |
|
|
299
|
+
| `nish-ui/elements` | Custom elements; also `/forms`, `/data`, `/charts`, `/all` |
|
|
175
300
|
| `nish-ui/vite` | The theme-init Vite plugin |
|
|
176
301
|
| `nish-ui/eslint` | Lint rules for theme classes |
|
|
177
302
|
|
|
178
|
-
Also `nish-ui/
|
|
179
|
-
`nish-
|
|
180
|
-
|
|
303
|
+
Also `nish-ui/theme-init.js` and `theme-init.sha256`, `nish-ui/theme.global.js`,
|
|
304
|
+
`nish-ui/fonts/*`, `nish-ui/tsconfig/*` (strict presets), the `nish-th-check` CLI, and
|
|
305
|
+
`nish-ui/server`, `nish-ui/server/hono` and `nish-ui/inbox-client` (a login, session and inbox
|
|
306
|
+
kit for Hono servers; other projects can ignore it).
|
|
181
307
|
Details: [Vite plugin and lint](https://design.nish.software/#/components/vite-plugin).
|
|
182
308
|
|
|
309
|
+
## Bundle size
|
|
310
|
+
|
|
311
|
+
Measured with esbuild (minified, React external) from `dist/esm` on every pull request by
|
|
312
|
+
`npm run size`, which fails the build when a budget is passed:
|
|
313
|
+
|
|
314
|
+
| Import | Gzip |
|
|
315
|
+
|---|---|
|
|
316
|
+
| `cn` | under 10 KB |
|
|
317
|
+
| `Button` | under 11 KB |
|
|
318
|
+
| `useMediaQuery` | under 1.5 KB |
|
|
319
|
+
| `nish-ui/theme` | under 12 KB |
|
|
320
|
+
| `nish-ui/format` | under 4 KB |
|
|
321
|
+
|
|
322
|
+
The JavaScript is one file per source module with `/* @__PURE__ */` annotations and a
|
|
323
|
+
`sideEffects` list, so an import costs what it uses. The budgets are in
|
|
324
|
+
`tools/size-budgets.json`; the whole package is checked against a 2.5 MB tarball limit.
|
|
325
|
+
|
|
183
326
|
## Accessibility
|
|
184
327
|
|
|
185
|
-
- Every theme passes WCAG contrast (4.5:1 text, 3:1 graphics
|
|
186
|
-
matrix on [Themes](https://design.nish.software/#/themes).
|
|
328
|
+
- Every theme passes WCAG contrast (4.5:1 text, 3:1 graphics and form-control borders), checked
|
|
329
|
+
in CI and shown as a matrix on [Themes](https://design.nish.software/#/themes).
|
|
187
330
|
- Controls grow to 44px tap targets on touch screens and stay compact under a mouse.
|
|
188
|
-
- Visible focus rings, focus traps in dialogs, live regions for toasts
|
|
189
|
-
respected everywhere.
|
|
190
|
-
-
|
|
331
|
+
- Visible focus rings, focus traps in dialogs, live regions for toasts and loading states,
|
|
332
|
+
forced-colors (Windows High Contrast) rules and reduced motion respected everywhere.
|
|
333
|
+
- Tooltip follows WCAG 1.4.13: it opens on focus and hover, closes with Escape and can be
|
|
334
|
+
hovered, with no extra Tab stop.
|
|
335
|
+
|
|
336
|
+
## What CI checks
|
|
337
|
+
|
|
338
|
+
Every pull request runs: typecheck, lint, the WCAG contrast check over every theme, the unit
|
|
339
|
+
tests (Vitest, in a DOM and in plain Node with no DOM, including server rendering of every
|
|
340
|
+
export and two copies of the package on one page), Playwright specs for overlays, custom
|
|
341
|
+
elements, hydration, Content Security Policy and Trusted Types, an axe accessibility scan with
|
|
342
|
+
zero serious or critical findings, a consumer build in Next.js (App Router), Vite and a
|
|
343
|
+
TypeScript matrix (5.4, 5.9 and 6.0 with `bundler` and `node16` resolution), the bundle size
|
|
344
|
+
budgets, a screenshot check of the docs site at 360, 840 and 1440 px in light and dark, and an
|
|
345
|
+
exports snapshot that fails when a public name or `.nish-*` class disappears. Releases publish to
|
|
346
|
+
npm with provenance. The docs site is checked at 360, 840 and 1440 px; not every component is
|
|
347
|
+
checked in every theme on every pull request.
|
|
191
348
|
|
|
192
349
|
## Links
|
|
193
350
|
|
|
194
351
|
- Docs and live components: [design.nish.software](https://design.nish.software)
|
|
195
352
|
- Changelog: [CHANGELOG.md](https://github.com/nishant/ui/blob/master/CHANGELOG.md)
|
|
196
|
-
-
|
|
353
|
+
- Moving from 1.x: [docs/MIGRATING-2.0.md](https://github.com/nishant/ui/blob/master/docs/MIGRATING-2.0.md)
|
|
354
|
+
- Contributing: [CONTRIBUTING.md](https://github.com/nishant/ui/blob/master/CONTRIBUTING.md)
|
|
355
|
+
- Security: [SECURITY.md](https://github.com/nishant/ui/blob/master/SECURITY.md)
|
|
197
356
|
- Working on this repo: [docs/DEVELOPING.md](https://github.com/nishant/ui/blob/master/docs/DEVELOPING.md)
|
|
357
|
+
- Releasing: [docs/RELEASING.md](https://github.com/nishant/ui/blob/master/docs/RELEASING.md)
|
|
198
358
|
- Troubleshooting and versioning: [Getting started](https://design.nish.software/#/getting-started)
|
|
199
359
|
- Issues: [github.com/nishant/ui/issues](https://github.com/nishant/ui/issues)
|
|
200
360
|
|