|
7 | 7 | <!-- Site Styles -->
|
8 | 8 | <link rel="stylesheet" href="{assets}/site.css" />
|
9 | 9 |
|
10 |
| - {#if fixationTheme} |
| 10 | + {#if theme} |
11 | 11 | <!-- SMUI Styles -->
|
12 |
| - <link rel="stylesheet" href="{assets}/smui-fixation.css" /> |
| 12 | + <link rel="stylesheet" href="{assets}/smui-{theme}.css" /> |
13 | 13 |
|
14 | 14 | <!-- Site Styles -->
|
15 |
| - <link rel="stylesheet" href="{assets}/site-fixation.css" /> |
| 15 | + <link rel="stylesheet" href="{assets}/site-{theme}.css" /> |
16 | 16 |
|
17 | 17 | {#if lightTheme === false}
|
18 | 18 | <!-- SMUI Styles -->
|
19 |
| - <link rel="stylesheet" href="{assets}/smui-fixation.css" /> |
20 | 19 | <link
|
21 | 20 | rel="stylesheet"
|
22 |
| - href="{assets}/smui-fixation-dark.css" |
| 21 | + href="{assets}/smui-{theme}-dark.css" |
23 | 22 | media="screen"
|
24 | 23 | />
|
25 | 24 | <!-- Site Styles -->
|
26 |
| - <link rel="stylesheet" href="{assets}/site-fixation.css" /> |
27 | 25 | <link
|
28 | 26 | rel="stylesheet"
|
29 |
| - href="{assets}/site-fixation-dark.css" |
| 27 | + href="{assets}/site-{theme}-dark.css" |
30 | 28 | media="screen"
|
31 | 29 | />
|
32 | 30 | {:else if lightTheme !== true}
|
33 | 31 | <!-- SMUI Styles -->
|
34 | 32 | <link
|
35 | 33 | rel="stylesheet"
|
36 |
| - href="{assets}/smui-fixation-dark.css" |
| 34 | + href="{assets}/smui-{theme}-dark.css" |
37 | 35 | media="screen and (prefers-color-scheme: dark)"
|
38 | 36 | />
|
39 | 37 |
|
40 | 38 | <!-- Site Styles -->
|
41 | 39 | <link
|
42 | 40 | rel="stylesheet"
|
43 |
| - href="{assets}/site-fixation-dark.css" |
| 41 | + href="{assets}/site-{theme}-dark.css" |
44 | 42 | media="screen and (prefers-color-scheme: dark)"
|
45 | 43 | />
|
46 | 44 | {/if}
|
|
133 | 131 | </IconButton>
|
134 | 132 | <Tooltip>Hunter Perrin (SMUI Author) on Mastodon</Tooltip>
|
135 | 133 | </Wrapper>
|
136 |
| - <Wrapper> |
137 |
| - <IconButton |
138 |
| - toggle |
139 |
| - pressed={fixationTheme} |
140 |
| - on:SMUIIconButtonToggle:change={() => |
141 |
| - (fixationTheme = !fixationTheme)} |
142 |
| - > |
143 |
| - <Icon component={Svg} viewBox="0 0 24 24" on> |
144 |
| - <path fill="currentColor" d={siSvelte.path} /> |
145 |
| - </Icon> |
146 |
| - <Icon component={Svg} viewBox="0 0 24 24"> |
147 |
| - <path fill="currentColor" d={mdiFormatPaint} /> |
148 |
| - </Icon> |
149 |
| - </IconButton> |
150 |
| - <Tooltip |
151 |
| - >{fixationTheme |
152 |
| - ? 'Go back to the Svelte theme' |
153 |
| - : 'Check out a custom theme'}</Tooltip |
154 |
| - > |
155 |
| - </Wrapper> |
156 |
| - <Wrapper> |
157 |
| - <IconButton |
158 |
| - toggle |
159 |
| - pressed={lightTheme} |
160 |
| - on:SMUIIconButtonToggle:change={() => (lightTheme = !lightTheme)} |
161 |
| - > |
162 |
| - <Icon component={Svg} viewBox="0 0 24 24" on> |
163 |
| - <path fill="currentColor" d={mdiWeatherNight} /> |
164 |
| - </Icon> |
165 |
| - <Icon component={Svg} viewBox="0 0 24 24"> |
166 |
| - <path fill="currentColor" d={mdiWeatherSunny} /> |
167 |
| - </Icon> |
168 |
| - </IconButton> |
169 |
| - <Tooltip>{lightTheme ? 'Lights off' : 'Lights on'}</Tooltip> |
170 |
| - </Wrapper> |
| 134 | + <div style="display: inline-block;"> |
| 135 | + <Wrapper> |
| 136 | + <IconButton on:click={() => themeMenu.setOpen(true)}> |
| 137 | + <Icon component={Svg} viewBox="0 0 24 24"> |
| 138 | + <path fill="currentColor" d={mdiPalette} /> |
| 139 | + </Icon> |
| 140 | + </IconButton> |
| 141 | + <Tooltip>Pick a theme.</Tooltip> |
| 142 | + </Wrapper> |
| 143 | + <Menu bind:this={themeMenu}> |
| 144 | + <List> |
| 145 | + <SelectionGroup> |
| 146 | + <Item |
| 147 | + on:SMUI:action={() => (lightTheme = null)} |
| 148 | + selected={lightTheme == null} |
| 149 | + > |
| 150 | + <SelectionGroupIcon> |
| 151 | + <i class="material-icons">check</i> |
| 152 | + </SelectionGroupIcon> |
| 153 | + <Text>Follow System</Text> |
| 154 | + </Item> |
| 155 | + {#each [{ label: 'Light', value: true }, { label: 'Dark', value: false }] as item} |
| 156 | + <Item |
| 157 | + on:SMUI:action={() => (lightTheme = item.value)} |
| 158 | + selected={lightTheme === item.value} |
| 159 | + > |
| 160 | + <SelectionGroupIcon> |
| 161 | + <i class="material-icons">check</i> |
| 162 | + </SelectionGroupIcon> |
| 163 | + <Text>{item.label}</Text> |
| 164 | + </Item> |
| 165 | + {/each} |
| 166 | + </SelectionGroup> |
| 167 | + <Separator /> |
| 168 | + <SelectionGroup> |
| 169 | + <Item |
| 170 | + on:SMUI:action={() => (theme = null)} |
| 171 | + selected={theme == null} |
| 172 | + > |
| 173 | + <SelectionGroupIcon> |
| 174 | + <i class="material-icons">check</i> |
| 175 | + </SelectionGroupIcon> |
| 176 | + <Text>Svelte</Text> |
| 177 | + </Item> |
| 178 | + {#each themes as item} |
| 179 | + <Item |
| 180 | + on:SMUI:action={() => (theme = item.value)} |
| 181 | + selected={theme === item.value} |
| 182 | + > |
| 183 | + <SelectionGroupIcon> |
| 184 | + <i class="material-icons">check</i> |
| 185 | + </SelectionGroupIcon> |
| 186 | + <Text>{item.label}</Text> |
| 187 | + </Item> |
| 188 | + {/each} |
| 189 | + </SelectionGroup> |
| 190 | + <Separator /> |
| 191 | + <Item tag="a" href="/THEMING.md" style="color: inherit;"> |
| 192 | + <Text>Learn about theming</Text> |
| 193 | + </Item> |
| 194 | + <Item |
| 195 | + tag="a" |
| 196 | + href="https://github.com/hperrin/svelte-material-ui/tree/master/packages/site/src/theme" |
| 197 | + target="_blank" |
| 198 | + rel="noreferrer noorigin" |
| 199 | + style="color: inherit;" |
| 200 | + > |
| 201 | + <Text>See the theme source</Text> |
| 202 | + </Item> |
| 203 | + </List> |
| 204 | + </Menu> |
| 205 | + </div> |
171 | 206 | </Section>
|
172 | 207 | </Row>
|
173 | 208 | </TopAppBar>
|
|
221 | 256 |
|
222 | 257 | <script lang="ts">
|
223 | 258 | import { onDestroy, onMount } from 'svelte';
|
224 |
| - import { |
225 |
| - mdiFileDocument, |
226 |
| - mdiFormatPaint, |
227 |
| - mdiWeatherSunny, |
228 |
| - mdiWeatherNight, |
229 |
| - } from '@mdi/js'; |
230 |
| - import { siDiscord, siMastodon, siGithub, siSvelte } from 'simple-icons'; |
| 259 | + import { mdiFileDocument, mdiPalette } from '@mdi/js'; |
| 260 | + import { siDiscord, siMastodon, siGithub } from 'simple-icons'; |
231 | 261 | import TinyGesture from 'tinygesture';
|
232 | 262 | import { assets } from '$app/paths';
|
233 | 263 | import { page } from '$app/stores';
|
234 | 264 |
|
235 | 265 | import TopAppBar, { Row, Section, Title } from '@smui/top-app-bar';
|
236 | 266 | import Drawer, { Content, Scrim, AppContent } from '@smui/drawer';
|
237 | 267 | import IconButton from '@smui/icon-button';
|
| 268 | + import Menu, { SelectionGroup, SelectionGroupIcon } from '@smui/menu'; |
238 | 269 | import List, { Item, Text, Separator } from '@smui/list';
|
239 | 270 | import Tooltip, { Wrapper } from '@smui/tooltip';
|
240 | 271 | import { Icon, Svg } from '@smui/common';
|
|
248 | 279 | let drawerGesture: TinyGesture;
|
249 | 280 | let mainContentGesture: TinyGesture;
|
250 | 281 |
|
251 |
| - let lightTheme: boolean; |
252 |
| - let fixationTheme = false; |
| 282 | + const themes = [ |
| 283 | + { label: 'Material', value: 'material' }, |
| 284 | + { label: 'Fixation', value: 'fixation' }, |
| 285 | + { label: 'Metro', value: 'metro' }, |
| 286 | + { label: 'Unity', value: 'unity' }, |
| 287 | + ]; |
| 288 | + let themeMenu: Menu; |
| 289 | + let lightTheme: boolean | null = null; |
| 290 | + let theme: string | null = null; |
253 | 291 |
|
254 | 292 | type DemoSection = {
|
255 | 293 | component?: InstanceType<typeof Item>;
|
|
0 commit comments