Skip to content

Commit 3ec3e2d

Browse files
committed
docs: improvements for the readmes and the site structure and demos
1 parent d5ade30 commit 3ec3e2d

File tree

11 files changed

+224
-107
lines changed

11 files changed

+224
-107
lines changed

SVELTEKIT.md

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# SvelteKit Installation
22

3-
(You can also check out the [SvelteKit example repo](https://github.com/hperrin/smui-example-sveltekit).)
4-
53
You will need to install the packages you use individually as well as the theme package.
64

75
```sh
@@ -18,73 +16,72 @@ Create your theme files with `smui-theme`.
1816
npx smui-theme template src/theme
1917
```
2018

21-
You can [modify your theme variables](/THEMING.md#theme-variables) in the files now in `src/theme`.
19+
You can [modify your theme variables](/THEMING.md#theme-variables) in the files now in `src/theme` and `src/theme/dark`. You can also add the [Material typography styles](/TYPOGRAPHY.md).
2220

2321
## Theme Build Scripts
2422

25-
You'll need one of these sets of prepare scripts in your `package.json` file. Note that SvelteKit already provides a "prepare" script, so you'll need to modify it to look like below.
23+
You'll need one of these sets of prepare scripts in your `package.json` file.
2624

27-
- Without Dark Mode support.
25+
With Dark Mode support.
2826

29-
```
30-
"prepare": "npm run smui-theme",
31-
"smui-theme": "smui-theme compile static/smui.css -i src/theme"
32-
```
27+
```
28+
"prepare": "npm run smui-theme-light && npm run smui-theme-dark",
29+
"smui-theme-light": "smui-theme compile static/smui.css -i src/theme",
30+
"smui-theme-dark": "smui-theme compile static/smui-dark.css -i src/theme/dark"
31+
```
3332

34-
- With Dark Mode support.
33+
Or, without Dark Mode support.
3534

36-
```
37-
"prepare": "npm run smui-theme-light && npm run smui-theme-dark",
38-
"smui-theme-light": "smui-theme compile static/smui.css -i src/theme",
39-
"smui-theme-dark": "smui-theme compile static/smui-dark.css -i src/theme/dark"
40-
```
35+
```
36+
"prepare": "npm run smui-theme",
37+
"smui-theme": "smui-theme compile static/smui.css -i src/theme"
38+
```
4139

4240
## Stylesheets
4341

4442
Now in your `src/app.html` file, add the following to the `head` section:
4543

44+
With Dark Mode support.
45+
4646
```html
47-
<!-- Material Icons -->
48-
<link
49-
rel="stylesheet"
50-
href="https://fonts.googleapis.com/icon?family=Material+Icons"
51-
/>
52-
<!-- Roboto -->
53-
<link
54-
rel="stylesheet"
55-
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700"
56-
/>
57-
<!-- Roboto Mono -->
47+
<!-- SMUI Styles -->
48+
<link rel="stylesheet" href="/smui.css" media="(prefers-color-scheme: light)" />
5849
<link
5950
rel="stylesheet"
60-
href="https://fonts.googleapis.com/css?family=Roboto+Mono"
51+
href="/smui-dark.css"
52+
media="screen and (prefers-color-scheme: dark)"
6153
/>
6254
```
6355

64-
And this for without Dark Mode support.
56+
Or, without Dark Mode support.
6557

6658
```html
6759
<!-- SMUI Styles -->
6860
<link rel="stylesheet" href="/smui.css" />
6961
```
7062

71-
Or this for with Dark Mode support.
63+
### Fonts
64+
65+
Material uses the Roboto fonts, so include those as well. If you'd like to use the Material Icons font, include that as well.
7266

7367
```html
74-
<!-- SMUI Styles -->
75-
<link rel="stylesheet" href="/smui.css" media="(prefers-color-scheme: light)" />
68+
<!-- Material Icons -->
7669
<link
7770
rel="stylesheet"
78-
href="/smui-dark.css"
79-
media="screen and (prefers-color-scheme: dark)"
71+
href="https://fonts.googleapis.com/icon?family=Material+Icons"
72+
/>
73+
<!-- Roboto -->
74+
<link
75+
rel="stylesheet"
76+
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700"
77+
/>
78+
<!-- Roboto Mono -->
79+
<link
80+
rel="stylesheet"
81+
href="https://fonts.googleapis.com/css?family=Roboto+Mono"
8082
/>
8183
```
8284

83-
<small>
84-
<i style="font-size: 1em;" class="material-icons">info</i>
85-
Note: There used to be a Vite config step at this point, because SMUI was packaged incorrectly. It is now packaged correctly, so that's no longer required.
86-
</small>
87-
8885
## Finishing Up
8986

9087
After that, run `npm run prepare` to build your CSS file, then you can run `npm run dev` to start developing. Happy coding!

THEMING.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Theming with Sass
44

5+
If you're going to theme with Sass, reading an [introduction to Sass](https://sass-lang.com/guide) would be helpful. Hoever, you don't need to know much about Sass to make basic themes for SMUI.
6+
57
To create a custom Sass theme, install the SMUI Theme Builder.
68

79
```sh
@@ -14,32 +16,25 @@ You can use it to create your theme directory from a template. Adjust to your so
1416
npx smui-theme template src/theme
1517
```
1618

17-
This creates `_smui-theme.scss` files in `src/theme`. That is where you set the theme variables.
19+
This creates a `_smui-theme.scss` file in `src/theme` for light mode and an alternative `_smui-theme.scss` file in `src/theme/dark` for dark mode. That is where you set the theme variables.
1820

1921
### Building Your Theme
2022

2123
In your package.json file, add this script in the "scripts" section, adjusting the source/destination files as needed.
2224

23-
```
24-
"prepare": "smui-theme compile build/smui.css -i src/theme",
25-
```
26-
27-
Or for dark mode support.
28-
2925
```
3026
"prepare": "npm run smui-theme-light && npm run smui-theme-dark",
3127
"smui-theme-light": "smui-theme compile build/smui.css -i src/theme",
3228
"smui-theme-dark": "smui-theme compile build/smui-dark.css -i src/theme/dark",
3329
```
3430

35-
Now run `npm run prepare` to build the CSS file(s), then add it/them on your page. Something like this, adjusting the paths as needed.
31+
Or if you don't need dark mode support.
3632

37-
```html
38-
<!-- SMUI Styles -->
39-
<link rel="stylesheet" href="/smui.css" />
33+
```
34+
"prepare": "smui-theme compile build/smui.css -i src/theme",
4035
```
4136

42-
Or for dark mode support.
37+
Now run `npm run prepare` to build the CSS file(s), then add them on your page. Something like this, adjusting the paths as needed.
4338

4439
```html
4540
<!-- SMUI Styles -->
@@ -51,11 +46,20 @@ Or for dark mode support.
5146
/>
5247
```
5348

54-
Note: The smui-theme compiler will only include the Sass for the packages installed when it is run. If you install a new SMUI package, you should run `npm run prepare` to rebuild the CSS.
49+
Or if you don't need dark mode support.
50+
51+
```html
52+
<!-- SMUI Styles -->
53+
<link rel="stylesheet" href="/smui.css" />
54+
```
55+
56+
Important: The smui-theme compiler will only include the Sass for the packages installed when it is run. If you install a new SMUI package, you should run `npm run prepare` to rebuild the CSS.
5557

5658
### Theme Variables
5759

58-
You can check out the READMEs of [the MDC-Web components](https://github.com/material-components/material-components-web/tree/v14.0.0/packages) to learn how to deeply style the components. The most important part (and probably the only one you want) is setting the [theme colors](https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-theme#color-scheme). For the Material color palette, you can @use ["@material/theme/color-palette"](https://github.com/material-components/material-components-web/blob/v14.0.0/packages/mdc-theme/_color-palette.scss). You might also want to style the [border radius variables](https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-shape#sass-variables).
60+
The most important part of theming (and probably the only one you want) is setting the [theme colors](https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-theme#color-scheme). For the Material color palette, you can @use ["@material/theme/color-palette"](https://github.com/material-components/material-components-web/blob/v14.0.0/packages/mdc-theme/_color-palette.scss). You might also want to style the [border radius variables](https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-shape#sass-variables).
61+
62+
To learn how to deeply style the individual components, you can check out the READMEs of [the MDC-Web components](https://github.com/material-components/material-components-web/tree/v14.0.0/packages). If you need more help, check out the [theming guide](https://m2.material.io/develop/web/theming/theming-guide) on the MDC-Web website. SMUI uses all the styles from MDC-Web, so everything regarding Sass and CSS from that guide should work with SMUI.
5963

6064
Here is an example `_smui-theme.scss` file you can use as a starting point.
6165

@@ -102,12 +106,16 @@ Just make sure that you put that directly after the `@use '@material/theme/index
102106

103107
### Adding Classes and Variables
104108

105-
If you want to use MDC's classes and variables (like `var(--mdc-theme-primary)` and `class="mdc-theme--primary-bg"`), you can add the following line somewhere in your Sass files. A great place to add it is in your `_smui-theme.scss` file.
109+
If you want to use MDC's classes and variables (like `var(--mdc-theme-primary)` and `class="mdc-theme--primary-bg"`), you can add the following line somewhere in your Sass files. A great place to add it is in your `_smui-theme.scss` files.
106110

107111
```scss
108112
@use '@material/theme/styles';
109113
```
110114

115+
## Adding Material Typography
116+
117+
You can [add Material typography](/TYPOGRAPHY.md) as the default for your app.
118+
111119
## Theming the Bare CSS
112120

113121
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.

TYPOGRAPHY.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Material Typoography
2+
3+
If you'd like to style your entire app using Material's typography, you can add Sass like this to your `_smui-theme.scss` files.
4+
5+
```scss
6+
// Import the mixins.
7+
@use '@material/typography/index' as typography;
8+
9+
html {
10+
@include typography.typography('body1');
11+
}
12+
13+
h1 {
14+
@include typography.typography('headline1');
15+
}
16+
17+
h2 {
18+
@include typography.typography('headline2');
19+
}
20+
21+
h3 {
22+
@include typography.typography('headline3');
23+
}
24+
25+
h4 {
26+
@include typography.typography('headline4');
27+
}
28+
29+
h5 {
30+
@include typography.typography('headline5');
31+
}
32+
33+
h6 {
34+
@include typography.typography('headline6');
35+
}
36+
37+
caption {
38+
@include typography.typography('caption');
39+
}
40+
41+
code,
42+
pre {
43+
font-family: 'Roboto Mono', monospace;
44+
}
45+
46+
small {
47+
font-size: 0.9em;
48+
}
49+
50+
big {
51+
font-size: 1.1em;
52+
}
53+
54+
b,
55+
strong {
56+
font-weight: bold;
57+
}
58+
```

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

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -241,35 +241,20 @@
241241
separator: true,
242242
},
243243
{
244-
name: 'Accordion',
245-
route: '/demo/accordion/',
246-
indent: 0,
247-
repos: [
248-
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/accordion',
249-
],
250-
},
251-
{
252-
name: 'Badge',
253-
route: '/demo/badge/',
244+
name: 'Introduction',
245+
route: '/demo/introduction/',
254246
indent: 0,
255-
repos: [
256-
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/badge',
257-
],
258247
},
259248
{
260-
name: 'Banner',
261-
route: '/demo/banner/',
262-
indent: 0,
263-
repos: [
264-
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/banner',
265-
],
249+
name: 'sep2',
250+
separator: true,
266251
},
267252
{
268-
name: 'Bottom App Bar',
269-
route: '/demo/bottom-app-bar/',
253+
name: 'Accordion',
254+
route: '/demo/accordion/',
270255
indent: 0,
271256
repos: [
272-
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/bottom-app-bar',
257+
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/accordion',
273258
],
274259
},
275260
{
@@ -300,6 +285,42 @@
300285
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/icon-button',
301286
],
302287
},
288+
{
289+
name: 'App Bars',
290+
indent: 0,
291+
},
292+
{
293+
name: 'Bottom App Bar',
294+
route: '/demo/bottom-app-bar/',
295+
indent: 1,
296+
repos: [
297+
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/bottom-app-bar',
298+
],
299+
},
300+
{
301+
name: 'Top App Bar',
302+
route: '/demo/top-app-bar/',
303+
indent: 1,
304+
repos: [
305+
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/top-app-bar',
306+
],
307+
},
308+
{
309+
name: 'Badge',
310+
route: '/demo/badge/',
311+
indent: 0,
312+
repos: [
313+
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/badge',
314+
],
315+
},
316+
{
317+
name: 'Banner',
318+
route: '/demo/banner/',
319+
indent: 0,
320+
repos: [
321+
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/banner',
322+
],
323+
},
303324
{
304325
name: 'Cards',
305326
route: '/demo/card/',
@@ -531,14 +552,6 @@
531552
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/tooltip',
532553
],
533554
},
534-
{
535-
name: 'Top App Bar',
536-
route: '/demo/top-app-bar/',
537-
indent: 0,
538-
repos: [
539-
'https://github.com/hperrin/svelte-material-ui/tree/master/packages/top-app-bar',
540-
],
541-
},
542555
{
543556
name: 'Touch Target',
544557
route: '/demo/touch-target/',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<Content>
4848
Many SMUI components are based on <a
4949
style="color: #fff;"
50-
href="https://material.io/develop/web"
50+
href="https://github.com/material-components/material-components-web"
5151
target="_blank">Material Design Components for Web</a
5252
>, by Google. It integrates these components using the
5353
<a
@@ -223,7 +223,7 @@
223223
<SecondaryText style="white-space: normal;">
224224
With over <a
225225
href="https://github.com/hperrin/svelte-material-ui/network/dependents?package_id=UGFja2FnZS01NTM5MDg5MDQ"
226-
target="_blank">1700 projects</a
226+
target="_blank">2200 projects</a
227227
> using SMUI components, it is the most popular Svelte UI library.
228228
For good reason, too. It is the most versatile and adaptable Svelte
229229
UI library, guaranteed.
@@ -285,7 +285,7 @@
285285
<a href="https://github.com/hperrin/svelte-material-ui/issues"
286286
>Issue Tracker</a
287287
>
288-
| &copy; 2022 Hunter Perrin ]
288+
| &copy; 2019-2023 Hunter Perrin ]
289289
</p>
290290
</div>
291291
</section>

0 commit comments

Comments
 (0)