@tenphi/starlight 0.9.6 → 0.10.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/dist/components/GlobalStyles.js +246 -268
- package/dist/components/LayoutComponents.js +0 -9
- package/dist/components/TastyComponents.js +1 -5
- package/dist/components/component-styles.test.ts +39 -29
- package/dist/components/component-styles.ts +11 -35
- package/dist/components/customize-component.js +2 -4
- package/dist/index.js +9 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,6 @@ configureCookbookStates();
|
|
|
6
6
|
|
|
7
7
|
export const LogoRoot = customizeComponent(
|
|
8
8
|
"Logo",
|
|
9
|
-
{ as: "span" },
|
|
10
9
|
tasty({
|
|
11
10
|
as: "span",
|
|
12
11
|
styles: {
|
|
@@ -33,7 +32,6 @@ export const LogoRoot = customizeComponent(
|
|
|
33
32
|
|
|
34
33
|
export const PackageVersionRoot = customizeComponent(
|
|
35
34
|
"PackageVersion",
|
|
36
|
-
{ as: "span" },
|
|
37
35
|
tasty({
|
|
38
36
|
as: "span",
|
|
39
37
|
styles: {
|
|
@@ -55,7 +53,6 @@ export const PackageVersionRoot = customizeComponent(
|
|
|
55
53
|
|
|
56
54
|
export const TopNavigationRoot = customizeComponent(
|
|
57
55
|
"TopNavigation",
|
|
58
|
-
{ as: "nav" },
|
|
59
56
|
tasty({
|
|
60
57
|
as: "nav",
|
|
61
58
|
styles: {
|
|
@@ -101,7 +98,6 @@ export const TopNavigationRoot = customizeComponent(
|
|
|
101
98
|
|
|
102
99
|
export const StarlightHeaderRoot = customizeComponent(
|
|
103
100
|
"StarlightHeader",
|
|
104
|
-
{ as: "div" },
|
|
105
101
|
tasty({
|
|
106
102
|
as: "div",
|
|
107
103
|
styles: {
|
|
@@ -345,7 +341,6 @@ const appearanceSelectStyles = {
|
|
|
345
341
|
|
|
346
342
|
export const ThemeSelectRoot = customizeComponent(
|
|
347
343
|
"ThemeSelect",
|
|
348
|
-
{ as: "starlight-theme-select" },
|
|
349
344
|
tasty({
|
|
350
345
|
as: "starlight-theme-select",
|
|
351
346
|
styles: appearanceSelectStyles,
|
|
@@ -354,7 +349,6 @@ export const ThemeSelectRoot = customizeComponent(
|
|
|
354
349
|
|
|
355
350
|
export const ContrastSelectRoot = customizeComponent(
|
|
356
351
|
"ContrastSelect",
|
|
357
|
-
{ as: "cookbook-contrast-select" },
|
|
358
352
|
tasty({
|
|
359
353
|
as: "cookbook-contrast-select",
|
|
360
354
|
styles: appearanceSelectStyles,
|
|
@@ -363,7 +357,6 @@ export const ContrastSelectRoot = customizeComponent(
|
|
|
363
357
|
|
|
364
358
|
export const MobileNavigationTabsRoot = customizeComponent(
|
|
365
359
|
"MobileNavigationTabs",
|
|
366
|
-
{ as: "nav" },
|
|
367
360
|
tasty({
|
|
368
361
|
as: "nav",
|
|
369
362
|
styles: {
|
|
@@ -416,7 +409,6 @@ export const MobileNavigationTabsRoot = customizeComponent(
|
|
|
416
409
|
|
|
417
410
|
export const MobileMenuFooterRoot = customizeComponent(
|
|
418
411
|
"MobileMenuFooter",
|
|
419
|
-
{ as: "div" },
|
|
420
412
|
tasty({
|
|
421
413
|
as: "div",
|
|
422
414
|
styles: {
|
|
@@ -442,7 +434,6 @@ export const MobileMenuFooterRoot = customizeComponent(
|
|
|
442
434
|
|
|
443
435
|
export const FooterRoot = customizeComponent(
|
|
444
436
|
"Footer",
|
|
445
|
-
{ as: "footer" },
|
|
446
437
|
tasty({
|
|
447
438
|
as: "footer",
|
|
448
439
|
styles: {
|
|
@@ -6,7 +6,6 @@ configureCookbookStates();
|
|
|
6
6
|
|
|
7
7
|
export const CardRoot = customizeComponent(
|
|
8
8
|
"Card",
|
|
9
|
-
{ as: "article" },
|
|
10
9
|
tasty({
|
|
11
10
|
as: "article",
|
|
12
11
|
styles: {
|
|
@@ -68,7 +67,6 @@ const previewElements = {
|
|
|
68
67
|
|
|
69
68
|
export const PreviewRoot = customizeComponent(
|
|
70
69
|
"Preview",
|
|
71
|
-
{ as: "figure", elements: previewElements },
|
|
72
70
|
tasty({
|
|
73
71
|
as: "figure",
|
|
74
72
|
styles: {
|
|
@@ -116,7 +114,6 @@ export const PreviewRoot = customizeComponent(
|
|
|
116
114
|
|
|
117
115
|
export const StepsRoot = customizeComponent(
|
|
118
116
|
"Steps",
|
|
119
|
-
{ as: "ol" },
|
|
120
117
|
tasty({
|
|
121
118
|
as: "ol",
|
|
122
119
|
styles: {
|
|
@@ -132,7 +129,7 @@ export const StepsRoot = customizeComponent(
|
|
|
132
129
|
Marker: {
|
|
133
130
|
$: "> li::marker",
|
|
134
131
|
color: "#accent-text",
|
|
135
|
-
preset: "
|
|
132
|
+
preset: "strong",
|
|
136
133
|
},
|
|
137
134
|
},
|
|
138
135
|
}),
|
|
@@ -140,7 +137,6 @@ export const StepsRoot = customizeComponent(
|
|
|
140
137
|
|
|
141
138
|
export const TabsRoot = customizeComponent(
|
|
142
139
|
"Tabs",
|
|
143
|
-
{ as: "div" },
|
|
144
140
|
tasty({
|
|
145
141
|
as: "div",
|
|
146
142
|
styles: {
|
|
@@ -27,45 +27,22 @@ describe("component style configuration", () => {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it("
|
|
31
|
-
configureComponentStyles({
|
|
32
|
-
Card: { mode: "extend", styles: { radius: "1cr" } },
|
|
33
|
-
});
|
|
34
|
-
expect(resolveComponentStyles("Card", defaults)).toMatchObject({
|
|
35
|
-
color: "#text",
|
|
36
|
-
radius: "1cr",
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
configureComponentStyles({
|
|
40
|
-
Card: { mode: "replace", styles: { display: "grid" } },
|
|
41
|
-
});
|
|
42
|
-
expect(resolveComponentStyles("Card", defaults)).toEqual({
|
|
43
|
-
display: "grid",
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("normalizes configured component overrides for Tasty composition", () => {
|
|
30
|
+
it("returns the user override for Tasty component composition", () => {
|
|
48
31
|
expect(resolveComponentStyleOverride("Card")).toBeUndefined();
|
|
49
32
|
|
|
50
33
|
configureComponentStyles({ Card: { padding: "3x" } });
|
|
51
34
|
expect(resolveComponentStyleOverride("Card")).toEqual({
|
|
52
|
-
|
|
53
|
-
styles: { padding: "3x" },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
configureComponentStyles({
|
|
57
|
-
Card: { mode: "replace", styles: { display: "grid" } },
|
|
58
|
-
});
|
|
59
|
-
expect(resolveComponentStyleOverride("Card")).toEqual({
|
|
60
|
-
mode: "replace",
|
|
61
|
-
styles: { display: "grid" },
|
|
35
|
+
padding: "3x",
|
|
62
36
|
});
|
|
63
37
|
});
|
|
64
38
|
|
|
65
|
-
it("
|
|
39
|
+
it("merges configuration into bridged component style trees", () => {
|
|
66
40
|
configureComponentStyles({
|
|
67
41
|
MarkdownTable: { Table: { radius: "0" } },
|
|
68
42
|
Mermaid: { Diagram: { maxInlineSize: "90%" } },
|
|
43
|
+
MobileTableOfContents: { LinkLabel: { whiteSpace: "normal" } },
|
|
44
|
+
Sidebar: { Link: { padding: "1x" } },
|
|
45
|
+
TableOfContents: { Link: { color: "#text" } },
|
|
69
46
|
});
|
|
70
47
|
|
|
71
48
|
expect(
|
|
@@ -84,6 +61,39 @@ describe("component style configuration", () => {
|
|
|
84
61
|
).toEqual({
|
|
85
62
|
Diagram: { display: "block", maxInlineSize: "90%" },
|
|
86
63
|
});
|
|
64
|
+
expect(
|
|
65
|
+
resolveComponentStyles("Sidebar", {
|
|
66
|
+
display: "block",
|
|
67
|
+
Content: { gap: "3x" },
|
|
68
|
+
Link: { color: "#text-soft", padding: "2x" },
|
|
69
|
+
}),
|
|
70
|
+
).toEqual({
|
|
71
|
+
display: "block",
|
|
72
|
+
Content: { gap: "3x" },
|
|
73
|
+
Link: { color: "#text-soft", padding: "1x" },
|
|
74
|
+
});
|
|
75
|
+
expect(
|
|
76
|
+
resolveComponentStyles("TableOfContents", {
|
|
77
|
+
paddingBlockStart: "5x",
|
|
78
|
+
Heading: { color: "#text" },
|
|
79
|
+
Link: { color: "#text-muted", preset: "small" },
|
|
80
|
+
}),
|
|
81
|
+
).toEqual({
|
|
82
|
+
paddingBlockStart: "5x",
|
|
83
|
+
Heading: { color: "#text" },
|
|
84
|
+
Link: { color: "#text", preset: "small" },
|
|
85
|
+
});
|
|
86
|
+
expect(
|
|
87
|
+
resolveComponentStyles("MobileTableOfContents", {
|
|
88
|
+
display: "grid",
|
|
89
|
+
Item: { minInlineSize: "0" },
|
|
90
|
+
LinkLabel: { overflow: "hidden", whiteSpace: "nowrap" },
|
|
91
|
+
}),
|
|
92
|
+
).toEqual({
|
|
93
|
+
display: "grid",
|
|
94
|
+
Item: { minInlineSize: "0" },
|
|
95
|
+
LinkLabel: { overflow: "hidden", whiteSpace: "normal" },
|
|
96
|
+
});
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
it("keeps custom anatomy styles on the compatibility bridge", () => {
|
|
@@ -21,32 +21,21 @@ export function configureComponentStyles(
|
|
|
21
21
|
|
|
22
22
|
export function resolveComponentStyles(
|
|
23
23
|
name: CookbookComponentName,
|
|
24
|
-
|
|
24
|
+
baseStyles: Styles,
|
|
25
25
|
): Styles {
|
|
26
|
-
const
|
|
27
|
-
name
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return configured.mode === "replace"
|
|
33
|
-
? styles
|
|
34
|
-
: mergeStyles(defaults, styles);
|
|
35
|
-
}
|
|
36
|
-
return mergeStyles(defaults, configured as Styles);
|
|
26
|
+
const configuredStyles = sharedConfiguration
|
|
27
|
+
.__tenphiCookbookComponentStyles?.[name] as
|
|
28
|
+
ComponentStyleConfig | undefined;
|
|
29
|
+
return configuredStyles
|
|
30
|
+
? mergeStyles(baseStyles, configuredStyles as Styles)
|
|
31
|
+
: baseStyles;
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
export function resolveComponentStyleOverride(
|
|
40
35
|
name: CookbookComponentName,
|
|
41
|
-
):
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
] as ComponentStyleConfig | undefined;
|
|
45
|
-
if (!configured) return undefined;
|
|
46
|
-
if (isModeConfig(configured)) {
|
|
47
|
-
return { mode: configured.mode, styles: configured.styles as Styles };
|
|
48
|
-
}
|
|
49
|
-
return { mode: "extend", styles: configured as Styles };
|
|
36
|
+
): Styles | undefined {
|
|
37
|
+
return sharedConfiguration.__tenphiCookbookComponentStyles?.[name] as
|
|
38
|
+
Styles | undefined;
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
/** Preserve custom anatomy names from the pre-component style API. */
|
|
@@ -59,21 +48,8 @@ export function resolveLegacyAnatomyStyles(
|
|
|
59
48
|
(entry): entry is [string, ComponentStyleConfig] =>
|
|
60
49
|
!cookbookComponentNames.has(entry[0]) && entry[1] !== undefined,
|
|
61
50
|
)
|
|
62
|
-
.map(([name, value]) => [
|
|
63
|
-
`[data-tasty-anatomy="${name}"]`,
|
|
64
|
-
isModeConfig(value) ? value.styles : value,
|
|
65
|
-
]);
|
|
51
|
+
.map(([name, value]) => [`[data-tasty-anatomy="${name}"]`, value]);
|
|
66
52
|
return entries.length
|
|
67
53
|
? (Object.fromEntries(entries) as Record<string, Styles>)
|
|
68
54
|
: undefined;
|
|
69
55
|
}
|
|
70
|
-
|
|
71
|
-
function isModeConfig(
|
|
72
|
-
value: ComponentStyleConfig,
|
|
73
|
-
): value is Extract<ComponentStyleConfig, { mode: string }> {
|
|
74
|
-
return (
|
|
75
|
-
"mode" in value &&
|
|
76
|
-
(value.mode === "extend" || value.mode === "replace") &&
|
|
77
|
-
"styles" in value
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { tasty } from "@tenphi/tasty";
|
|
2
2
|
import { resolveComponentStyleOverride } from "./component-styles.js";
|
|
3
3
|
|
|
4
|
-
export function customizeComponent(name,
|
|
4
|
+
export function customizeComponent(name, base) {
|
|
5
5
|
const override = resolveComponentStyleOverride(name);
|
|
6
6
|
if (!override) return base;
|
|
7
|
-
return override
|
|
8
|
-
? tasty({ ...options, styles: override.styles })
|
|
9
|
-
: tasty(base, { styles: override.styles });
|
|
7
|
+
return tasty(base, { styles: override });
|
|
10
8
|
}
|
package/dist/index.js
CHANGED
|
@@ -163,7 +163,7 @@ const DEFAULT_TYPOGRAPHY_PRESETS = {
|
|
|
163
163
|
fontFamily: BODY_FONT,
|
|
164
164
|
fontSize: "1rem",
|
|
165
165
|
lineHeight: 1.65,
|
|
166
|
-
letterSpacing: "
|
|
166
|
+
letterSpacing: "0",
|
|
167
167
|
fontWeight: 420,
|
|
168
168
|
boldFontWeight: 640
|
|
169
169
|
},
|
|
@@ -171,16 +171,16 @@ const DEFAULT_TYPOGRAPHY_PRESETS = {
|
|
|
171
171
|
fontFamily: BODY_FONT,
|
|
172
172
|
fontSize: "1rem",
|
|
173
173
|
lineHeight: 1.15,
|
|
174
|
-
letterSpacing: "-0.
|
|
174
|
+
letterSpacing: "-0.01em",
|
|
175
175
|
fontWeight: 640,
|
|
176
176
|
boldFontWeight: 720
|
|
177
177
|
},
|
|
178
|
-
h1: heading("clamp(2.5rem, 5vw, 3.25rem)", 1.05, "-0.
|
|
179
|
-
h2: heading("clamp(1.75rem, 3vw, 2.125rem)", 1.1, "-0.
|
|
180
|
-
h3: heading("1.5rem", 1.15, "-0.
|
|
181
|
-
h4: heading("1.25rem", 1.2, "-0.
|
|
182
|
-
h5: heading("1.125rem", 1.25, "-0.
|
|
183
|
-
h6: heading("1rem", 1.3, "
|
|
178
|
+
h1: heading("clamp(2.5rem, 5vw, 3.25rem)", 1.05, "-0.025em"),
|
|
179
|
+
h2: heading("clamp(1.75rem, 3vw, 2.125rem)", 1.1, "-0.018em"),
|
|
180
|
+
h3: heading("1.5rem", 1.15, "-0.012em"),
|
|
181
|
+
h4: heading("1.25rem", 1.2, "-0.008em"),
|
|
182
|
+
h5: heading("1.125rem", 1.25, "-0.004em"),
|
|
183
|
+
h6: heading("1rem", 1.3, "0"),
|
|
184
184
|
navigation: {
|
|
185
185
|
fontFamily: "var(--body-font-family)",
|
|
186
186
|
fontSize: "0.9375rem",
|
|
@@ -851,12 +851,9 @@ function configureComponentStyles(styles) {
|
|
|
851
851
|
/** Preserve custom anatomy names from the pre-component style API. */
|
|
852
852
|
function resolveLegacyAnatomyStyles(styles) {
|
|
853
853
|
if (!styles) return void 0;
|
|
854
|
-
const entries = Object.entries(styles).filter((entry) => !cookbookComponentNames.has(entry[0]) && entry[1] !== void 0).map(([name, value]) => [`[data-tasty-anatomy="${name}"]`,
|
|
854
|
+
const entries = Object.entries(styles).filter((entry) => !cookbookComponentNames.has(entry[0]) && entry[1] !== void 0).map(([name, value]) => [`[data-tasty-anatomy="${name}"]`, value]);
|
|
855
855
|
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
856
856
|
}
|
|
857
|
-
function isModeConfig(value) {
|
|
858
|
-
return "mode" in value && (value.mode === "extend" || value.mode === "replace") && "styles" in value;
|
|
859
|
-
}
|
|
860
857
|
//#endregion
|
|
861
858
|
//#region src/component-overrides.ts
|
|
862
859
|
function resolveComponentOverrides(defaults, overrides, disabledFooterPath) {
|