@passui/tokens 0.1.0 → 0.1.2
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 -1
- package/package.json +1 -1
- package/src/accent.ts +2 -11
- package/src/theme-css.ts +18 -44
- package/styles/base.css +31 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @passui/tokens
|
|
2
2
|
|
|
3
3
|
Shared Passui colors, typography, layout, motion and generated theme CSS.
|
|
4
|
-
No React
|
|
4
|
+
No React runtime is required. Import tokens from `@passui/tokens`
|
|
5
5
|
and styles from `@passui/tokens/theme.css`. Framework packages compose the
|
|
6
6
|
shared styles and register their own Tailwind source files.
|
|
7
7
|
|
package/package.json
CHANGED
package/src/accent.ts
CHANGED
|
@@ -11,14 +11,7 @@ export interface AccentColors {
|
|
|
11
11
|
accentSoft: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export type AccentId =
|
|
15
|
-
| "blush"
|
|
16
|
-
| "honey"
|
|
17
|
-
| "sage"
|
|
18
|
-
| "ocean"
|
|
19
|
-
| "lavender"
|
|
20
|
-
| "rose"
|
|
21
|
-
| "graphite"
|
|
14
|
+
export type AccentId = "blush" | "honey" | "sage" | "ocean" | "lavender" | "rose" | "graphite"
|
|
22
15
|
|
|
23
16
|
export interface Accent {
|
|
24
17
|
id: AccentId
|
|
@@ -159,8 +152,6 @@ export const accents: Record<AccentId, Accent> = {
|
|
|
159
152
|
|
|
160
153
|
export const defaultAccent: AccentId = "blush"
|
|
161
154
|
|
|
162
|
-
export function isAccentId(
|
|
163
|
-
value: unknown
|
|
164
|
-
): value is AccentId {
|
|
155
|
+
export function isAccentId(value: unknown): value is AccentId {
|
|
165
156
|
return typeof value === "string" && value in accents
|
|
166
157
|
}
|
package/src/theme-css.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AccentColors,
|
|
3
|
-
accents,
|
|
4
|
-
defaultAccent,
|
|
5
|
-
} from "./accent"
|
|
1
|
+
import { type AccentColors, accents, defaultAccent } from "./accent"
|
|
6
2
|
import { type ColorScheme, dark, light } from "./color"
|
|
7
3
|
import { radius, space } from "./layout"
|
|
8
4
|
import { duration, easing } from "./motion"
|
|
9
|
-
import {
|
|
10
|
-
fontFamily,
|
|
11
|
-
minimumTextSize,
|
|
12
|
-
textStyles,
|
|
13
|
-
} from "./typography"
|
|
5
|
+
import { fontFamily, minimumTextSize, textStyles } from "./typography"
|
|
14
6
|
|
|
15
|
-
const kebab = (key: string) =>
|
|
16
|
-
key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
|
|
7
|
+
const kebab = (key: string) => key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
|
|
17
8
|
|
|
18
9
|
/**
|
|
19
10
|
* Text styles scale together with `--type-scale` (set from the reader's text
|
|
@@ -21,22 +12,17 @@ const kebab = (key: string) =>
|
|
|
21
12
|
* `leading-*` utilities, so adopting a size never moves existing leading.
|
|
22
13
|
*/
|
|
23
14
|
function textStyleVars(): string[] {
|
|
24
|
-
return Object.entries(textStyles).flatMap(
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
)
|
|
15
|
+
return Object.entries(textStyles).flatMap(([name, style]) => {
|
|
16
|
+
const scaled = (px: number) =>
|
|
17
|
+
`max(${Math.min(px, minimumTextSize)}px, calc(${px}px * var(--type-scale, 1)))`
|
|
18
|
+
return [
|
|
19
|
+
` --text-${kebab(name)}: ${scaled(style.size)};`,
|
|
20
|
+
` --leading-${kebab(name)}: ${scaled(style.lineHeight)};`,
|
|
21
|
+
]
|
|
22
|
+
})
|
|
34
23
|
}
|
|
35
24
|
|
|
36
|
-
function colorVars(
|
|
37
|
-
scheme: ColorScheme | AccentColors,
|
|
38
|
-
backgroundShare = 0
|
|
39
|
-
): string {
|
|
25
|
+
function colorVars(scheme: ColorScheme | AccentColors, backgroundShare = 0): string {
|
|
40
26
|
return Object.entries(scheme)
|
|
41
27
|
.map(([key, value]) => {
|
|
42
28
|
// The window ground keeps a whisper of the accent's own tint,
|
|
@@ -60,29 +46,17 @@ function colorVars(
|
|
|
60
46
|
* through `data-accent` on the root element.
|
|
61
47
|
*/
|
|
62
48
|
export function renderThemeCss(): string {
|
|
63
|
-
const others = Object.values(accents).filter(
|
|
64
|
-
(accent) => accent.id !== defaultAccent
|
|
65
|
-
)
|
|
49
|
+
const others = Object.values(accents).filter((accent) => accent.id !== defaultAccent)
|
|
66
50
|
const lines = [
|
|
67
51
|
"/* Generated by @passui/tokens. Do not edit by hand. */",
|
|
68
52
|
"@theme static {",
|
|
69
53
|
colorVars(light, 6),
|
|
70
|
-
...Object.entries(fontFamily).map(
|
|
71
|
-
([k, v]) => ` --font-${k}: ${v};`
|
|
72
|
-
),
|
|
54
|
+
...Object.entries(fontFamily).map(([k, v]) => ` --font-${k}: ${v};`),
|
|
73
55
|
...textStyleVars(),
|
|
74
|
-
...Object.entries(radius).map(
|
|
75
|
-
|
|
76
|
-
),
|
|
77
|
-
...Object.entries(
|
|
78
|
-
([k, v]) => ` --space-${k}: ${v}px;`
|
|
79
|
-
),
|
|
80
|
-
...Object.entries(duration).map(
|
|
81
|
-
([k, v]) => ` --duration-${k}: ${v}ms;`
|
|
82
|
-
),
|
|
83
|
-
...Object.entries(easing).map(
|
|
84
|
-
([k, v]) => ` --ease-${k}: ${v};`
|
|
85
|
-
),
|
|
56
|
+
...Object.entries(radius).map(([k, v]) => ` --radius-${k}: ${v}px;`),
|
|
57
|
+
...Object.entries(space).map(([k, v]) => ` --space-${k}: ${v}px;`),
|
|
58
|
+
...Object.entries(duration).map(([k, v]) => ` --duration-${k}: ${v}ms;`),
|
|
59
|
+
...Object.entries(easing).map(([k, v]) => ` --ease-${k}: ${v};`),
|
|
86
60
|
"}",
|
|
87
61
|
"",
|
|
88
62
|
// Native controls, scrollbars and form fills follow the same appearance.
|
package/styles/base.css
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
@layer base {
|
|
7
7
|
* {
|
|
8
8
|
@apply border-separator outline-accent/50;
|
|
9
|
-
scrollbar
|
|
9
|
+
/* Passui keeps scrolling behavior, but never displays scrollbar chrome. */
|
|
10
|
+
scrollbar-width: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
*::-webkit-scrollbar {
|
|
14
|
+
display: none;
|
|
15
|
+
width: 0;
|
|
16
|
+
height: 0;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
html {
|
|
@@ -64,6 +71,29 @@
|
|
|
64
71
|
-moz-appearance: textfield;
|
|
65
72
|
appearance: textfield;
|
|
66
73
|
}
|
|
74
|
+
|
|
75
|
+
/* Apple's pattern: a heading hugs the paragraph that follows it.
|
|
76
|
+
Section separation comes from the layout around the cluster,
|
|
77
|
+
not from the heading's own bottom margin. Apps that want extra
|
|
78
|
+
air can still add mt-* explicitly. Audit §4.3.3. */
|
|
79
|
+
h1, h2, h3, h4, h5, h6 {
|
|
80
|
+
margin-block: 0;
|
|
81
|
+
}
|
|
82
|
+
h1 + p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p {
|
|
83
|
+
margin-block-start: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Apple's rule: use SF Pro Display optical variants at 20pt and above,
|
|
87
|
+
SF Pro Text below. The --font-display family is declared in
|
|
88
|
+
typography.ts but was previously unused because --font-heading
|
|
89
|
+
aliased to --font-sans. This rule wires Display to the four large
|
|
90
|
+
text utilities. On Apple hardware -apple-system auto-selects
|
|
91
|
+
optical sizes, so this is invisible there; on systems with SF Pro
|
|
92
|
+
installed outside -apple-system, it ensures the correct cut.
|
|
93
|
+
Audit §4.4. */
|
|
94
|
+
.text-large-title, .text-title, .text-title2, .text-title3 {
|
|
95
|
+
font-family: var(--font-display);
|
|
96
|
+
}
|
|
67
97
|
}
|
|
68
98
|
|
|
69
99
|
@media (prefers-reduced-motion: reduce) {
|