@talelk/newui-tailwind 0.0.0-stage → 1.0.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 +9 -2
- package/package.json +43 -3
- package/src/contrast.test.ts +160 -0
- package/src/fonts/Inter/Inter-Italic.var.woff2 +0 -0
- package/src/fonts/Inter/Inter.var.woff2 +0 -0
- package/src/fonts/Inter/LICENSE.txt +92 -0
- package/src/fonts/Inter/inter.css +61 -0
- package/src/generated/theme.css +1469 -0
- package/src/generated/tokens.css +1095 -0
- package/src/generated.test.ts +141 -0
- package/src/keyframes.test.ts +67 -0
- package/src/plugins/icon-pack.js +87 -0
- package/src/plugins/lucide.js +28 -0
- package/src/plugins/theme.js +89 -0
- package/src/source.d.ts +1 -0
- package/src/source.ts +23 -0
- package/src/style.css +41 -0
- package/src/tokens.test.ts +145 -0
- package/src/utilities.css +120 -0
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @talelk/newui-tailwind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Import `@talelk/newui-tailwind/style.css` once in your application stylesheet. This
|
|
4
|
+
Tailwind v4 layer emits semantic @theme utilities and token variables. The
|
|
5
|
+
`@talelk/newui-tailwind/source` export exposes source paths for build integration.
|
|
6
|
+
There is no root JavaScript component export.
|
|
7
|
+
|
|
8
|
+
Keep package source visible to Tailwind scanning, use semantic colour utilities,
|
|
9
|
+
and run `pnpm css:check` against a fresh production build after recipe changes.
|
|
10
|
+
Reduced-motion styles and focus rings are part of the emitted contract.
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talelk/newui-tailwind",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Tailwind CSS v4 layer: the newui design tokens as @theme, @utility and plugins.",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./style.css": {
|
|
8
|
+
"style": "./src/style.css",
|
|
9
|
+
"import": "./src/style.css"
|
|
10
|
+
},
|
|
11
|
+
"./source": {
|
|
12
|
+
"types": "./src/source.d.ts",
|
|
13
|
+
"default": "./src/source.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@talelk/newui-tokens": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@tailwindcss/forms": "^0.5.11",
|
|
24
|
+
"@tailwindcss/typography": "^0.5.20",
|
|
25
|
+
"lucide-static": "^1.57.0",
|
|
26
|
+
"tailwindcss": "^4.3.3"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"tailwindcss": "^4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/talelk/newui.git",
|
|
39
|
+
"directory": "packages/tailwind"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsx scripts/build-css.ts",
|
|
43
|
+
"build:css": "tsx scripts/build-css.ts",
|
|
44
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
45
|
+
}
|
|
6
46
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { semanticColors } from '@talelk/newui-tokens'
|
|
2
|
+
import { wcagLuminance } from 'culori'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The contrast contract.
|
|
7
|
+
*
|
|
8
|
+
* Every foreground/background pairing the components ship is asserted against
|
|
9
|
+
* WCAG AA in both themes. This is objective UX: a pairing that fails is a
|
|
10
|
+
* legibility bug, not a taste question.
|
|
11
|
+
*
|
|
12
|
+
* The pairs mirror the recipes (Button, Badge, Alert, labels, links). Disabled
|
|
13
|
+
* text is deliberately absent — WCAG exempts inactive controls from contrast.
|
|
14
|
+
*/
|
|
15
|
+
type Mode = 'light' | 'dark'
|
|
16
|
+
|
|
17
|
+
const AA = 4.5
|
|
18
|
+
|
|
19
|
+
function resolve(mode: Mode, token: string): string {
|
|
20
|
+
const [category = '', ...rest] = token.split('-')
|
|
21
|
+
const layer = semanticColors[mode] as unknown as Record<
|
|
22
|
+
string,
|
|
23
|
+
Record<string, string>
|
|
24
|
+
>
|
|
25
|
+
const value = layer[category]?.[rest.join('-')]
|
|
26
|
+
if (!value) throw new Error(`unknown token: ${token}`)
|
|
27
|
+
return value
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function contrast(fg: string, bg: string): number {
|
|
31
|
+
const a = wcagLuminance(fg)
|
|
32
|
+
const b = wcagLuminance(bg)
|
|
33
|
+
const [hi, lo] = a > b ? [a, b] : [b, a]
|
|
34
|
+
return (hi + 0.05) / (lo + 0.05)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const THEMES = ['gray', 'blue', 'green', 'amber', 'red', 'violet'] as const
|
|
38
|
+
|
|
39
|
+
interface Pair {
|
|
40
|
+
fg: string
|
|
41
|
+
bg: string
|
|
42
|
+
what: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PAIRS: Pair[] = [
|
|
46
|
+
// body copy and labels
|
|
47
|
+
{ fg: 'ink-gray-8', bg: 'surface-base', what: 'body text' },
|
|
48
|
+
{ fg: 'ink-gray-6', bg: 'surface-base', what: 'label on base' },
|
|
49
|
+
{ fg: 'ink-gray-6', bg: 'surface-gray-2', what: 'muted on gray-2' },
|
|
50
|
+
{
|
|
51
|
+
fg: 'ink-gray-6',
|
|
52
|
+
bg: 'surface-elevation-2',
|
|
53
|
+
what: 'muted on a popover/menu surface',
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
{
|
|
57
|
+
fg: 'ink-gray-6',
|
|
58
|
+
bg: 'surface-elevation-1',
|
|
59
|
+
what: 'chart subtitle and card caption',
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// a board column is the one tinted region muted text lands on
|
|
63
|
+
{ fg: 'ink-gray-8', bg: 'surface-gray-1', what: 'column heading' },
|
|
64
|
+
{ fg: 'ink-gray-6', bg: 'surface-gray-1', what: 'muted on a board column' },
|
|
65
|
+
|
|
66
|
+
{ fg: 'ink-blue-link', bg: 'surface-base', what: 'blue link on base' },
|
|
67
|
+
{ fg: 'ink-blue-link', bg: 'surface-elevation-1', what: 'blue link on card' },
|
|
68
|
+
{ fg: 'ink-blue-link', bg: 'surface-gray-1', what: 'blue link on canvas' },
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
fg: 'ink-blue-8',
|
|
72
|
+
bg: 'surface-blue-1',
|
|
73
|
+
what: 'selected navigation and its count',
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
// subtle / outline / ghost text — ink-{theme}-8 on the pale surface
|
|
77
|
+
...THEMES.map((theme) => ({
|
|
78
|
+
fg: `ink-${theme}-8`,
|
|
79
|
+
bg: `surface-${theme}-2`,
|
|
80
|
+
what: `${theme} subtle`,
|
|
81
|
+
})),
|
|
82
|
+
...THEMES.map((theme) => ({
|
|
83
|
+
fg: `ink-${theme}-8`,
|
|
84
|
+
bg: 'surface-base',
|
|
85
|
+
what: `${theme} outline/ghost`,
|
|
86
|
+
})),
|
|
87
|
+
|
|
88
|
+
// solid fills — ink-base on the saturated surface (amber needs the deepest)
|
|
89
|
+
...THEMES.map((theme) => ({
|
|
90
|
+
fg: 'ink-base',
|
|
91
|
+
bg:
|
|
92
|
+
theme === 'gray'
|
|
93
|
+
? 'surface-gray-10'
|
|
94
|
+
: theme === 'amber'
|
|
95
|
+
? 'surface-amber-9'
|
|
96
|
+
: `surface-${theme}-8`,
|
|
97
|
+
what: `${theme} solid`,
|
|
98
|
+
})),
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
describe('contrast contract (WCAG AA)', () => {
|
|
102
|
+
for (const mode of ['light', 'dark'] as Mode[]) {
|
|
103
|
+
for (const pair of PAIRS) {
|
|
104
|
+
it(`${mode}: ${pair.what} ≥ ${AA}`, () => {
|
|
105
|
+
const ratio = contrast(resolve(mode, pair.fg), resolve(mode, pair.bg))
|
|
106
|
+
expect(
|
|
107
|
+
Number(ratio.toFixed(2)),
|
|
108
|
+
`${pair.fg} on ${pair.bg} = ${ratio.toFixed(2)}:1`,
|
|
109
|
+
).toBeGreaterThanOrEqual(AA)
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Why the muted step is `ink-gray-6` and not `ink-gray-5`.
|
|
116
|
+
*
|
|
117
|
+
* The contract above only covers the pairings the recipes ship, so a *new*
|
|
118
|
+
* recipe can introduce a pairing nobody listed — which is exactly how
|
|
119
|
+
* `text-ink-gray-5` reached the pagination range, the empty-state description
|
|
120
|
+
* and the timeline in one pass, caught by Lighthouse rather than here.
|
|
121
|
+
*
|
|
122
|
+
* So the boundary is pinned instead: the step above the muted one fails AA on
|
|
123
|
+
* the base surface, and the muted one passes. Change a token and this tells
|
|
124
|
+
* you which side of the line it moved to.
|
|
125
|
+
*/
|
|
126
|
+
for (const mode of ['light', 'dark'] as Mode[]) {
|
|
127
|
+
it(`${mode}: ink-gray-5 on base is below AA — that is why muted text is ink-gray-6`, () => {
|
|
128
|
+
const failing = contrast(
|
|
129
|
+
resolve(mode, 'ink-gray-5'),
|
|
130
|
+
resolve(mode, 'surface-base'),
|
|
131
|
+
)
|
|
132
|
+
const passing = contrast(
|
|
133
|
+
resolve(mode, 'ink-gray-6'),
|
|
134
|
+
resolve(mode, 'surface-base'),
|
|
135
|
+
)
|
|
136
|
+
expect(failing).toBeLessThan(AA)
|
|
137
|
+
expect(passing).toBeGreaterThanOrEqual(AA)
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const mode of ['light', 'dark'] as Mode[]) {
|
|
142
|
+
it(`${mode}: a decorative glyph may use ink-gray-5 (3:1 non-text)`, () => {
|
|
143
|
+
// Chevrons and leading icons are non-text: WCAG 1.4.11 asks for 3:1, not
|
|
144
|
+
// 4.5:1. That is the one place the step is allowed.
|
|
145
|
+
const ratio = contrast(
|
|
146
|
+
resolve(mode, 'ink-gray-5'),
|
|
147
|
+
resolve(mode, 'surface-base'),
|
|
148
|
+
)
|
|
149
|
+
expect(ratio).toBeGreaterThanOrEqual(3)
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
for (const mode of ['light', 'dark'] as Mode[]) {
|
|
155
|
+
it(`${mode}: invalid field boundary meets non-text contrast`, () => {
|
|
156
|
+
expect(
|
|
157
|
+
contrast(resolve(mode, 'outline-red-6'), resolve(mode, 'surface-base')),
|
|
158
|
+
).toBeGreaterThanOrEqual(3)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* Variable fonts usage:
|
|
2
|
+
:root { font-family: "Inter", sans-serif; }
|
|
3
|
+
@supports (font-variation-settings: normal) {
|
|
4
|
+
:root { font-family: "InterVar", sans-serif; font-optical-sizing: auto; }
|
|
5
|
+
} */
|
|
6
|
+
@font-face {
|
|
7
|
+
font-family: "InterVar";
|
|
8
|
+
font-weight: 100 900;
|
|
9
|
+
font-display: swap;
|
|
10
|
+
font-style: normal;
|
|
11
|
+
src:
|
|
12
|
+
url("Inter.var.woff2?v=3.19") format("woff2-variations"),
|
|
13
|
+
url("Inter.var.woff2?v=3.19") format("woff2");
|
|
14
|
+
src: url("Inter.var.woff2?v=3.19") format("woff2") tech("variations");
|
|
15
|
+
unicode-range:
|
|
16
|
+
U+0000-05FF, /* Latin, Greek, Cyrillic, Hebrew */ U+0700-1FFF,
|
|
17
|
+
/* Extended Latin, Greek, Cyrillic, Armenian, Georgian */ U+2C00-2FFF,
|
|
18
|
+
/* Additional scripts */ U+4E00-9FFF,
|
|
19
|
+
/* CJK (Chinese, Japanese, Korean) */ U+AC00-D7AF; /* Hangul (Korean) */
|
|
20
|
+
}
|
|
21
|
+
@font-face {
|
|
22
|
+
font-family: "InterVar";
|
|
23
|
+
font-weight: 100 900;
|
|
24
|
+
font-display: swap;
|
|
25
|
+
font-style: italic;
|
|
26
|
+
src:
|
|
27
|
+
url("Inter-Italic.var.woff2?v=3.19") format("woff2-variations"),
|
|
28
|
+
url("Inter-Italic.var.woff2?v=3.19") format("woff2");
|
|
29
|
+
src: url("Inter-Italic.var.woff2?v=3.19") format("woff2") tech("variations");
|
|
30
|
+
unicode-range:
|
|
31
|
+
U+0000-05FF, U+0700-1FFF, U+2C00-2FFF, U+4E00-9FFF, U+AC00-D7AF;
|
|
32
|
+
}
|
|
33
|
+
/* Aliased 'InterVar' font as 'Inter' */
|
|
34
|
+
/* To prevent breaking usage of `font-family: 'Inter'` */
|
|
35
|
+
@font-face {
|
|
36
|
+
font-family: "Inter";
|
|
37
|
+
font-weight: 100 900;
|
|
38
|
+
font-display: swap;
|
|
39
|
+
font-style: normal;
|
|
40
|
+
src:
|
|
41
|
+
url("Inter.var.woff2?v=3.19") format("woff2-variations"),
|
|
42
|
+
url("Inter.var.woff2?v=3.19") format("woff2");
|
|
43
|
+
src: url("Inter.var.woff2?v=3.19") format("woff2") tech("variations");
|
|
44
|
+
unicode-range:
|
|
45
|
+
U+0000-05FF, /* Latin, Greek, Cyrillic, Hebrew */ U+0700-1FFF,
|
|
46
|
+
/* Extended Latin, Greek, Cyrillic, Armenian, Georgian */ U+2C00-2FFF,
|
|
47
|
+
/* Additional scripts */ U+4E00-9FFF,
|
|
48
|
+
/* CJK (Chinese, Japanese, Korean) */ U+AC00-D7AF; /* Hangul (Korean) */
|
|
49
|
+
}
|
|
50
|
+
@font-face {
|
|
51
|
+
font-family: "Inter";
|
|
52
|
+
font-weight: 100 900;
|
|
53
|
+
font-display: swap;
|
|
54
|
+
font-style: italic;
|
|
55
|
+
src:
|
|
56
|
+
url("Inter-Italic.var.woff2?v=3.19") format("woff2-variations"),
|
|
57
|
+
url("Inter-Italic.var.woff2?v=3.19") format("woff2");
|
|
58
|
+
src: url("Inter-Italic.var.woff2?v=3.19") format("woff2") tech("variations");
|
|
59
|
+
unicode-range:
|
|
60
|
+
U+0000-05FF, U+0700-1FFF, U+2C00-2FFF, U+4E00-9FFF, U+AC00-D7AF;
|
|
61
|
+
}
|