Skip to content

Commit bb7fd66

Browse files
committed
feat: add premade themes to svelte-material-ui package
1 parent d2e06e3 commit bb7fd66

File tree

6 files changed

+74
-6
lines changed

6 files changed

+74
-6
lines changed

INSTALL.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ If you want the Material Icon, Roboto, and Roboto Mono fonts, be sure to include
5050

5151
## Installing a Theme
5252

53+
### A Custom Theme
54+
55+
Check out the [theming instructions](/THEMING.md) for setting up a custom theme.
56+
5357
### The Default Theme
5458

5559
You can use the prebuilt "bare.css" file from the "svelte-material-ui" package. If you use this option you _can_ mostly customize your theme, but your [theming options](/THEMING.md#theming-the-bare-css) are more limited.
@@ -59,12 +63,14 @@ npm install --save svelte-material-ui
5963
```
6064

6165
```html
66+
<!-- SMUI Styles -->
6267
<link rel="stylesheet" href="node_modules/svelte-material-ui/bare.css" />
6368
```
6469

6570
If that's not working (probably because your dependencies aren't copied to your build folder), you can also use a CDN. Just be sure you update the version here when you update to a new version of SMUI. (This may already be an outdated version, so update it now too.)
6671

6772
```html
73+
<!-- SMUI Styles -->
6874
<link
6975
rel="stylesheet"
7076
href="https://cdn.jsdelivr.net/npm/[email protected]/bare.min.css"
@@ -73,6 +79,51 @@ If that's not working (probably because your dependencies aren't copied to your
7379

7480
You can also use the "bare.css" files from the individual packages if you don't use many components and want smaller file sizes.
7581

76-
### A Custom Theme
82+
### A Premade Theme
7783

78-
Check out the [theming instructions](/THEMING.md) for setting up a custom theme.
84+
There are some premade themes as well in the "svelte-material-ui" package, including dark mode versions. These are the same themes that appear on the demo site. You won't find the CSS in the repo, because they're not git tracked, but here's a list.
85+
86+
- `themes/svelte.css`
87+
- `themes/svelte-dark.css`
88+
- `themes/material.css`
89+
- `themes/material-dark.css`
90+
- `themes/fixation.css`
91+
- `themes/fixation-dark.css`
92+
- `themes/metro.css`
93+
- `themes/metro-dark.css`
94+
- `themes/unity.css`
95+
- `themes/unity-dark.css`
96+
97+
```sh
98+
npm install --save svelte-material-ui
99+
```
100+
101+
```html
102+
<!-- SMUI Styles -->
103+
<link
104+
rel="stylesheet"
105+
href="node_modules/svelte-material-ui/themes/svelte.css"
106+
media="(prefers-color-scheme: light)"
107+
/>
108+
<link
109+
rel="stylesheet"
110+
href="node_modules/svelte-material-ui/themes/svelte-dark.css"
111+
media="screen and (prefers-color-scheme: dark)"
112+
/>
113+
```
114+
115+
Or with a CDN. Remember to update the version!
116+
117+
```html
118+
<!-- SMUI Styles -->
119+
<link
120+
rel="stylesheet"
121+
href="https://cdn.jsdelivr.net/npm/[email protected]/themes/svelte.min.css"
122+
media="(prefers-color-scheme: light)"
123+
/>
124+
<link
125+
rel="stylesheet"
126+
href="https://cdn.jsdelivr.net/npm/[email protected]/themes/svelte-dark.min.css"
127+
media="screen and (prefers-color-scheme: dark)"
128+
/>
129+
```

MIGRATING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This doc contains information that will help you migrate your code from an older
77
SMUI 7 migrated to upstream MDC 14.0 from 13.0:
88
https://github.com/material-components/material-components-web/blob/master/CHANGELOG.md#1400-2022-04-27
99

10+
## Themes
11+
12+
I spent a day [flexing every graphic design muscle in my body](https://i.kym-cdn.com/entries/icons/original/000/018/929/graphic_design_is_my_passion.png), and made some THEMES! SMUI 7 can now be styled with a custom theme, the default theme, or [brand spanking new premade themes](https://sveltematerialui.com/INSTALL.md#a-premade-theme). This makes it much easier to get started with SMUI.
13+
1014
## Breaking Changes
1115

1216
- The `@smui/common/elements` components are gone. Just set the `tag` prop on components now (like `<Button tag="div">`).

THEMING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ You can [add Material typography](/TYPOGRAPHY.md) as the default for your app.
118118

119119
## Theming the Bare CSS
120120

121-
If you use the bare CSS, you can set a subset of the theme options with CSS variables. Note that not all of the colors in SMUI read from CSS variables, so some parts will still use the colors defined in the original Sass compile. Below is a copy of the variables from the CSS on the SMUI website. You can use this as a starting point for your own theme.
121+
If you use the bare CSS (or a premade theme), you can set a subset of the theme options with CSS variables. Note that not all of the colors in SMUI read from CSS variables, so some parts will still use the colors defined in the original Sass compile. Below is a copy of the variables from the CSS on the SMUI website. You can use this as a starting point for your own theme.
122122

123123
```css
124124
/* Theme colors. */

packages/site/src/routes/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
<path fill="currentColor" d={mdiPalette} />
139139
</Icon>
140140
</IconButton>
141-
<Tooltip>Pick a theme.</Tooltip>
141+
<Tooltip>Pick a theme or toggle dark mode.</Tooltip>
142142
</Wrapper>
143143
<Menu bind:this={themeMenu}>
144144
<List>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/themes

packages/svelte-material-ui/package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@
1212
"sveltejs"
1313
],
1414
"scripts": {
15-
"build": "smui-theme compile bare.css -i theme/ -i node_modules/",
15+
"build": "npm run build-bare && npm run build-svelte-light && npm run build-svelte-dark && npm run build-fixation-light && npm run build-fixation-dark && npm run build-material-light && npm run build-material-dark && npm run build-metro-light && npm run build-metro-dark && npm run build-unity-light && npm run build-unity-dark",
16+
"build-bare": "smui-theme compile bare.css -i theme/ -i node_modules/",
17+
"build-svelte-light": "smui-theme compile themes/svelte.css -s expanded -i ../site/src/theme -i node_modules/",
18+
"build-svelte-dark": "smui-theme compile themes/svelte-dark.css -s expanded -i ../site/src/theme/dark -i node_modules/",
19+
"build-fixation-light": "smui-theme compile themes/fixation.css -s expanded -i ../site/src/theme/fixation -i node_modules/",
20+
"build-fixation-dark": "smui-theme compile themes/fixation-dark.css -s expanded -i ../site/src/theme/fixation-dark -i node_modules/",
21+
"build-material-light": "smui-theme compile themes/material.css -s expanded -i ../site/src/theme/material -i node_modules/",
22+
"build-material-dark": "smui-theme compile themes/material-dark.css -s expanded -i ../site/src/theme/material-dark -i node_modules/",
23+
"build-metro-light": "smui-theme compile themes/metro.css -s expanded -i ../site/src/theme/metro -i node_modules/",
24+
"build-metro-dark": "smui-theme compile themes/metro-dark.css -s expanded -i ../site/src/theme/metro-dark -i node_modules/",
25+
"build-unity-light": "smui-theme compile themes/unity.css -s expanded -i ../site/src/theme/unity -i node_modules/",
26+
"build-unity-dark": "smui-theme compile themes/unity-dark.css -s expanded -i ../site/src/theme/unity-dark -i node_modules/",
1627
"clean": "git status --ignored -u --porcelain . | grep -v node_modules/ | grep -e '^!! ' | sed 's/^!! packages\\/[a-z-]*\\///g' | tr '\\n' ' ' | xargs rm",
1728
"prepare": "npm run build",
1829
"test": "echo \"Error: no test specified\" && exit 1"
1930
},
2031
"files": [
21-
"bare.css"
32+
"bare.css",
33+
"themes"
2234
],
2335
"publishConfig": {
2436
"access": "public"

0 commit comments

Comments
 (0)