@14ch/svelte-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +359 -0
- package/dist/assets/styles/README.md +144 -0
- package/dist/assets/styles/core.scss +61 -0
- package/dist/assets/styles/import.scss +11 -0
- package/dist/assets/styles/optional/fonts.scss +23 -0
- package/dist/assets/styles/optional/reset.scss +230 -0
- package/dist/assets/styles/variables.scss +805 -0
- package/dist/components/Button.svelte +574 -0
- package/dist/components/Button.svelte.d.ts +56 -0
- package/dist/components/COMPONENT_DESIGN_GUIDELINES.md +127 -0
- package/dist/components/Checkbox.svelte +523 -0
- package/dist/components/Checkbox.svelte.d.ts +42 -0
- package/dist/components/CheckboxGroup.svelte +82 -0
- package/dist/components/CheckboxGroup.svelte.d.ts +13 -0
- package/dist/components/ColorPicker.svelte +496 -0
- package/dist/components/ColorPicker.svelte.d.ts +45 -0
- package/dist/components/Combobox.svelte +576 -0
- package/dist/components/Combobox.svelte.d.ts +52 -0
- package/dist/components/ConfirmDialog.svelte +116 -0
- package/dist/components/ConfirmDialog.svelte.d.ts +20 -0
- package/dist/components/Datepicker.svelte +578 -0
- package/dist/components/Datepicker.svelte.d.ts +72 -0
- package/dist/components/DatepickerCalendar.svelte +925 -0
- package/dist/components/DatepickerCalendar.svelte.d.ts +31 -0
- package/dist/components/Dialog.svelte +245 -0
- package/dist/components/Dialog.svelte.d.ts +38 -0
- package/dist/components/Drawer.svelte +383 -0
- package/dist/components/Drawer.svelte.d.ts +39 -0
- package/dist/components/Fab.svelte +486 -0
- package/dist/components/Fab.svelte.d.ts +51 -0
- package/dist/components/FileUploader.svelte +456 -0
- package/dist/components/FileUploader.svelte.d.ts +36 -0
- package/dist/components/Icon.svelte +167 -0
- package/dist/components/Icon.svelte.d.ts +21 -0
- package/dist/components/IconButton.svelte +557 -0
- package/dist/components/IconButton.svelte.d.ts +60 -0
- package/dist/components/ImageUploader.svelte +516 -0
- package/dist/components/ImageUploader.svelte.d.ts +37 -0
- package/dist/components/ImageUploaderPreview.svelte +157 -0
- package/dist/components/ImageUploaderPreview.svelte.d.ts +13 -0
- package/dist/components/Input.svelte +885 -0
- package/dist/components/Input.svelte.d.ts +75 -0
- package/dist/components/LoadingSpinner.svelte +116 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +10 -0
- package/dist/components/Modal.svelte +313 -0
- package/dist/components/Modal.svelte.d.ts +34 -0
- package/dist/components/Pagination.svelte +276 -0
- package/dist/components/Pagination.svelte.d.ts +14 -0
- package/dist/components/Popup.svelte +676 -0
- package/dist/components/Popup.svelte.d.ts +40 -0
- package/dist/components/PopupMenu.svelte +421 -0
- package/dist/components/PopupMenu.svelte.d.ts +24 -0
- package/dist/components/PopupMenuButton.svelte +365 -0
- package/dist/components/PopupMenuButton.svelte.d.ts +42 -0
- package/dist/components/Radio.svelte +548 -0
- package/dist/components/Radio.svelte.d.ts +42 -0
- package/dist/components/RadioGroup.svelte +74 -0
- package/dist/components/RadioGroup.svelte.d.ts +14 -0
- package/dist/components/Select.svelte +479 -0
- package/dist/components/Select.svelte.d.ts +47 -0
- package/dist/components/Slider.svelte +473 -0
- package/dist/components/Slider.svelte.d.ts +46 -0
- package/dist/components/Snackbar.svelte +124 -0
- package/dist/components/Snackbar.svelte.d.ts +9 -0
- package/dist/components/SnackbarItem.svelte +423 -0
- package/dist/components/SnackbarItem.svelte.d.ts +21 -0
- package/dist/components/Switch.svelte +454 -0
- package/dist/components/Switch.svelte.d.ts +40 -0
- package/dist/components/Tab.svelte +193 -0
- package/dist/components/Tab.svelte.d.ts +14 -0
- package/dist/components/TabItem.svelte +140 -0
- package/dist/components/TabItem.svelte.d.ts +17 -0
- package/dist/components/Textarea.svelte +702 -0
- package/dist/components/Textarea.svelte.d.ts +64 -0
- package/dist/components/skeleton/Skeleton.svelte +235 -0
- package/dist/components/skeleton/Skeleton.svelte.d.ts +13 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte +97 -0
- package/dist/components/skeleton/SkeletonAvatar.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonBox.svelte +105 -0
- package/dist/components/skeleton/SkeletonBox.svelte.d.ts +12 -0
- package/dist/components/skeleton/SkeletonButton.svelte +71 -0
- package/dist/components/skeleton/SkeletonButton.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonHeading.svelte +49 -0
- package/dist/components/skeleton/SkeletonHeading.svelte.d.ts +8 -0
- package/dist/components/skeleton/SkeletonMedia.svelte +115 -0
- package/dist/components/skeleton/SkeletonMedia.svelte.d.ts +9 -0
- package/dist/components/skeleton/SkeletonText.svelte +75 -0
- package/dist/components/skeleton/SkeletonText.svelte.d.ts +8 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +43 -0
- package/dist/types/icon.d.ts +4 -0
- package/dist/types/icon.js +2 -0
- package/dist/types/menuItem.d.ts +8 -0
- package/dist/types/menuItem.js +1 -0
- package/dist/types/options.d.ts +6 -0
- package/dist/types/options.js +4 -0
- package/dist/types/skeleton.d.ts +77 -0
- package/dist/types/skeleton.js +19 -0
- package/dist/utils/accessibility.d.ts +48 -0
- package/dist/utils/accessibility.js +87 -0
- package/dist/utils/formatText.d.ts +4 -0
- package/dist/utils/formatText.js +44 -0
- package/dist/utils/mobile.d.ts +9 -0
- package/dist/utils/mobile.js +47 -0
- package/dist/utils/snackbar.svelte.d.ts +51 -0
- package/dist/utils/snackbar.svelte.js +107 -0
- package/dist/utils/style.d.ts +17 -0
- package/dist/utils/style.js +22 -0
- package/package.json +102 -0
package/README.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# Svelte UI
|
|
2
|
+
|
|
3
|
+
A Svelte component library with TypeScript support and Material Design-inspired styling.
|
|
4
|
+
|
|
5
|
+
> **⚠️ Preview Release**: This library is in preview. APIs may change before the stable 1.0 release.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Material Design-inspired components
|
|
10
|
+
- ARIA support and keyboard navigation
|
|
11
|
+
- Touch-optimized for mobile devices
|
|
12
|
+
- Dark mode and high contrast mode support
|
|
13
|
+
- TypeScript definitions included
|
|
14
|
+
- Tree-shakeable ES modules
|
|
15
|
+
- Built with Svelte 5 runes API
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @14ch/svelte-ui
|
|
21
|
+
# or
|
|
22
|
+
pnpm add @14ch/svelte-ui
|
|
23
|
+
# or
|
|
24
|
+
yarn add @14ch/svelte-ui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Setup
|
|
28
|
+
|
|
29
|
+
### 1. Import Styles
|
|
30
|
+
|
|
31
|
+
**Important**: You must import the CSS styles for the components to work properly.
|
|
32
|
+
|
|
33
|
+
Add this to your main app file (e.g., `app.html`, `+layout.svelte`, or `main.js`):
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
// Import all necessary styles (recommended)
|
|
37
|
+
import '@14ch/svelte-ui/styles';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or import individual style files:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
// Core styles (required)
|
|
44
|
+
import '@14ch/svelte-ui/styles/variables.scss';
|
|
45
|
+
import '@14ch/svelte-ui/styles/core.scss';
|
|
46
|
+
|
|
47
|
+
// Optional styles
|
|
48
|
+
import '@14ch/svelte-ui/styles/optional/fonts.scss'; // Material Symbols font
|
|
49
|
+
import '@14ch/svelte-ui/styles/optional/reset.scss'; // CSS reset
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Basic Usage
|
|
53
|
+
|
|
54
|
+
```svelte
|
|
55
|
+
<script>
|
|
56
|
+
import { Button, Input, Dialog } from '@14ch/svelte-ui';
|
|
57
|
+
|
|
58
|
+
let dialogRef;
|
|
59
|
+
let inputValue = $state('');
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<Input bind:value={inputValue} placeholder="Enter your name" />
|
|
63
|
+
|
|
64
|
+
<Button onclick={() => dialogRef.open()}>Open Dialog</Button>
|
|
65
|
+
|
|
66
|
+
<Dialog bind:this={dialogRef} title="Greeting">
|
|
67
|
+
<p>Hello {inputValue}!</p>
|
|
68
|
+
<p>Welcome to Svelte UI Component Library.</p>
|
|
69
|
+
{#snippet footer()}
|
|
70
|
+
<Button onclick={() => dialogRef.close()}>Close</Button>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</Dialog>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Available Components
|
|
76
|
+
|
|
77
|
+
### Form Components
|
|
78
|
+
|
|
79
|
+
- `Button` - Various button styles and states
|
|
80
|
+
- `Input` - Text input with validation support
|
|
81
|
+
- `Textarea` - Multi-line text input
|
|
82
|
+
- `Checkbox` - Checkbox with custom styling
|
|
83
|
+
- `CheckboxGroup` - Multiple checkbox selection group
|
|
84
|
+
- `Radio` - Radio button groups
|
|
85
|
+
- `RadioGroup` - Radio button group wrapper
|
|
86
|
+
- `Select` - Dropdown selection
|
|
87
|
+
- `Combobox` - Searchable dropdown
|
|
88
|
+
- `Slider` - Range slider input
|
|
89
|
+
- `Switch` - Toggle switch
|
|
90
|
+
- `ColorPicker` - Color selection input
|
|
91
|
+
- `Datepicker` - Date selection with calendar
|
|
92
|
+
- `FileUploader` - File upload with drag & drop
|
|
93
|
+
- `ImageUploader` - Image upload with preview
|
|
94
|
+
|
|
95
|
+
### Layout & Navigation
|
|
96
|
+
|
|
97
|
+
- `Tab` / `TabItem` - Tab navigation
|
|
98
|
+
- `Pagination` - Page navigation
|
|
99
|
+
|
|
100
|
+
### Modals
|
|
101
|
+
|
|
102
|
+
- `Dialog` - Modal dialogs
|
|
103
|
+
- `ConfirmDialog` - Confirmation dialogs
|
|
104
|
+
- `Drawer` - Side drawer
|
|
105
|
+
|
|
106
|
+
### Popups & Menus
|
|
107
|
+
|
|
108
|
+
- `Popup` - Popover content
|
|
109
|
+
- `PopupMenu` / `PopupMenuButton` - Context menus
|
|
110
|
+
|
|
111
|
+
### Notifications & Feedback
|
|
112
|
+
|
|
113
|
+
- `Snackbar` / `SnackbarItem` - Toast notifications
|
|
114
|
+
- `LoadingSpinner` - Loading indicators
|
|
115
|
+
|
|
116
|
+
### Skeleton Loaders
|
|
117
|
+
|
|
118
|
+
- `Skeleton` - Loading placeholders with preset patterns
|
|
119
|
+
|
|
120
|
+
### Icons & Buttons
|
|
121
|
+
|
|
122
|
+
- `Icon` - Material Symbols icons
|
|
123
|
+
- `IconButton` - Icon-based buttons
|
|
124
|
+
- `Fab` - Floating Action Button
|
|
125
|
+
|
|
126
|
+
## Component Examples
|
|
127
|
+
|
|
128
|
+
### Button Variants
|
|
129
|
+
|
|
130
|
+
```svelte
|
|
131
|
+
<script>
|
|
132
|
+
import { Button } from '@14ch/svelte-ui';
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<!-- Different variants -->
|
|
136
|
+
<Button variant="filled">Filled Button</Button>
|
|
137
|
+
<Button variant="outlined">Outlined Button</Button>
|
|
138
|
+
<Button variant="text">Text Button</Button>
|
|
139
|
+
|
|
140
|
+
<!-- With icons -->
|
|
141
|
+
<Button icon="add">Add Item</Button>
|
|
142
|
+
|
|
143
|
+
<!-- Different sizes -->
|
|
144
|
+
<Button size="small">Small</Button>
|
|
145
|
+
<Button size="medium">Medium</Button>
|
|
146
|
+
<Button size="large">Large</Button>
|
|
147
|
+
|
|
148
|
+
<!-- States -->
|
|
149
|
+
<Button disabled>Disabled</Button>
|
|
150
|
+
<Button loading>Loading...</Button>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Form Validation
|
|
154
|
+
|
|
155
|
+
```svelte
|
|
156
|
+
<script>
|
|
157
|
+
import { Input, Checkbox, Button } from '@14ch/svelte-ui';
|
|
158
|
+
|
|
159
|
+
let email = $state('');
|
|
160
|
+
let password = $state('');
|
|
161
|
+
let agreed = $state(false);
|
|
162
|
+
|
|
163
|
+
const handleSubmit = () => {
|
|
164
|
+
if (!email || !password || !agreed) {
|
|
165
|
+
alert('Please fill all fields');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// Handle form submission
|
|
169
|
+
};
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<Input bind:value={email} type="email" placeholder="Email" required />
|
|
173
|
+
|
|
174
|
+
<Input bind:value={password} type="password" placeholder="Password" required />
|
|
175
|
+
|
|
176
|
+
<Checkbox bind:value={agreed}>I agree to the terms and conditions</Checkbox>
|
|
177
|
+
|
|
178
|
+
<Button onclick={handleSubmit} disabled={!agreed}>Sign Up</Button>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Checkbox & Radio Groups
|
|
182
|
+
|
|
183
|
+
```svelte
|
|
184
|
+
<script>
|
|
185
|
+
import { CheckboxGroup, RadioGroup } from '@14ch/svelte-ui';
|
|
186
|
+
|
|
187
|
+
const options = [
|
|
188
|
+
{ label: 'Option 1', value: 'opt1' },
|
|
189
|
+
{ label: 'Option 2', value: 'opt2' },
|
|
190
|
+
{ label: 'Option 3', value: 'opt3' }
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
let selectedCheckboxes = $state([]);
|
|
194
|
+
let selectedRadio = $state(null);
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<CheckboxGroup bind:value={selectedCheckboxes} {options} direction="vertical" gap="16px" />
|
|
198
|
+
|
|
199
|
+
<RadioGroup bind:value={selectedRadio} {options} direction="horizontal" gap="24px" />
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Skeleton Loaders
|
|
203
|
+
|
|
204
|
+
```svelte
|
|
205
|
+
<script>
|
|
206
|
+
import { Skeleton, SkeletonBox, SkeletonText, SkeletonAvatar } from '@14ch/svelte-ui';
|
|
207
|
+
</script>
|
|
208
|
+
|
|
209
|
+
<!-- Using preset patterns -->
|
|
210
|
+
<Skeleton patterns={[{ type: 'article-list' }]} repeat={3} />
|
|
211
|
+
<Skeleton patterns={[{ type: 'product-list' }]} repeat={4} />
|
|
212
|
+
|
|
213
|
+
<!-- Using individual components for custom layouts -->
|
|
214
|
+
<div>
|
|
215
|
+
<SkeletonAvatar showName={true} />
|
|
216
|
+
<SkeletonBox width="100%" height="200px" />
|
|
217
|
+
<SkeletonText lines={3} />
|
|
218
|
+
</div>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Dialog with Confirmation
|
|
222
|
+
|
|
223
|
+
```svelte
|
|
224
|
+
<script>
|
|
225
|
+
import { Button, ConfirmDialog } from '@14ch/svelte-ui';
|
|
226
|
+
|
|
227
|
+
let confirmDialogRef;
|
|
228
|
+
|
|
229
|
+
const handleDelete = () => {
|
|
230
|
+
confirmDialogRef.open();
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const onConfirm = () => {
|
|
234
|
+
// Delete logic here
|
|
235
|
+
console.log('Item deleted');
|
|
236
|
+
confirmDialogRef.close();
|
|
237
|
+
};
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<Button variant="outlined" onclick={handleDelete}>Delete Item</Button>
|
|
241
|
+
|
|
242
|
+
<ConfirmDialog
|
|
243
|
+
bind:this={confirmDialogRef}
|
|
244
|
+
title="Confirm Delete"
|
|
245
|
+
message="Are you sure you want to delete this item? This action cannot be undone."
|
|
246
|
+
onconfirm={onConfirm}
|
|
247
|
+
oncancel={() => confirmDialogRef.close()}
|
|
248
|
+
/>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Dark Theme
|
|
252
|
+
|
|
253
|
+
Apply dark mode by setting the `data-theme` attribute:
|
|
254
|
+
|
|
255
|
+
```svelte
|
|
256
|
+
<script>
|
|
257
|
+
import { Button } from '@14ch/svelte-ui';
|
|
258
|
+
import { onMount } from 'svelte';
|
|
259
|
+
|
|
260
|
+
let theme = $state('light');
|
|
261
|
+
|
|
262
|
+
const toggleTheme = () => {
|
|
263
|
+
theme = theme === 'light' ? 'dark' : 'light';
|
|
264
|
+
document.body.setAttribute('data-theme', theme);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
onMount(() => {
|
|
268
|
+
document.body.setAttribute('data-theme', theme);
|
|
269
|
+
});
|
|
270
|
+
</script>
|
|
271
|
+
|
|
272
|
+
<Button onclick={toggleTheme}>Toggle Theme</Button>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
You can also apply dark mode to specific sections:
|
|
276
|
+
|
|
277
|
+
```svelte
|
|
278
|
+
<div data-theme="dark">
|
|
279
|
+
<!-- This section and its children will use dark mode -->
|
|
280
|
+
<Button>Dark Mode Button</Button>
|
|
281
|
+
</div>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Customization
|
|
285
|
+
|
|
286
|
+
### CSS Custom Properties
|
|
287
|
+
|
|
288
|
+
The library uses CSS custom properties for easy theming:
|
|
289
|
+
|
|
290
|
+
```css
|
|
291
|
+
:root {
|
|
292
|
+
--svelte-ui-primary-color: #1976d2;
|
|
293
|
+
--svelte-ui-surface-color: #ffffff;
|
|
294
|
+
--svelte-ui-text-color: #1f1f1f;
|
|
295
|
+
--svelte-ui-border-radius: 8px;
|
|
296
|
+
/* ... and many more */
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Customizing Dark Mode Colors
|
|
301
|
+
|
|
302
|
+
You can customize dark mode colors by overriding CSS variables:
|
|
303
|
+
|
|
304
|
+
```css
|
|
305
|
+
[data-theme='dark'] {
|
|
306
|
+
--svelte-ui-primary-color: #90caf9;
|
|
307
|
+
--svelte-ui-surface-color: #121212;
|
|
308
|
+
--svelte-ui-text-color: #ffffff;
|
|
309
|
+
/* ... customize other colors as needed */
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## TypeScript Support
|
|
314
|
+
|
|
315
|
+
All components come with full TypeScript definitions:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import type { MenuItem } from '@14ch/svelte-ui';
|
|
319
|
+
|
|
320
|
+
const menuItems: MenuItem[] = [
|
|
321
|
+
{ title: 'Home', href: '/' },
|
|
322
|
+
{ title: 'About', href: '/about' },
|
|
323
|
+
{ title: 'Contact', href: '/contact' }
|
|
324
|
+
];
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Accessibility
|
|
328
|
+
|
|
329
|
+
This library is built with accessibility in mind:
|
|
330
|
+
|
|
331
|
+
- Proper ARIA attributes
|
|
332
|
+
- Keyboard navigation support
|
|
333
|
+
- Screen reader announcements
|
|
334
|
+
- Focus management
|
|
335
|
+
- High contrast mode support
|
|
336
|
+
|
|
337
|
+
## Browser Support
|
|
338
|
+
|
|
339
|
+
- Chrome/Edge 88+
|
|
340
|
+
- Firefox 78+
|
|
341
|
+
- Safari 14+
|
|
342
|
+
|
|
343
|
+
## License
|
|
344
|
+
|
|
345
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
346
|
+
|
|
347
|
+
## Changelog
|
|
348
|
+
|
|
349
|
+
### v0.0.1
|
|
350
|
+
|
|
351
|
+
- Initial release
|
|
352
|
+
- 40+ components (Button, Input, Dialog, Skeleton loaders, etc.)
|
|
353
|
+
- CheckboxGroup and RadioGroup
|
|
354
|
+
- Skeleton component with preset patterns
|
|
355
|
+
- Material Design-inspired styling
|
|
356
|
+
- TypeScript support
|
|
357
|
+
- ARIA, keyboard navigation, screen reader support
|
|
358
|
+
- High contrast mode support
|
|
359
|
+
- Svelte 5 runes API
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Svelte UI Library Styles
|
|
2
|
+
|
|
3
|
+
この svelte-ui ライブラリは、ライブラリユーザーのスタイルとの競合を避けるために、スタイルを **必須スタイル** と **オプションスタイル** に分離しています。
|
|
4
|
+
|
|
5
|
+
## 🎯 変更点
|
|
6
|
+
|
|
7
|
+
- **v0.0.1** から、ライブラリのindex.tsでは必須スタイルのみを自動読み込み
|
|
8
|
+
- リセットCSSやフォントなどは **オプション** として分離
|
|
9
|
+
- ユーザーが必要に応じて選択的に読み込み可能
|
|
10
|
+
|
|
11
|
+
## 📁 ファイル構成
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
dist/assets/styles/
|
|
15
|
+
├── core.scss # 🔴 必須 - コンポーネント動作に必要
|
|
16
|
+
├── variables.scss # 🔴 必須 - CSS変数
|
|
17
|
+
|
|
18
|
+
├── import.scss # 🔴 必須 - 上記2つをまとめて読み込み
|
|
19
|
+
└── optional/
|
|
20
|
+
├── reset.scss # 🔵 オプション - リセットCSS
|
|
21
|
+
└── fonts.scss # 🔵 オプション - フォント読み込み
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 🔴 必須スタイル(自動読み込み)
|
|
25
|
+
|
|
26
|
+
これらのスタイルは、ライブラリをインポートすると自動的に読み込まれます:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// ライブラリをインポートするだけで必須スタイルが読み込まれる
|
|
30
|
+
import { Button } from 'svelte-ui';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 含まれる内容
|
|
34
|
+
|
|
35
|
+
- **Box-sizing**: `box-sizing: border-box` の設定(全コンポーネント)
|
|
36
|
+
- **Button reset**: button要素のブラウザデフォルトスタイルをリセット(Button, IconButton, Fab等)
|
|
37
|
+
- **Dialog reset**: dialog要素の基本スタイル(Dialog, Drawer等)
|
|
38
|
+
- **Form elements**: input autofill、label等の調整(Input, Textarea, Checkbox, Radio等)
|
|
39
|
+
- **Accessibility**: `.sr-only` クラス(PopupMenu等で使用)
|
|
40
|
+
- **CSS variables**: 全コンポーネントで使用される変数
|
|
41
|
+
- **Material Icons**: アイコンフォントの設定
|
|
42
|
+
|
|
43
|
+
## 🔵 オプションスタイル(選択読み込み)
|
|
44
|
+
|
|
45
|
+
必要に応じて、以下のスタイルを選択的に読み込むことができます:
|
|
46
|
+
|
|
47
|
+
### 1. リセットCSS
|
|
48
|
+
|
|
49
|
+
```scss
|
|
50
|
+
// Eric Meyer's CSS Reset + 基本的なレイアウト設定
|
|
51
|
+
@import 'svelte-ui/dist/assets/styles/optional/reset.scss';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. フォント
|
|
55
|
+
|
|
56
|
+
```scss
|
|
57
|
+
// Google Fonts (Roboto, Noto Sans JP) + YakuHanJP
|
|
58
|
+
@import 'svelte-ui/dist/assets/styles/optional/fonts.scss';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 🚀 使用例
|
|
62
|
+
|
|
63
|
+
### 最小構成(必須スタイルのみ)
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// main.ts または app.ts
|
|
67
|
+
import { Button, Input, Dialog } from 'svelte-ui';
|
|
68
|
+
|
|
69
|
+
// 必須スタイルは自動的に読み込まれる
|
|
70
|
+
// 自分のリセットCSSやフォントを使用可能
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 標準構成(オプションスタイルも使用)
|
|
74
|
+
|
|
75
|
+
```scss
|
|
76
|
+
// app.scss
|
|
77
|
+
// 必須スタイルは自動読み込みされているので、オプションのみ追加
|
|
78
|
+
@import 'svelte-ui/dist/assets/styles/optional/reset.scss';
|
|
79
|
+
@import 'svelte-ui/dist/assets/styles/optional/fonts.scss';
|
|
80
|
+
|
|
81
|
+
// 自分のスタイル
|
|
82
|
+
body {
|
|
83
|
+
background-color: #f0f0f0;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 部分的な使用
|
|
88
|
+
|
|
89
|
+
```scss
|
|
90
|
+
// app.scss
|
|
91
|
+
// 自分のリセットCSSを使用し、フォントだけライブラリのものを使用
|
|
92
|
+
@import 'svelte-ui/dist/assets/styles/optional/fonts.scss';
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 🔄 移行ガイド
|
|
96
|
+
|
|
97
|
+
### 旧バージョンからの移行
|
|
98
|
+
|
|
99
|
+
以前のバージョンではリセットCSSが自動的に読み込まれていました。同じ動作を維持したい場合:
|
|
100
|
+
|
|
101
|
+
```scss
|
|
102
|
+
// app.scss
|
|
103
|
+
@import 'svelte-ui/dist/assets/styles/optional/reset.scss';
|
|
104
|
+
@import 'svelte-ui/dist/assets/styles/optional/fonts.scss';
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 競合を避けたい場合
|
|
108
|
+
|
|
109
|
+
```scss
|
|
110
|
+
// 必須スタイルは自動読み込みされるので、何もしなくてOK
|
|
111
|
+
// 自分のリセットCSSやフォントを使用してください
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 🎨 カスタマイズ
|
|
115
|
+
|
|
116
|
+
CSS変数を上書きすることで、簡単にテーマをカスタマイズできます:
|
|
117
|
+
|
|
118
|
+
```scss
|
|
119
|
+
// カスタムテーマ
|
|
120
|
+
:root {
|
|
121
|
+
--svelte-ui-primary-color: #ff6b6b;
|
|
122
|
+
--svelte-ui-button-border-radius: 8px;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 🔧 トラブルシューティング
|
|
127
|
+
|
|
128
|
+
### スタイルが適用されない場合
|
|
129
|
+
|
|
130
|
+
1. **Box-sizing**: 必須スタイルに含まれているため、基本的な要素サイズは正常に表示されます
|
|
131
|
+
2. **Button要素**: 基本的なリセットは必須スタイルに含まれています
|
|
132
|
+
3. **アイコン**: Material Icons は必須スタイルに含まれています
|
|
133
|
+
|
|
134
|
+
### 競合が発生した場合
|
|
135
|
+
|
|
136
|
+
1. **リセットCSS**: optional/reset.scss を読み込まずに、自分のリセットCSSを使用
|
|
137
|
+
2. **フォント**: optional/fonts.scss を読み込まずに、自分のフォントを指定
|
|
138
|
+
3. **CSS変数**: 必要に応じて上書きしてください
|
|
139
|
+
|
|
140
|
+
## 📚 詳細情報
|
|
141
|
+
|
|
142
|
+
- [コンポーネント一覧](../../components/)
|
|
143
|
+
- [CSS変数一覧](./variables.scss)
|
|
144
|
+
- [TypeScript型定義](../../types/)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* src/lib/assets/styles/core.scss */
|
|
2
|
+
/*
|
|
3
|
+
* Core styles required for component functionality
|
|
4
|
+
* These styles are automatically included with the library
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*===================================================================
|
|
8
|
+
* Box-sizing - Required for proper component sizing
|
|
9
|
+
*===================================================================*/
|
|
10
|
+
*,
|
|
11
|
+
*::before,
|
|
12
|
+
*::after {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/*===================================================================
|
|
17
|
+
* Button reset - Required for consistent button styling
|
|
18
|
+
*===================================================================*/
|
|
19
|
+
button {
|
|
20
|
+
background: transparent;
|
|
21
|
+
border: none;
|
|
22
|
+
font-size: inherit;
|
|
23
|
+
font-weight: inherit;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*===================================================================
|
|
28
|
+
* Dialog element - Required for dialog components
|
|
29
|
+
*===================================================================*/
|
|
30
|
+
dialog {
|
|
31
|
+
color: inherit;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*===================================================================
|
|
35
|
+
* Form elements - Required for proper form functionality
|
|
36
|
+
*===================================================================*/
|
|
37
|
+
/* Prevent autofill background color changes */
|
|
38
|
+
input:-webkit-autofill {
|
|
39
|
+
transition: background-color 5000s ease-in-out 0s !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Label normalization - Used in Input, Textarea, Checkbox, Radio */
|
|
43
|
+
label {
|
|
44
|
+
font-weight: normal;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*===================================================================
|
|
48
|
+
* Accessibility - Required for screen readers
|
|
49
|
+
*===================================================================*/
|
|
50
|
+
/* Screen reader only class for accessibility - Used in PopupMenu */
|
|
51
|
+
.sr-only {
|
|
52
|
+
position: absolute;
|
|
53
|
+
width: 1px;
|
|
54
|
+
height: 1px;
|
|
55
|
+
padding: 0;
|
|
56
|
+
margin: -1px;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
clip: rect(0, 0, 0, 0);
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
border: 0;
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* src/lib/assets/styles/import.scss */
|
|
2
|
+
/*
|
|
3
|
+
* Core styles automatically included with svelte-ui
|
|
4
|
+
* These are the minimum required styles for components to work properly
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
@use './variables';
|
|
8
|
+
@use './core';
|
|
9
|
+
|
|
10
|
+
/* Material Symbols font (required for Icon component) */
|
|
11
|
+
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* src/lib/assets/styles/optional/fonts.scss */
|
|
2
|
+
/*
|
|
3
|
+
* Optional Font Imports
|
|
4
|
+
* Include this if you want to use our default font stack
|
|
5
|
+
* Import with: @import 'svelte-ui/styles/optional/fonts.scss';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*===================================================================
|
|
9
|
+
* Google Fonts & External Font Imports
|
|
10
|
+
*===================================================================*/
|
|
11
|
+
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
|
|
12
|
+
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap');
|
|
13
|
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100;400;700&display=swap');
|
|
14
|
+
@import url('https://cdn.jsdelivr.net/npm/yakuhanjp@3.0.0/dist/css/yakuhanjp.min.css');
|
|
15
|
+
|
|
16
|
+
/*===================================================================
|
|
17
|
+
* Font Family Settings
|
|
18
|
+
*===================================================================*/
|
|
19
|
+
body * {
|
|
20
|
+
font-family:
|
|
21
|
+
YakuHanJP, Roboto, 'Noto Sans JP', 'ヒラギノ角ゴ ProN W3', 'Hiragino Kaku Gothic ProN',
|
|
22
|
+
'メイリオ', Meiryo, sans-serif;
|
|
23
|
+
}
|