Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit 56baac3

Browse files
docs: better usage advice
Signed-off-by: Florian-Schoenherr <[email protected]>
1 parent 15a9636 commit 56baac3

File tree

2 files changed

+56
-47
lines changed

2 files changed

+56
-47
lines changed

packages/docs/src/routes/getting-started/installation.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ If you want a fast and basic setup, without custom SCSS/SASS, then only installi
2828
$ npm i svelte-materialify
2929
```
3030

31-
In your svelte files, import the _compiled_ module `from 'svelte-materialify'`:
32-
33-
```html
34-
<script>
35-
// Import Everything
36-
import * as S from 'svelte-materialify';
37-
// or...
38-
// Import a single component
39-
import { Button } from 'svelte-materialify';
40-
</script>
41-
```
42-
4331
## Install with Custom Styles
4432

4533
If you want finer control over Svelte Materialify, install all its peer dependencies:
@@ -48,18 +36,6 @@ If you want finer control over Svelte Materialify, install all its peer dependen
4836
$ npm i -D svelte-materialify svelte-preprocess sass postcss
4937
```
5038

51-
In your svelte files, import the _uncompiled_ module `from 'svelte-materialify/src'`:
52-
53-
```html
54-
<script>
55-
// Import Everything
56-
import * as S from 'svelte-materialify/src';
57-
// or...
58-
// Import a single component
59-
import { Button } from 'svelte-materialify/src';
60-
</script>
61-
```
62-
6339
Now create a **\_material-theme.scss** file. Let's put it in a folder called **theme**.
6440
Include the folder path in the `sveltePreprocess` function in your **rollup.config.js**:
6541

packages/docs/src/routes/getting-started/usage.md

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,45 @@ related:
99

1010
# Usage
1111

12-
Once you have installed Svelte Materialify and other dependencies, it is time to learn how to use it.
12+
Once you have installed Svelte Materialify, it's time to learn how to use it.
1313

14+
## Importing the Components
15+
Depending on the Install you chose, there are two ways to import:
16+
### With Default styles
17+
18+
In your svelte files, import the _compiled_ module `from 'svelte-materialify'`:
19+
20+
```html
21+
<script>
22+
import { MaterialApp, Button } from 'svelte-materialify';
23+
</script>
24+
25+
<MaterialApp>
26+
<Button>Compiled (Default styles, used in the REPL)</Button>
27+
</MaterialApp>
28+
```
29+
### With Custom styles
30+
31+
In your svelte files, import the _uncompiled_ module `from 'svelte-materialify/src'`:
32+
33+
```html
34+
<script>
35+
import { MaterialApp, Button } from 'svelte-materialify/src';
36+
//this works, too:
37+
import Button from 'svelte-materialify/src/components/Button/Button.svelte';
38+
</script>
39+
40+
<MaterialApp>
41+
<Button>Uncompiled (Custom styles, defined in _material-theme.scss)</Button>
42+
</MaterialApp>
43+
```
1444
## Layout
1545

16-
All components should be children of `MaterialApp` which has all the global styles and
17-
enables theming.
46+
All components should be children of `MaterialApp`, which has all the **global styles** and enables theming:
1847

1948
```html
2049
<script>
21-
import { MaterialApp } from 'svelte-materialify';
50+
import { MaterialApp } from 'svelte-materialify'; //or from `/src`
2251
let theme = 'light';
2352
</script>
2453

@@ -27,39 +56,43 @@ enables theming.
2756
</MaterialApp>
2857
```
2958

59+
If you don't want any global styles (other than theming and colors), you can use `MaterialAppMin` instead:
60+
61+
```html
62+
<script>
63+
import { MaterialAppMin } from 'svelte-materialify'; //or from `/src`
64+
let theme = 'light';
65+
</script>
66+
67+
<MaterialAppMin theme="{theme}">
68+
<slot />
69+
</MaterialAppMin>
70+
```
71+
3072
## Theming
3173

32-
What to customise some SCSS variables, worry not, just put them in the **\_material-theme.scss** you had created.
74+
You want to customise some SCSS variables? Worry not, just put them in the **\_material-theme.scss** you had created:
3375

3476
```scss
77+
$primary-color: #004d26;
78+
$secondary-color: #ff99cc;
79+
$error-color: #420420;
80+
$success-color: #66ff99;
81+
3582
$body-font-family: "Poppins", "Segoe UI", sans-serif;
3683

3784
$spacer: 6px !default;
3885
...
3986
```
4087

41-
To access these variables in your own components just import the variable file from svelte materialify.
88+
To access these variables in your own components, just import the variable file from svelte materialify:
4289

4390
```scss
4491
@import 'svelte-materialify/src/styles/variables';
4592
```
4693

47-
## Components
48-
49-
Just import them one by one or all at once from svelte materialify.
50-
51-
```html
52-
<script>
53-
import * as S from 'svelte-materialify';
54-
55-
import { Button } from 'svelte-materialify';
56-
// OR import from source
57-
import { Button } from 'svelte-materialify/src';
58-
// OR directly import the button component
59-
import Button from 'svelte-materialify/src/components/Button/index.js';
60-
</script>
94+
<Components.Alert type='info'>
6195

62-
<S.Button>These Are</S.Button>
96+
If you want to use SCSS and SASS styles in your own components, [use svelte-preprocess](https://github.com/sveltejs/svelte-preprocess/blob/master/docs/usage.md).
6397

64-
<button>The Same Thing</button>
65-
```
98+
</Components.Alert>

0 commit comments

Comments
 (0)