@farming-labs/svelte-theme 0.0.2-beta.13 → 0.0.2-beta.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/svelte-theme",
3
- "version": "0.0.2-beta.13",
3
+ "version": "0.0.2-beta.15",
4
4
  "description": "Svelte UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle",
5
5
  "type": "module",
6
6
  "svelte": "./src/index.js",
@@ -33,6 +33,22 @@
33
33
  "./pixel-border/css": "./styles/pixel-border-bundle.css",
34
34
  "./darksharp/css": "./styles/darksharp-bundle.css"
35
35
  },
36
+ "typesVersions": {
37
+ "*": {
38
+ "pixel-border": [
39
+ "./src/themes/pixel-border.d.ts"
40
+ ],
41
+ "darksharp": [
42
+ "./src/themes/darksharp.d.ts"
43
+ ],
44
+ "fumadocs": [
45
+ "./src/themes/default.d.ts"
46
+ ],
47
+ ".": [
48
+ "./src/index.d.ts"
49
+ ]
50
+ }
51
+ },
36
52
  "files": [
37
53
  "src",
38
54
  "styles"
@@ -49,8 +65,8 @@
49
65
  "dependencies": {
50
66
  "gray-matter": "^4.0.3",
51
67
  "sugar-high": "^0.9.5",
52
- "@farming-labs/docs": "0.0.2-beta.13",
53
- "@farming-labs/svelte": "0.0.2-beta.13"
68
+ "@farming-labs/docs": "0.0.2-beta.15",
69
+ "@farming-labs/svelte": "0.0.2-beta.15"
54
70
  },
55
71
  "peerDependencies": {
56
72
  "svelte": ">=5.0.0"
@@ -115,12 +115,78 @@
115
115
  if (!iconKey) return null;
116
116
  return ICON_MAP[iconKey] || null;
117
117
  }
118
+
119
+ const COLOR_MAP = {
120
+ primary: "--color-fd-primary",
121
+ primaryForeground: "--color-fd-primary-foreground",
122
+ background: "--color-fd-background",
123
+ foreground: "--color-fd-foreground",
124
+ muted: "--color-fd-muted",
125
+ mutedForeground: "--color-fd-muted-foreground",
126
+ border: "--color-fd-border",
127
+ card: "--color-fd-card",
128
+ cardForeground: "--color-fd-card-foreground",
129
+ accent: "--color-fd-accent",
130
+ accentForeground: "--color-fd-accent-foreground",
131
+ popover: "--color-fd-popover",
132
+ popoverForeground: "--color-fd-popover-foreground",
133
+ secondary: "--color-fd-secondary",
134
+ secondaryForeground: "--color-fd-secondary-foreground",
135
+ ring: "--color-fd-ring",
136
+ };
137
+
138
+ function buildColorsCSS(colors) {
139
+ if (!colors) return "";
140
+ const vars = [];
141
+ for (const [key, value] of Object.entries(colors)) {
142
+ if (!value || !COLOR_MAP[key]) continue;
143
+ vars.push(`${COLOR_MAP[key]}: ${value};`);
144
+ }
145
+ if (vars.length === 0) return "";
146
+ return `:root, .dark {\n ${vars.join("\n ")}\n}`;
147
+ }
148
+
149
+ function buildFontStyleVars(prefix, style) {
150
+ if (!style) return "";
151
+ const parts = [];
152
+ if (style.size) parts.push(`${prefix}-size: ${style.size};`);
153
+ if (style.weight != null) parts.push(`${prefix}-weight: ${style.weight};`);
154
+ if (style.lineHeight) parts.push(`${prefix}-line-height: ${style.lineHeight};`);
155
+ if (style.letterSpacing) parts.push(`${prefix}-letter-spacing: ${style.letterSpacing};`);
156
+ return parts.join("\n ");
157
+ }
158
+
159
+ function buildTypographyCSS(typo) {
160
+ if (!typo?.font) return "";
161
+ const vars = [];
162
+ const fontStyle = typo.font.style;
163
+ if (fontStyle?.sans) vars.push(`--fd-font-sans: ${fontStyle.sans};`);
164
+ if (fontStyle?.mono) vars.push(`--fd-font-mono: ${fontStyle.mono};`);
165
+ for (const el of ["h1", "h2", "h3", "h4", "body", "small"]) {
166
+ const elStyle = typo.font[el];
167
+ if (elStyle) {
168
+ const elVars = buildFontStyleVars(`--fd-${el}`, elStyle);
169
+ if (elVars) vars.push(elVars);
170
+ }
171
+ }
172
+ if (vars.length === 0) return "";
173
+ return `:root {\n ${vars.join("\n ")}\n}`;
174
+ }
175
+
176
+ let overrideCSS = $derived.by(() => {
177
+ const colorOverrides = config?.theme?._userColorOverrides;
178
+ const typography = config?.theme?.ui?.typography;
179
+ return [buildColorsCSS(colorOverrides), buildTypographyCSS(typography)].filter(Boolean).join("\n");
180
+ });
118
181
  </script>
119
182
 
120
183
  <svelte:window onkeydown={handleKeydown} />
121
184
 
122
185
  <svelte:head>
123
186
  {@html `<script>${themeInitScript}</script>`}
187
+ {#if overrideCSS}
188
+ {@html `<style>${overrideCSS}</style>`}
189
+ {/if}
124
190
  </svelte:head>
125
191
 
126
192
  <div class="fd-layout">
@@ -94,6 +94,11 @@
94
94
  .fd-sidebar-folder.fd-sidebar-first-item {
95
95
  border-top: none;
96
96
  }
97
+
98
+ .fd-sidebar-top-link:last-child,
99
+ .fd-sidebar-nav > .fd-sidebar-folder:last-child {
100
+ border-bottom: 1px solid var(--color-fd-border);
101
+ }
97
102
  .fd-sidebar-folder-content::before {
98
103
  content: '';
99
104
  position: absolute;