generated from patoi/svelte-component-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.svelte
237 lines (209 loc) · 5.58 KB
/
App.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<script>
import Button from './Button/index.svelte'
import Icon from './Icon/index.svelte'
import Spacer from './Spacer/index.svelte'
import Text from './Text/index.svelte'
import TextInput from './TextInput/index.svelte'
let value = ''
</script>
<style>
:root {
--button-gap: 8px;
--button-padding: 8px;
--button-size: 48px;
--color-text-dimmed: #888888;
--spacer-size: var(--button-gap);
}
</style>
<ul>
<li>
<a href="#button">Button</a>
</li>
<li>
<a href="#icon">Icon</a>
</li>
<li>
<a href="#spacer">Spacer</a>
</li>
<li>
<a href="#text">Text</a>
</li>
<li>
<a href="#textinput">TextInput</a>
</li>
</ul>
<section section="button">
<h2>Button</h2>
<p>Depends on the following CSS variables:</p>
<dl>
<dt>
<code>--button-gap</code>
</dt>
<dd>
Gap between the different components inside the button, if there are
multiple.
</dd>
<dt>
<code>--button-padding</code>
</dt>
<dd>
Space on both sides of the button's content when
<code>relaxed</code>
.
</dd>
<dt>
<code>--button-size</code>
</dt>
<dd>Minimum size of the button.</dd>
</dl>
<h3>Default</h3>
<div id="button-default">
<Button title="Example button" onclick={() => alert('Example!')}>
<Text>Example</Text>
</Button>
</div>
<h3>With icons</h3>
<p>
<strong>Note:</strong>
Until the CSS property
<code>gap</code>
for Flexbox is
<a href="https://caniuse.com/#feat=flexbox-gap">better supported</a>
, buttons with multiple elements rely on
<a href="#spacer">
<code>Spacer</code>
</a>
to separate them.
</p>
<div id="button-icon">
<Button title="Example button" onclick={() => alert('Example!')}>
<Icon type="sun" size={24} />
</Button>
</div>
<div id="button-icon-text">
<Button title="Example button" onclick={() => alert('Example!')}>
<Icon type="moon" size={24} />
<Spacer />
<Text>Example</Text>
</Button>
</div>
<div id="button-text-icon">
<Button title="Example button" onclick={() => alert('Example!')}>
<Text>Example</Text>
<Spacer />
<Icon type="sun" size={24} />
</Button>
</div>
<h3>Relaxed</h3>
<div id="button-relaxed">
<Button
title="Example button"
onclick={() => alert('Example!')}
relaxed>
<Icon type="moon" size={24} />
<Spacer />
<Text>Example</Text>
</Button>
</div>
</section>
<section section="icon">
<h2>Icon</h2>
<p>
<strong>Important:</strong>
this component depends on a source of icons being accessible (e.g.
<code>public/icons.svg</code>
). The
<a href="https://feathericons.com">Feather icons download file</a>
can be used as a reference to create such a source of icons. The
<code>type</code>
of each icon matches the
<code>id</code>
of an SVG
<code>symbol</code>
inside that file.
</p>
<h3>Default</h3>
<div id="icon-default">
<Icon type="moon" />
</div>
<h3>Illustrative</h3>
<div id="icon-illustrative">
<Icon type="sun" illustrative={true} />
</div>
<h3>Custom size</h3>
<div id="icon-small">
<Icon type="moon" size={24} />
</div>
</section>
<section section="spacer">
<h2>Spacer</h2>
<p>
Allows to insert a space between other components when they are used in
another component `slot` and styling is not otherwise possible. Don't
over-use it!
</p>
<p>Depends on the following CSS variable:</p>
<dl>
<dt>
<code>--spacer-size</code>
</dt>
<dd>Width and height of the spacer.</dd>
</dl>
<h3>Default</h3>
<div id="spacer-default">
<Icon type="sun" />
<Icon type="sun" />
<Icon type="sun" />
<Spacer />
<Icon type="sun" />
</div>
</section>
<section section="text">
<h2>Text</h2>
<p>Depends on the following CSS variable:</p>
<dl>
<dt>
<code>--color-text-dimmed</code>
</dt>
<dd>
Color of the text when
<code>dimmed</code>
.
</dd>
</dl>
<h3>Default</h3>
<div id="text-default">
<Text>The quick brown fox jumps over the lazy dog.</Text>
</div>
<h3>Dimmed</h3>
<div id="text-dimmed">
<Text dimmed>The quick brown fox jumps over the lazy dog.</Text>
</div>
<h3>
Custom elements
<code>p</code>
</h3>
<div id="text-h1">
<Text element="h1">Quick brown fox</Text>
</div>
<div id="text-h2">
<Text element="h2">Lazy dog</Text>
</div>
<div id="text-p">
<Text element="p">The quick brown fox jumps over the lazy dog.</Text>
</div>
</section>
<section section="textinput">
<h2>TextInput</h2>
<h3>Default</h3>
<div id="textinput-default">
<TextInput
id="username"
label="Username <small>(required)</small>"
hint="This username is the one people will use to address messages
to you."
placeholder="dapper-drake"
bind:value
required />
</div>
</section>