@sniptide/ui 0.5.1 → 0.6.0
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 +92 -45
- package/package.json +4 -5
- package/src/components/popover.tsx +8 -1
- package/src/hooks/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -1,67 +1,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Sniptide UI
|
|
2
2
|
|
|
3
|
-
Sniptide
|
|
4
|
-
|
|
3
|
+
Build Sniptide screens with the same components, theme and logo as the app. `@sniptide/ui` holds
|
|
4
|
+
the shared React components (shadcn on Base UI), the Tailwind CSS v4 theme and the brand `Logo`.
|
|
5
|
+
The app imports it from this monorepo, and the marketing site installs it from npm.
|
|
5
6
|
|
|
6
|
-
The package ships TypeScript source, so the
|
|
7
|
+
The package ships TypeScript and CSS source, so the Next.js app that consumes it compiles it.
|
|
8
|
+
[`DESIGN.md`](../../DESIGN.md) describes the tokens and when to use each component.
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## Install
|
|
9
11
|
|
|
10
|
-
```
|
|
12
|
+
```sh
|
|
11
13
|
bun add @sniptide/ui
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const nextConfig = { transpilePackages: ["@sniptide/ui"] }
|
|
17
|
-
```
|
|
16
|
+
It needs React 19.2 or newer and Next.js. Tailwind CSS, PostCSS, Base UI and `lucide-react` come
|
|
17
|
+
with the package as dependencies.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
// postcss.config.mjs
|
|
21
|
-
export { default } from "@sniptide/ui/postcss.config"
|
|
22
|
-
```
|
|
19
|
+
## Add it to a Next.js app
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
21
|
+
1. Compile the package with your app:
|
|
22
|
+
|
|
23
|
+
```ts title="next.config.ts"
|
|
24
|
+
const nextConfig = { transpilePackages: ["@sniptide/ui"] }
|
|
25
|
+
export default nextConfig
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Use the package's PostCSS configuration, which loads Tailwind:
|
|
29
|
+
|
|
30
|
+
```js title="postcss.config.mjs"
|
|
31
|
+
export { default } from "@sniptide/ui/postcss.config"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. Import the theme once in the root layout, and set the three font variables on `<html>`, for
|
|
35
|
+
example with `next/font`. The theme reads `--font-sans` for Inter, `--font-mono` for Paper Mono
|
|
36
|
+
and `--font-heading` for Archivo.
|
|
37
|
+
|
|
38
|
+
```tsx title="app/layout.tsx"
|
|
39
|
+
import "@sniptide/ui/globals.css"
|
|
40
|
+
import { Toaster } from "@sniptide/ui/components/toast"
|
|
41
|
+
```
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
`--font-sans` (Inter), `--font-mono` (Paper Mono) and `--font-heading` (Archivo).
|
|
33
|
-
The Paper Mono fonts in `src/fonts` come from the
|
|
34
|
-
[v1.000 release](https://github.com/paper-design/paper-mono/releases/tag/v1.000). The included
|
|
35
|
-
`OFL.txt` contains their SIL Open Font License 1.1.
|
|
36
|
-
The logo uses vector outlines and does not need a font.
|
|
43
|
+
4. Import components by path:
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
```tsx
|
|
46
|
+
import { Button } from "@sniptide/ui/components/button"
|
|
47
|
+
import { Logo } from "@sniptide/ui/components/logo"
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
export function Header() {
|
|
50
|
+
return (
|
|
51
|
+
<header>
|
|
52
|
+
<Logo />
|
|
53
|
+
<Button>New paste</Button>
|
|
54
|
+
</header>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
```
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
The header renders the wordmark and a blue button that sits on a darker edge and presses down when
|
|
60
|
+
you click it. If the button has no fill, `globals.css` is not loaded. If the text falls back to a
|
|
61
|
+
system font, the font variables are not set on `<html>`.
|
|
44
62
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
`globals.css` tells Tailwind to scan this package's components, and Tailwind's automatic source
|
|
64
|
+
detection finds your own files. The light and dark themes switch with the `dark` class on `<html>`.
|
|
65
|
+
|
|
66
|
+
## What the package exports
|
|
67
|
+
|
|
68
|
+
| Import path | Contents |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `@sniptide/ui/globals.css` | The palette, the `@theme` tokens and the utilities from `shadcn.css` |
|
|
71
|
+
| `@sniptide/ui/postcss.config` | The PostCSS configuration with the Tailwind plugin |
|
|
72
|
+
| `@sniptide/ui/components/<name>` | One file per component, such as `button`, `dialog`, `dropdown-menu`, `sheet`, `toast` and `logo` |
|
|
73
|
+
| `@sniptide/ui/lib/utils` | `cn`, which joins class names |
|
|
74
|
+
| `@sniptide/ui/lib/confetti` | The confetti burst that plays when someone clicks the logo several times in a row |
|
|
75
|
+
|
|
76
|
+
The components live in [`src/components`](src/components). Each one keeps the shadcn API, so the
|
|
77
|
+
[shadcn documentation](https://ui.shadcn.com/docs/components) applies, with the variants that
|
|
78
|
+
`DESIGN.md` lists.
|
|
79
|
+
|
|
80
|
+
## Show loading, success and errors
|
|
81
|
+
|
|
82
|
+
Every async action ends in one of three states, and these components cover them:
|
|
83
|
+
|
|
84
|
+
- **Loading.** `<Button loading={pending}>` swaps the button's icon for a `Spinner`, ignores clicks
|
|
85
|
+
and sets `aria-busy`. `Skeleton` holds the place of content that is still loading.
|
|
86
|
+
- **Success.** `SuccessCheck` draws a check, which a copy button shows in place of its icon. An
|
|
87
|
+
action without a button of its own, such as a menu item, calls `toast.success(...)`. Mount
|
|
49
88
|
`<Toaster />` once in the root layout.
|
|
50
|
-
- **Error
|
|
51
|
-
`inline` under a field
|
|
89
|
+
- **Error.** `FormError` shows a failure next to what failed. Its `banner` variant, the default,
|
|
90
|
+
sits on top of a form, and `inline` sits under a field. An action with no place for a message
|
|
91
|
+
calls `toast.error(...)`.
|
|
92
|
+
|
|
93
|
+
When the visitor prefers reduced motion, spinners pulse slowly instead of turning, and the check
|
|
94
|
+
and skeletons stop animating.
|
|
95
|
+
|
|
96
|
+
## Fonts and licenses
|
|
52
97
|
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
The Paper Mono files in [`src/fonts`](src/fonts) come from the
|
|
99
|
+
[v1.000 release](https://github.com/paper-design/paper-mono/releases/tag/v1.000) under the SIL Open
|
|
100
|
+
Font License 1.1 in `OFL.txt`. The logo is drawn as vector paths and needs no font.
|
|
55
101
|
|
|
56
|
-
##
|
|
102
|
+
## Release a new version
|
|
57
103
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
isolated consumer, then publishes through npm Trusted Publishing with
|
|
104
|
+
A merge to `main` releases the package after CI passes, but only when its packed contents changed.
|
|
105
|
+
The Conventional Commit types since the last release choose the version bump. The workflow installs
|
|
106
|
+
the packed package in an isolated consumer, then publishes it through npm Trusted Publishing with
|
|
107
|
+
provenance.
|
|
61
108
|
|
|
62
|
-
The
|
|
63
|
-
|
|
64
|
-
|
|
109
|
+
The version in `package.json` is a development default, and npm records the released version, so
|
|
110
|
+
don't bump it by hand. [Automatic npm releases](../../docs/npm-publishing.md) covers the one-time
|
|
111
|
+
owner setup and how to retry a failed release.
|
|
65
112
|
|
|
66
113
|
## License
|
|
67
114
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sniptide/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"gitHead": "
|
|
5
|
-
"description": "Sniptide's
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"gitHead": "6f7f163b4b23e3bedbe77bf81baf08c551bdb6c4",
|
|
5
|
+
"description": "Sniptide's React components, Tailwind CSS theme and logo, shared by the app and the website.",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"homepage": "https://sniptide.com",
|
|
8
8
|
"type": "module",
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"./globals.css": "./src/styles/globals.css",
|
|
20
20
|
"./postcss.config": "./postcss.config.mjs",
|
|
21
21
|
"./lib/*": "./src/lib/*.ts",
|
|
22
|
-
"./components/*": "./src/components/*.tsx"
|
|
23
|
-
"./hooks/*": "./src/hooks/*.ts"
|
|
22
|
+
"./components/*": "./src/components/*.tsx"
|
|
24
23
|
},
|
|
25
24
|
"files": [
|
|
26
25
|
"src",
|
|
@@ -13,9 +13,14 @@ function PopoverContent({
|
|
|
13
13
|
align = "start",
|
|
14
14
|
side,
|
|
15
15
|
sideOffset = 6,
|
|
16
|
+
anchor,
|
|
17
|
+
collisionPadding,
|
|
16
18
|
...props
|
|
17
19
|
}: PopoverPrimitive.Popup.Props &
|
|
18
|
-
Pick<
|
|
20
|
+
Pick<
|
|
21
|
+
PopoverPrimitive.Positioner.Props,
|
|
22
|
+
"align" | "side" | "sideOffset" | "anchor" | "collisionPadding"
|
|
23
|
+
>) {
|
|
19
24
|
return (
|
|
20
25
|
<PopoverPrimitive.Portal>
|
|
21
26
|
<PopoverPrimitive.Positioner
|
|
@@ -23,6 +28,8 @@ function PopoverContent({
|
|
|
23
28
|
align={align}
|
|
24
29
|
side={side}
|
|
25
30
|
sideOffset={sideOffset}
|
|
31
|
+
anchor={anchor}
|
|
32
|
+
collisionPadding={collisionPadding}
|
|
26
33
|
>
|
|
27
34
|
<PopoverPrimitive.Popup
|
|
28
35
|
data-slot="popover-content"
|
package/src/hooks/.gitkeep
DELETED
|
File without changes
|