Skip to content

Commit ac308a9

Browse files
authored
NEXT: Resolve custom theme and doc errors (#2701)
1 parent 244c531 commit ac308a9

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

sites/next.skeleton.dev/src/content/docs/design/themes.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,33 @@ Optionally you can choose to generate a custom theme to adapt to your app's uniq
4747
4. Copy the contents of the generated theme in full.
4848
5. Create a new file in the root of your project called `theme-custom.ts` (any name is fine).
4949

50-
You may import one or more themes at the top of your project's `tailwind.config`, then review the register instructions below.
50+
You may import each custom theme at the top of your project's `tailwind.config`. Then proceed to the register instructions below.
5151

5252
```ts title="tailwind.config"
53-
import { yourThemeNameHere } from './theme-custom.ts';
53+
import myCustomTheme from './theme-custom.ts';
5454
```
5555

5656
## Register Themes
5757

58-
Once all themes are imported, you can register your theme in the Skeleton plugin settings in `tailwind.config`.
58+
Register each imported theme within the Skeleton plugin settings in `tailwind.config`. Then proceed to activation below.
5959

6060
```ts title="tailwind.config" {6-8, 10}
6161
plugins: [
6262
// The Skeleton Tailwind Plugin
6363
skeleton({
6464
themes: [
65-
// Preset Themes
65+
// Preset Theme(s)
6666
themes.cerberus,
6767
themes.pine,
6868
themes.rose,
69-
// Custom Themes
70-
yourThemeNameHere,
69+
// Custom Theme(s)
70+
myCustomTheme,
7171
],
7272
}),
7373
];
7474
```
7575

76-
> TIP: There's no limited to how many themes you can register, but each increases the size of your Tailwind-generated CSS bundle.
76+
> TIP: There's no limited to how many themes you can register, but each increases the size of your generated CSS bundle.
7777
7878
## Activate a Theme
7979

sites/themes.skeleton.dev/src/lib/components/previews/CodeGen.svelte

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33
import { stateFormCore } from '$lib/state.svelte';
44
55
let theme = $derived(genThemeCode());
6+
7+
function formatThemeName(e: any) {
8+
if (!e.target.value) return;
9+
stateFormCore.name = e.target.value.replace(/[^\w]/g, ''); // [A-Za-z0-9_]
10+
}
611
</script>
712

813
<div class="space-y-4 md:space-y-8">
914
<!-- Theme Name -->
1015
<label class="label">
1116
<span class="label-text">Name Your Theme</span>
12-
<input type="text" class="input" placeholder="ex: my-custom-theme" bind:value={stateFormCore.name} />
17+
<input
18+
type="text"
19+
class="input"
20+
placeholder="ex: myCustomTheme"
21+
bind:value={stateFormCore.name}
22+
oninput={formatThemeName}
23+
/>
1324
</label>
1425
<!-- prettier-ignore -->
1526
<pre class="pre !bg-neutral-950"><code>{`
16-
const ${stateFormCore.name} = ${JSON.stringify(theme.properties, null, 2)}\n
27+
import type { Theme } from '@skeletonlabs/skeleton';\n
28+
const ${stateFormCore.name} = ${JSON.stringify({name: stateFormCore.name, properties: theme.properties}, null, 2)} satisfies Theme;\n
1729
export default ${stateFormCore.name};
1830
`.trim()}</code></pre>
1931
</div>

sites/themes.skeleton.dev/src/lib/state.svelte.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export let stateDisplay: any = $state({
1212
// Form: Core ---
1313

1414
export let stateFormCore: Record<string, string> = $state({
15-
name: 'theme'
15+
name: 'myCustomTheme'
1616
});
1717

1818
// Form: Colors ---

0 commit comments

Comments
 (0)