mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
docs(theme): add examples
This commit is contained in:
parent
05cfeda115
commit
a97f72d3e3
8 changed files with 112 additions and 4 deletions
|
@ -5,4 +5,40 @@
|
||||||
|
|
||||||
### Default
|
### Default
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/Theme" />
|
<FileSource src="/framed/Theme/Theme" />
|
||||||
|
|
||||||
|
### Persist locally
|
||||||
|
|
||||||
|
Set `persist` to `true` to persist the theme locally using the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemePersist" />
|
||||||
|
|
||||||
|
### Custom theme
|
||||||
|
|
||||||
|
Define keys and values in the `tokens` prop that override default Carbon theme tokens.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemeTokens" />
|
||||||
|
|
||||||
|
### Theme toggle
|
||||||
|
|
||||||
|
Set `render` to `"toggle"` to render a toggle switch to control the theme.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemeToggle" />
|
||||||
|
|
||||||
|
### Theme toggle (custom)
|
||||||
|
|
||||||
|
Customize the toggle using the `toggle` prop.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemeToggleCustom" />
|
||||||
|
|
||||||
|
### Theme select
|
||||||
|
|
||||||
|
Set `render` to `"select"` to render a select dropdown to control the theme.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemeSelect" />
|
||||||
|
|
||||||
|
### Theme select (custom)
|
||||||
|
|
||||||
|
Customize the select using the `select` prop.
|
||||||
|
|
||||||
|
<FileSource src="/framed/Theme/ThemeSelectCustom" />
|
|
@ -1,5 +1,17 @@
|
||||||
<script>
|
<script>
|
||||||
import { Theme } from "carbon-components-svelte";
|
import {
|
||||||
|
Theme,
|
||||||
|
RadioButtonGroup,
|
||||||
|
RadioButton,
|
||||||
|
} from "carbon-components-svelte";
|
||||||
|
|
||||||
|
let theme = "g90";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Theme theme="g90" />
|
<Theme bind:theme />
|
||||||
|
|
||||||
|
<RadioButtonGroup legendText="Carbon theme" bind:selected="{theme}">
|
||||||
|
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||||
|
<RadioButton labelText="{value}" value="{value}" />
|
||||||
|
{/each}
|
||||||
|
</RadioButtonGroup>
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
Theme,
|
||||||
|
RadioButtonGroup,
|
||||||
|
RadioButton,
|
||||||
|
} from "carbon-components-svelte";
|
||||||
|
|
||||||
|
let theme = "g90";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Theme bind:theme persist persistKey="__carbon-theme" />
|
||||||
|
|
||||||
|
<RadioButtonGroup legendText="Carbon theme" bind:selected="{theme}">
|
||||||
|
{#each ["white", "g10", "g80", "g90", "g100"] as value}
|
||||||
|
<RadioButton labelText="{value}" value="{value}" />
|
||||||
|
{/each}
|
||||||
|
</RadioButtonGroup>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<script>
|
||||||
|
import { Theme } from "carbon-components-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Theme render="select" />
|
|
@ -0,0 +1,12 @@
|
||||||
|
<script>
|
||||||
|
import { Theme } from "carbon-components-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Theme
|
||||||
|
render="select"
|
||||||
|
select="{{
|
||||||
|
themes: ['white', 'g90', 'g100'],
|
||||||
|
labelText: 'Select a theme',
|
||||||
|
inline: true,
|
||||||
|
}}"
|
||||||
|
/>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<script>
|
||||||
|
import { Theme } from "carbon-components-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Theme render="toggle" />
|
|
@ -0,0 +1,14 @@
|
||||||
|
<script>
|
||||||
|
import { Theme } from "carbon-components-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Theme
|
||||||
|
render="toggle"
|
||||||
|
toggle="{{
|
||||||
|
themes: ['g10', 'g80'],
|
||||||
|
labelA: 'Enable dark mode',
|
||||||
|
labelB: 'Enable dark mode',
|
||||||
|
hideLabel: true,
|
||||||
|
size: 'sm',
|
||||||
|
}}"
|
||||||
|
/>
|
|
@ -2,6 +2,13 @@
|
||||||
import { Theme, Button } from "carbon-components-svelte";
|
import { Theme, Button } from "carbon-components-svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Theme theme="g90" tokens="{{ 'button-primary': 'violet' }}" />
|
<Theme
|
||||||
|
theme="g90"
|
||||||
|
tokens="{{
|
||||||
|
'interactive-01': '#d02670',
|
||||||
|
'hover-primary': '#ee5396',
|
||||||
|
'active-primary': '#9f1853',
|
||||||
|
}}"
|
||||||
|
/>
|
||||||
|
|
||||||
<Button>Primary button</Button>
|
<Button>Primary button</Button>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue