@@ -9,16 +9,45 @@ related:
9
9
10
10
# Usage
11
11
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.
13
13
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
+ ```
14
44
## Layout
15
45
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:
18
47
19
48
``` html
20
49
<script >
21
- import { MaterialApp } from ' svelte-materialify' ;
50
+ import { MaterialApp } from ' svelte-materialify' ; // or from `/src`
22
51
let theme = ' light' ;
23
52
</script >
24
53
@@ -27,39 +56,43 @@ enables theming.
27
56
</MaterialApp >
28
57
```
29
58
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
+
30
72
## Theming
31
73
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:
33
75
34
76
``` scss
77
+ $primary-color : #004d26 ;
78
+ $secondary-color : #ff99cc ;
79
+ $error-color : #420420 ;
80
+ $success-color : #66ff99 ;
81
+
35
82
$body-font-family : " Poppins" , " Segoe UI" , sans-serif ;
36
83
37
84
$spacer : 6px !default ;
38
85
...
39
86
```
40
87
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:
42
89
43
90
``` scss
44
91
@import ' svelte-materialify/src/styles/variables' ;
45
92
```
46
93
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'>
61
95
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 ) .
63
97
64
- <button >The Same Thing</button >
65
- ```
98
+ </Components.Alert>
0 commit comments