@42-central/ui-react 0.18.0 → 0.18.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/biome/no-gray-color.grit +18 -0
- package/dist/{chunk-6I4R3HR6.js → chunk-RQL7FVCS.js} +3 -3
- package/dist/{chunk-6I4R3HR6.js.map → chunk-RQL7FVCS.js.map} +1 -1
- package/dist/{chunk-JBVFWSRQ.js → chunk-VIYVN4WF.js} +6 -4
- package/dist/chunk-VIYVN4WF.js.map +1 -0
- package/dist/{chunk-S53FHWNG.js → chunk-YWRBG23W.js} +3 -3
- package/dist/chunk-YWRBG23W.js.map +1 -0
- package/dist/colors.css +12 -26
- package/dist/components/avatar/avatar.d.ts +3 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/chart/chart.d.ts +1 -1
- package/dist/components/chart/index.js +1 -1
- package/dist/components/chart/index.js.map +1 -1
- package/dist/components/code/index.js +1 -1
- package/dist/components/data-table/index.js +1 -1
- package/dist/components/mark/index.js +1 -1
- package/dist/components/mark/mark.d.ts +2 -2
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/schedule/schedule-types.d.ts +1 -1
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/colors.d.ts +1 -1
- package/dist/lib/colors.d.ts.map +1 -1
- package/dist/theme.css +0 -33
- package/package.json +2 -1
- package/src/biome-plugins.test.ts +61 -0
- package/src/colors.css +12 -26
- package/src/components/avatar/avatar.tsx +3 -3
- package/src/components/chart/chart.test.tsx +1 -2
- package/src/components/chart/chart.tsx +1 -1
- package/src/components/code-block/gutters.test.ts +2 -2
- package/src/components/mark/mark.test.tsx +4 -4
- package/src/components/mark/mark.tsx +3 -3
- package/src/components/schedule/schedule-types.ts +1 -1
- package/src/components/theme-icon/theme-icon.tsx +1 -1
- package/src/lib/colors.ts +4 -2
- package/src/theme.css +0 -33
- package/dist/chunk-JBVFWSRQ.js.map +0 -1
- package/dist/chunk-S53FHWNG.js.map +0 -1
|
@@ -5,7 +5,7 @@ import type { RequiredIfGranted } from "../../lib/required-if";
|
|
|
5
5
|
import type { ScheduleSlotPredicate } from "../../lib/schedule-predicates";
|
|
6
6
|
/**
|
|
7
7
|
* A closed subset of the kit's full palette (`lib/colors.ts`), not the
|
|
8
|
-
* shared `Color` type: `brand` and `
|
|
8
|
+
* shared `Color` type: `brand` and `neutral` are excluded (reserved for chrome),
|
|
9
9
|
* and there's no custom-string escape hatch — every allowed value's
|
|
10
10
|
* `--c-text`/`--c-soft` pairing has been checked against a white/near-black
|
|
11
11
|
* grid background, a guarantee an arbitrary custom color couldn't make.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_THEME_STORAGE_KEY, resolveTheme, applyThemeAttribute, getSystemTheme, isThemeMode, disableTransitionsDuringChange } from './chunk-EEMRRRYS.js';
|
|
2
2
|
export { DEFAULT_THEME_STORAGE_KEY, THEME_MODES, buildThemeInitScript, getSystemTheme, isThemeMode, resolveTheme } from './chunk-EEMRRRYS.js';
|
|
3
3
|
export { DEFAULT_LOCALE, DEFAULT_TIME_ZONE, IntlProvider, useLocale, useTimeZone } from './chunk-7NZSTCJO.js';
|
|
4
|
-
export { COLORS } from './chunk-
|
|
4
|
+
export { COLORS } from './chunk-VIYVN4WF.js';
|
|
5
5
|
export { useContainerQuery } from './chunk-P3XMBETI.js';
|
|
6
6
|
export { LinkComponentProvider, useLinkComponent } from './chunk-GTKKRV5N.js';
|
|
7
7
|
import { useIsomorphicLayoutEffect } from './chunk-BUIHQJGE.js';
|
package/dist/lib/colors.d.ts
CHANGED
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
* 3. Add a `[data-color="<name>"]` block in `colors.css` with the slot vars
|
|
10
10
|
* (and a dark-mode override if the shade should shift).
|
|
11
11
|
*/
|
|
12
|
-
export declare const COLORS: readonly ["brand", "
|
|
12
|
+
export declare const COLORS: readonly ["brand", "neutral", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink"];
|
|
13
13
|
export type Color = (typeof COLORS)[number] | (string & {});
|
|
14
14
|
//# sourceMappingURL=colors.d.ts.map
|
package/dist/lib/colors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/lib/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,YACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/lib/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,YACjB,OAAO,EAMP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,CACE,CAAA;AAIV,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA"}
|
package/dist/theme.css
CHANGED
|
@@ -48,34 +48,6 @@
|
|
|
48
48
|
--color-gray-dark-900: #13161b;
|
|
49
49
|
--color-gray-dark-950: #0c0e12;
|
|
50
50
|
|
|
51
|
-
/* Gray Modern */
|
|
52
|
-
--color-gray-modern-25: #fcfcfd;
|
|
53
|
-
--color-gray-modern-50: #f8fafc;
|
|
54
|
-
--color-gray-modern-100: #eef2f6;
|
|
55
|
-
--color-gray-modern-200: #e3e8ef;
|
|
56
|
-
--color-gray-modern-300: #cdd5df;
|
|
57
|
-
--color-gray-modern-400: #9aa4b2;
|
|
58
|
-
--color-gray-modern-500: #697586;
|
|
59
|
-
--color-gray-modern-600: #4b5565;
|
|
60
|
-
--color-gray-modern-700: #364152;
|
|
61
|
-
--color-gray-modern-800: #202939;
|
|
62
|
-
--color-gray-modern-900: #121926;
|
|
63
|
-
--color-gray-modern-950: #0d121c;
|
|
64
|
-
|
|
65
|
-
/* Gray Blue */
|
|
66
|
-
--color-gray-blue-25: #fcfcfd;
|
|
67
|
-
--color-gray-blue-50: #f8f9fc;
|
|
68
|
-
--color-gray-blue-100: #eaecf5;
|
|
69
|
-
--color-gray-blue-200: #d5d9eb;
|
|
70
|
-
--color-gray-blue-300: #b3b8db;
|
|
71
|
-
--color-gray-blue-400: #717bbc;
|
|
72
|
-
--color-gray-blue-500: #4e5ba6;
|
|
73
|
-
--color-gray-blue-600: #3e4784;
|
|
74
|
-
--color-gray-blue-700: #363f72;
|
|
75
|
-
--color-gray-blue-800: #293056;
|
|
76
|
-
--color-gray-blue-900: #101323;
|
|
77
|
-
--color-gray-blue-950: #0d0f1c;
|
|
78
|
-
|
|
79
51
|
/* Gray True */
|
|
80
52
|
--color-gray-true-25: #fcfcfc;
|
|
81
53
|
--color-gray-true-50: #f7f7f7;
|
|
@@ -1274,8 +1246,3 @@ body {
|
|
|
1274
1246
|
|
|
1275
1247
|
/* Variants to use with slider's values */
|
|
1276
1248
|
@custom-variant state-under-or-at (&:is([data-state="under-value"], [data-state="at-value"]));
|
|
1277
|
-
|
|
1278
|
-
*,
|
|
1279
|
-
:root {
|
|
1280
|
-
@apply scrollbar-thumb-gray-300/60 hover:scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-500/60 dark:hover:scrollbar-thumb-gray-500 scrollbar-track-transparent;
|
|
1281
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@42-central/ui-react",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "React UI kit for 42 tools",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"src",
|
|
13
|
+
"biome",
|
|
13
14
|
"README.md"
|
|
14
15
|
],
|
|
15
16
|
"exports": {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process"
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs"
|
|
3
|
+
import { tmpdir } from "node:os"
|
|
4
|
+
import { join, resolve } from "node:path"
|
|
5
|
+
import { afterAll, describe, expect, it } from "vitest"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Runs the shipped Biome plugins (`biome/*.grit`) against a throwaway file
|
|
9
|
+
* with the repo's own Biome. A Grit rule that stops matching fails silently,
|
|
10
|
+
* with no lint error, so this pins what each one flags and what it leaves alone.
|
|
11
|
+
*/
|
|
12
|
+
const pkg = resolve(__dirname, "..")
|
|
13
|
+
const biome = resolve(pkg, "../../node_modules/.bin/biome")
|
|
14
|
+
// Outside the repo: Biome never lints anything under `node_modules`, and the
|
|
15
|
+
// fixture must not pick up the repo's own biome.json either.
|
|
16
|
+
const dir = mkdtempSync(join(tmpdir(), "biome-plugins-"))
|
|
17
|
+
|
|
18
|
+
const lint = (plugin: string, source: string) => {
|
|
19
|
+
writeFileSync(
|
|
20
|
+
join(dir, "biome.json"),
|
|
21
|
+
JSON.stringify({
|
|
22
|
+
root: true,
|
|
23
|
+
plugins: [resolve(pkg, "biome", plugin)],
|
|
24
|
+
linter: { rules: { recommended: false } },
|
|
25
|
+
formatter: { enabled: false },
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
28
|
+
writeFileSync(join(dir, "sample.tsx"), source)
|
|
29
|
+
const out = execFileSync(biome, ["lint", "--reporter=json", "sample.tsx"], {
|
|
30
|
+
cwd: dir,
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
})
|
|
33
|
+
const { diagnostics } = JSON.parse(out) as {
|
|
34
|
+
diagnostics: { location: { start: { line: number } } }[]
|
|
35
|
+
}
|
|
36
|
+
return diagnostics.map((d) => d.location.start.line)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
afterAll(() => rmSync(dir, { recursive: true, force: true }))
|
|
40
|
+
|
|
41
|
+
describe("no-gray-color.grit", () => {
|
|
42
|
+
it("warns on gray literals and nothing else", () => {
|
|
43
|
+
const lines = lint(
|
|
44
|
+
"no-gray-color.grit",
|
|
45
|
+
[
|
|
46
|
+
`export const A = () => (`,
|
|
47
|
+
` <>`,
|
|
48
|
+
` <Badge color="gray" variant="light">a</Badge>`,
|
|
49
|
+
` <Button color={"gray"} />`,
|
|
50
|
+
` <Button color={'gray'}>b</Button>`,
|
|
51
|
+
` <Button color="neutral" />`,
|
|
52
|
+
` <Text c="gray" />`,
|
|
53
|
+
` <Badge background="gray" />`,
|
|
54
|
+
` </>`,
|
|
55
|
+
`)`,
|
|
56
|
+
`export const data = { color: "gray" }`,
|
|
57
|
+
].join("\n"),
|
|
58
|
+
)
|
|
59
|
+
expect(lines).toEqual([3, 4, 5])
|
|
60
|
+
})
|
|
61
|
+
})
|
package/src/colors.css
CHANGED
|
@@ -21,12 +21,10 @@
|
|
|
21
21
|
* --c-solid-hover : filled hover state (600 light / 400 dark)
|
|
22
22
|
* --c-on-solid : foreground sitting on a solid background. brand-950 (dark navy)
|
|
23
23
|
* for every color, light or dark theme — matches the 42 UI Kit
|
|
24
|
-
* Figma, which uses dark navy text on solid fills. `
|
|
25
|
-
* theme) is the one exception,
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* the 4.5 AA threshold) but keeps brand-950 anyway for
|
|
29
|
-
* consistency with the other nine colors.
|
|
24
|
+
* Figma, which uses dark navy text on solid fills. `neutral`
|
|
25
|
+
* (light theme) is the one exception, white on its black fill.
|
|
26
|
+
* `purple` is a marginal fail (4.29:1 vs the 4.5 AA threshold)
|
|
27
|
+
* but keeps brand-950 anyway for consistency with the others.
|
|
30
28
|
* --c-soft : tinted surface for `light` / hover tints (50 light / 950 dark)
|
|
31
29
|
* --c-soft-hover : a step darker than --c-soft
|
|
32
30
|
* --c-text : text + icon on non-filled surfaces (700 light / 300 dark)
|
|
@@ -94,24 +92,6 @@
|
|
|
94
92
|
--c-text: var(--color-brand-300);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
[data-color="gray"] {
|
|
98
|
-
/* gray-700 is too dark for brand-950 text (2.05:1, fails WCAG AA) — kept white. */
|
|
99
|
-
--c-solid: var(--color-gray-light-700);
|
|
100
|
-
--c-solid-hover: var(--color-gray-light-800);
|
|
101
|
-
--c-on-solid: var(--color-white);
|
|
102
|
-
--c-soft: var(--color-gray-light-100);
|
|
103
|
-
--c-soft-hover: var(--color-gray-light-200);
|
|
104
|
-
--c-text: var(--color-gray-light-700);
|
|
105
|
-
}
|
|
106
|
-
[data-theme="dark"] [data-color="gray"] {
|
|
107
|
-
--c-solid: var(--color-gray-dark-300);
|
|
108
|
-
--c-solid-hover: var(--color-gray-dark-200);
|
|
109
|
-
--c-on-solid: var(--color-brand-950);
|
|
110
|
-
--c-soft: var(--color-gray-dark-800);
|
|
111
|
-
--c-soft-hover: var(--color-gray-dark-700);
|
|
112
|
-
--c-text: var(--color-gray-dark-300);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
95
|
[data-color="red"] {
|
|
116
96
|
--c-solid: var(--color-red-500);
|
|
117
97
|
--c-solid-hover: var(--color-red-600);
|
|
@@ -268,7 +248,12 @@
|
|
|
268
248
|
--c-text: var(--color-pink-300);
|
|
269
249
|
}
|
|
270
250
|
|
|
271
|
-
|
|
251
|
+
/* `gray` is a deprecated alias of `neutral`: the former mid-gray palette was
|
|
252
|
+
cut (Figma's "gray" Button already draws these exact values). The selector
|
|
253
|
+
stays one minor so `data-color="gray"` doesn't silently inherit its
|
|
254
|
+
ancestor's palette instead. Remove in the next minor. */
|
|
255
|
+
[data-color="neutral"],
|
|
256
|
+
[data-color="gray"] {
|
|
272
257
|
/* Figma "White" hierarchy — the literal white/dark-navy button most of the
|
|
273
258
|
kit defaults to. --c-soft mirrors Figma's own translucent-white overlay
|
|
274
259
|
intent, but a single value shared across themes would go invisible (or
|
|
@@ -286,7 +271,8 @@
|
|
|
286
271
|
--c-soft-hover: color-mix(in oklab, var(--color-black) 35%, transparent);
|
|
287
272
|
--c-text: var(--color-gray-light-700);
|
|
288
273
|
}
|
|
289
|
-
[data-theme="dark"] [data-color="neutral"]
|
|
274
|
+
[data-theme="dark"] [data-color="neutral"],
|
|
275
|
+
[data-theme="dark"] [data-color="gray"] {
|
|
290
276
|
--c-solid: var(--color-white);
|
|
291
277
|
--c-solid-hover: var(--color-gray-light-300);
|
|
292
278
|
--c-on-solid: var(--color-brand-950);
|
|
@@ -114,9 +114,9 @@ export type AvatarNameMode = "name" | "initials"
|
|
|
114
114
|
/**
|
|
115
115
|
* Default hash pool for `color="name"` / `color="initials"`. Excludes
|
|
116
116
|
* `brand` (the kit's own primary/CTA identity color — auto-tinting a user
|
|
117
|
-
* avatar with it would read as "official") and `
|
|
118
|
-
*
|
|
119
|
-
*
|
|
117
|
+
* avatar with it would read as "official") and `neutral` (muted, and a
|
|
118
|
+
* composed-not-scaled tone per `lib/colors.ts`, so it would just look
|
|
119
|
+
* washed-out for some names). Exported so a consumer can extend it,
|
|
120
120
|
* e.g. `palette={[...AVATAR_PALETTE, "brand"]}`.
|
|
121
121
|
*/
|
|
122
122
|
export const AVATAR_PALETTE: Color[] = [
|
|
@@ -90,9 +90,8 @@ describe("chartColors", () => {
|
|
|
90
90
|
expect(chartColors(["#ff00aa"])).toEqual(["#ff00aa"])
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
-
it("excludes brand
|
|
93
|
+
it("excludes brand and neutral from the default palette", () => {
|
|
94
94
|
expect(CHART_PALETTE).not.toContain("brand")
|
|
95
|
-
expect(CHART_PALETTE).not.toContain("gray")
|
|
96
95
|
expect(CHART_PALETTE).not.toContain("neutral")
|
|
97
96
|
})
|
|
98
97
|
})
|
|
@@ -29,7 +29,7 @@ const resolveChartColor = (color: Color): string =>
|
|
|
29
29
|
/**
|
|
30
30
|
* Ordered categorical palette for multi-series charts, built from `COLORS`
|
|
31
31
|
* (`lib/colors.ts`) minus `brand` (kept free for `color`'s own single-series
|
|
32
|
-
* identity) and `
|
|
32
|
+
* identity) and `neutral` (already the chart's own chrome color, via
|
|
33
33
|
* `styles.css`).
|
|
34
34
|
*
|
|
35
35
|
* The first four — `blue`/`green`/`red`/`pink` — are the only 4-combination
|
|
@@ -262,12 +262,12 @@ describe("resolveGutterColumns", () => {
|
|
|
262
262
|
|
|
263
263
|
it("{ text: true, color } renders the payload verbatim, still colored", () => {
|
|
264
264
|
const columns: CodeBlockGutterColumn[] = [
|
|
265
|
-
{ kind: "content", tags: { blame: { text: true, color: "
|
|
265
|
+
{ kind: "content", tags: { blame: { text: true, color: "neutral" } } },
|
|
266
266
|
]
|
|
267
267
|
const gutters = resolveGutterColumns(columns, notationOf([]), 0)
|
|
268
268
|
const span = gutters.render(line([{ tag: "blame", payload: "alice" }]))[0]!
|
|
269
269
|
expect(text(span)).toBe("alice")
|
|
270
|
-
expect(span.properties["data-color"]).toBe("
|
|
270
|
+
expect(span.properties["data-color"]).toBe("neutral")
|
|
271
271
|
})
|
|
272
272
|
|
|
273
273
|
it("a content column with no color/background on the matched tag has no data-color/decoration classes", () => {
|
|
@@ -17,12 +17,12 @@ describe("Mark", () => {
|
|
|
17
17
|
expect(screen.getByTestId("note")).toBeTruthy()
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
it("defaults background to yellow and text to neutral
|
|
20
|
+
it("defaults background to yellow and text to neutral when neither is set", () => {
|
|
21
21
|
const { container } = render(<Mark>hi</Mark>)
|
|
22
22
|
const root = container.firstElementChild as HTMLElement
|
|
23
23
|
const inner = root.firstElementChild as HTMLElement
|
|
24
24
|
expect(root.getAttribute("data-color")).toBe("yellow")
|
|
25
|
-
expect(inner.getAttribute("data-color")).toBe("
|
|
25
|
+
expect(inner.getAttribute("data-color")).toBe("neutral")
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
it("the inner span always contains text-(--c-text), unconditionally", () => {
|
|
@@ -68,12 +68,12 @@ describe("Mark", () => {
|
|
|
68
68
|
expect(root.className).toContain("bg-transparent")
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
it("background alone tints only the highlight — text stays neutral
|
|
71
|
+
it("background alone tints only the highlight — text stays neutral, not matching background", () => {
|
|
72
72
|
const { container } = render(<Mark background="red">hi</Mark>)
|
|
73
73
|
const root = container.firstElementChild as HTMLElement
|
|
74
74
|
const inner = root.firstElementChild as HTMLElement
|
|
75
75
|
expect(root.getAttribute("data-color")).toBe("red")
|
|
76
|
-
expect(inner.getAttribute("data-color")).toBe("
|
|
76
|
+
expect(inner.getAttribute("data-color")).toBe("neutral")
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
it("root className carries the translucent soft background, never a text color", () => {
|
|
@@ -10,7 +10,7 @@ import type { WithTestId } from "../../lib/test-id"
|
|
|
10
10
|
* `background` and `color` are fully independent — `background` only ever
|
|
11
11
|
* changes the highlight, `color` only ever changes the text, neither leaks
|
|
12
12
|
* into the other: `background` alone (no `color`) tints the highlight with
|
|
13
|
-
* *neutral*
|
|
13
|
+
* *neutral* text, not text matching the highlight; `color` alone (no
|
|
14
14
|
* `background`) renders as tinted text with no highlight at all —
|
|
15
15
|
* `background` only defaults to `"yellow"` when it's unset, regardless of
|
|
16
16
|
* `color`. This needs two DOM nodes rather than one: `--c-soft`/`--c-text`
|
|
@@ -41,7 +41,7 @@ export type MarkProps = ComponentPropsWithoutRef<"mark"> &
|
|
|
41
41
|
WithTestId & {
|
|
42
42
|
/**
|
|
43
43
|
* Text color. Independent of `background` — never falls back to it.
|
|
44
|
-
* @default "
|
|
44
|
+
* @default "neutral"
|
|
45
45
|
*/
|
|
46
46
|
color?: Color
|
|
47
47
|
/**
|
|
@@ -71,7 +71,7 @@ export const Mark = ({ className, color, background, children, testId, ...rest }
|
|
|
71
71
|
className,
|
|
72
72
|
)}
|
|
73
73
|
>
|
|
74
|
-
<span data-color={color ?? "
|
|
74
|
+
<span data-color={color ?? "neutral"} className="text-(--c-text)">
|
|
75
75
|
{children}
|
|
76
76
|
</span>
|
|
77
77
|
</mark>
|
|
@@ -6,7 +6,7 @@ import type { ScheduleSlotPredicate } from "../../lib/schedule-predicates"
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A closed subset of the kit's full palette (`lib/colors.ts`), not the
|
|
9
|
-
* shared `Color` type: `brand` and `
|
|
9
|
+
* shared `Color` type: `brand` and `neutral` are excluded (reserved for chrome),
|
|
10
10
|
* and there's no custom-string escape hatch — every allowed value's
|
|
11
11
|
* `--c-text`/`--c-soft` pairing has been checked against a white/near-black
|
|
12
12
|
* grid background, a guarantee an arbitrary custom color couldn't make.
|
|
@@ -38,7 +38,7 @@ const themeIconVariants = cva(
|
|
|
38
38
|
// fill blends with whatever surface it sits on instead of reading
|
|
39
39
|
// as a painted CTA block. The border mixes in black on top of that
|
|
40
40
|
// same var — a fixed darkening, not another opacity step of it —
|
|
41
|
-
// so it reads as a recessed edge in both themes; some colors (
|
|
41
|
+
// so it reads as a recessed edge in both themes; some colors (neutral
|
|
42
42
|
// in particular) have a dark-mode `--c-solid` that's lighter than
|
|
43
43
|
// its own soft/text steps, which would flip a same-var-opacity
|
|
44
44
|
// border the wrong way. This is the ThemeIcon-specific reading of
|
package/src/lib/colors.ts
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export const COLORS = [
|
|
13
13
|
"brand",
|
|
14
|
-
"gray",
|
|
15
14
|
// Composed from existing white/gray/brand-950 tokens rather than its own
|
|
16
|
-
// scale — the literal white/dark-navy button from the 42 UI Kit Figma
|
|
15
|
+
// scale — the literal white/dark-navy button from the 42 UI Kit Figma
|
|
16
|
+
// (where it is still labelled "gray" on Button). The former mid-gray `gray`
|
|
17
|
+
// palette was cut in its favor; `data-color="gray"` survives only as a
|
|
18
|
+
// deprecated CSS alias of this one (see colors.css).
|
|
17
19
|
"neutral",
|
|
18
20
|
"red",
|
|
19
21
|
"orange",
|
package/src/theme.css
CHANGED
|
@@ -48,34 +48,6 @@
|
|
|
48
48
|
--color-gray-dark-900: #13161b;
|
|
49
49
|
--color-gray-dark-950: #0c0e12;
|
|
50
50
|
|
|
51
|
-
/* Gray Modern */
|
|
52
|
-
--color-gray-modern-25: #fcfcfd;
|
|
53
|
-
--color-gray-modern-50: #f8fafc;
|
|
54
|
-
--color-gray-modern-100: #eef2f6;
|
|
55
|
-
--color-gray-modern-200: #e3e8ef;
|
|
56
|
-
--color-gray-modern-300: #cdd5df;
|
|
57
|
-
--color-gray-modern-400: #9aa4b2;
|
|
58
|
-
--color-gray-modern-500: #697586;
|
|
59
|
-
--color-gray-modern-600: #4b5565;
|
|
60
|
-
--color-gray-modern-700: #364152;
|
|
61
|
-
--color-gray-modern-800: #202939;
|
|
62
|
-
--color-gray-modern-900: #121926;
|
|
63
|
-
--color-gray-modern-950: #0d121c;
|
|
64
|
-
|
|
65
|
-
/* Gray Blue */
|
|
66
|
-
--color-gray-blue-25: #fcfcfd;
|
|
67
|
-
--color-gray-blue-50: #f8f9fc;
|
|
68
|
-
--color-gray-blue-100: #eaecf5;
|
|
69
|
-
--color-gray-blue-200: #d5d9eb;
|
|
70
|
-
--color-gray-blue-300: #b3b8db;
|
|
71
|
-
--color-gray-blue-400: #717bbc;
|
|
72
|
-
--color-gray-blue-500: #4e5ba6;
|
|
73
|
-
--color-gray-blue-600: #3e4784;
|
|
74
|
-
--color-gray-blue-700: #363f72;
|
|
75
|
-
--color-gray-blue-800: #293056;
|
|
76
|
-
--color-gray-blue-900: #101323;
|
|
77
|
-
--color-gray-blue-950: #0d0f1c;
|
|
78
|
-
|
|
79
51
|
/* Gray True */
|
|
80
52
|
--color-gray-true-25: #fcfcfc;
|
|
81
53
|
--color-gray-true-50: #f7f7f7;
|
|
@@ -1274,8 +1246,3 @@ body {
|
|
|
1274
1246
|
|
|
1275
1247
|
/* Variants to use with slider's values */
|
|
1276
1248
|
@custom-variant state-under-or-at (&:is([data-state="under-value"], [data-state="at-value"]));
|
|
1277
|
-
|
|
1278
|
-
*,
|
|
1279
|
-
:root {
|
|
1280
|
-
@apply scrollbar-thumb-gray-300/60 hover:scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-500/60 dark:hover:scrollbar-thumb-gray-500 scrollbar-track-transparent;
|
|
1281
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/colors.ts"],"names":[],"mappings":";AAWO,IAAM,MAAA,GAAS;AAAA,EACpB,OAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA,EAGA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF","file":"chunk-JBVFWSRQ.js","sourcesContent":["/**\n * Single source of truth for the `color` prop accepted by colored components\n * (Button, ActionIcon, Slider, …). The const array drives both the type and\n * any runtime iteration (docs swatches, story controls).\n *\n * Adding a new color is a three-step change:\n * 1. Append the name here.\n * 2. Define its `--color-<name>-{25..950}` scale in `theme.css`.\n * 3. Add a `[data-color=\"<name>\"]` block in `colors.css` with the slot vars\n * (and a dark-mode override if the shade should shift).\n */\nexport const COLORS = [\n \"brand\",\n \"gray\",\n // Composed from existing white/gray/brand-950 tokens rather than its own\n // scale — the literal white/dark-navy button from the 42 UI Kit Figma.\n \"neutral\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"blue\",\n \"purple\",\n \"pink\",\n] as const\n\n// Extend the type to allow custom color strings (e.g. `color=\"custom\"`)\n// but still allow complete type safety for the predefined colors\nexport type Color = (typeof COLORS)[number] | (string & {})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/mark/mark.tsx"],"names":[],"mappings":";;;;AAqDO,IAAM,IAAA,GAAO,CAAC,EAAE,SAAA,EAAW,KAAA,EAAO,YAAY,QAAA,EAAU,MAAA,EAAQ,GAAG,IAAA,EAAK,KAAiB;AAG9F,EAAA,MAAM,cAAA,GAAiB,UAAA,KAAe,MAAA,IAAa,KAAA,KAAU,MAAA;AAC7D,EAAA,MAAM,KAAK,UAAA,IAAc,QAAA;AACzB,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAY,iBAAiB,EAAA,GAAK,MAAA;AAAA,MACjC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAClC,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,EAAA;AAAA,QACT,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,iBAAiB,+BAAA,GAAkC,gBAAA;AAAA,QACnD;AAAA,OACF;AAAA,MAEA,8BAAC,MAAA,EAAA,EAAK,YAAA,EAAY,SAAS,MAAA,EAAQ,SAAA,EAAU,mBAC1C,QAAA,EACH;AAAA;AAAA,GACF;AAEJ","file":"chunk-S53FHWNG.js","sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * Mark — an inline `<mark>` highlighter. Pure React Server Component.\n *\n * `background` and `color` are fully independent — `background` only ever\n * changes the highlight, `color` only ever changes the text, neither leaks\n * into the other: `background` alone (no `color`) tints the highlight with\n * *neutral* (\"gray\") text, not text matching the highlight; `color` alone (no\n * `background`) renders as tinted text with no highlight at all —\n * `background` only defaults to `\"yellow\"` when it's unset, regardless of\n * `color`. This needs two DOM nodes rather than one: `--c-soft`/`--c-text`\n * are both defined together inside the same `[data-color=\"X\"]` block in\n * `colors.css`, so a single `data-color` attribute can only ever scope one\n * color's worth of both vars at once. Letting background and text pick\n * *different* color names — and stay theme-aware, the whole reason\n * `--c-soft`/`--c-text` exist instead of a fixed shade — means they need two\n * independently-scoped `data-color` attributes. The outer `<mark>` scopes\n * `--c-soft` for the background; the inner `<span>` scopes its own `--c-text`\n * for the text, independent of the outer scope.\n *\n * The inner span's `text-(--c-text)` class is unconditional — never gated\n * behind an `if (color)` branch — so it always declares its own explicit\n * `color`, never inheriting one. That's what makes nesting a colored `<Mark>`\n * inside a colored `<Code>` (or any other colored ancestor) \"just work\": an\n * ancestor's `color` only reaches a descendant by inheritance, the\n * lowest-priority source of a property's value, so the inner span's own\n * declaration always wins, no `!important` or descendant-selector games\n * needed.\n *\n * No `asChild` (plain `ComponentPropsWithoutRef<\"mark\">`, not `HTMLArkProps`):\n * the inner span above already repurposes `children` as \"the highlighted\n * content,\" which collides with `asChild`'s usual meaning (the one child to\n * render as root) — the same reasoning `Skeleton`'s wrap mode uses to skip it.\n */\nexport type MarkProps = ComponentPropsWithoutRef<\"mark\"> &\n WithTestId & {\n /**\n * Text color. Independent of `background` — never falls back to it.\n * @default \"gray\" (neutral)\n */\n color?: Color\n /**\n * Background/highlight tint. Re-exported as `Color` from `@42/ui-react`.\n * @default \"yellow\"\n */\n background?: Color\n }\n\nexport const Mark = ({ className, color, background, children, testId, ...rest }: MarkProps) => {\n // A background only defaults to \"yellow\" when neither prop is given —\n // `color` alone must render as tinted text with no highlight at all.\n const showBackground = background !== undefined || color === undefined\n const bg = background ?? \"yellow\"\n return (\n <mark\n data-color={showBackground ? bg : undefined}\n {...props({ \"data-testid\": testId })}\n {...rest}\n className={cn(\n \"rounded-xs\",\n // Browsers ship a UA-stylesheet default for `<mark>` (a solid yellow\n // background, historically with black text) — an explicit\n // `bg-transparent` is required in the no-background branch, or that\n // default bleeds through instead of \"no highlight at all\".\n showBackground ? \"bg-(--c-soft)/60 px-0.5 py-px\" : \"bg-transparent\",\n className,\n )}\n >\n <span data-color={color ?? \"gray\"} className=\"text-(--c-text)\">\n {children}\n </span>\n </mark>\n )\n}\n"]}
|