@ticatec/uniface-element 0.2.3 → 0.3.0
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/dist/accordion/README.md +169 -0
- package/dist/accordion/README_CN.md +176 -0
- package/dist/action-bar/README.md +275 -0
- package/dist/action-bar/README_CN.md +285 -0
- package/dist/app-layout/README.md +374 -0
- package/dist/app-layout/README_CN.md +381 -0
- package/dist/app-top-bar/README.md +357 -0
- package/dist/app-top-bar/README_CN.md +365 -0
- package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
- package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
- package/dist/base-calendar/CalendarBase.svelte +0 -3
- package/dist/box/README.md +385 -0
- package/dist/box/README_CN.md +393 -0
- package/dist/breadcrumbs/README.md +442 -0
- package/dist/breadcrumbs/README_CN.md +442 -0
- package/dist/button/Button.svelte +27 -7
- package/dist/button/Button.svelte.d.ts +3 -1
- package/dist/button/IconButton.svelte +26 -6
- package/dist/button/IconButton.svelte.d.ts +3 -1
- package/dist/button/IconButton_README.md +513 -0
- package/dist/button/IconButton_README_CN.md +513 -0
- package/dist/button/README.md +428 -0
- package/dist/button/README_CN.md +428 -0
- package/dist/button/TextButton.svelte +26 -6
- package/dist/button/TextButton.svelte.d.ts +3 -1
- package/dist/button/TextButton_README.md +571 -0
- package/dist/button/TextButton_README_CN.md +571 -0
- package/dist/card/README.md +666 -0
- package/dist/card/README_CN.md +666 -0
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
- package/dist/cascade-options-select/README.md +663 -2
- package/dist/cascade-options-select/README_CN.md +664 -0
- package/dist/checkbox/CheckBox.svelte +20 -6
- package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
- package/dist/checkbox/README.md +562 -0
- package/dist/checkbox/README_CN.md +727 -0
- package/dist/common-editor/NumberInput.svelte +39 -26
- package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
- package/dist/concise-data-table/ConciseListTable.svelte +133 -36
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
- package/dist/concise-data-table/DataCell.svelte +5 -6
- package/dist/concise-data-table/DataRow.svelte +22 -2
- package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
- package/dist/concise-data-table/README.md +606 -0
- package/dist/concise-data-table/README_CN.md +611 -0
- package/dist/context-menu/ContextMenu.svelte +138 -21
- package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
- package/dist/context-menu/ContextMenuItem.d.ts +20 -4
- package/dist/context-menu/README.md +551 -0
- package/dist/context-menu/README_CN.md +551 -0
- package/dist/criteria-field/CriteriaField.svelte +3 -5
- package/dist/criteria-field/README.md +532 -0
- package/dist/criteria-field/README_CN.md +532 -0
- package/dist/data-table/README.md +712 -0
- package/dist/data-table/README_CN.md +712 -0
- package/dist/date-picker/DatePicker.svelte +44 -7
- package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
- package/dist/date-picker/DateTimePicker.svelte +32 -8
- package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
- package/dist/date-picker/README.md +326 -0
- package/dist/date-picker/README_CN.md +316 -0
- package/dist/date-picker/ScrollBar.svelte +18 -8
- package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
- package/dist/date-picker/TimePanel.svelte +5 -5
- package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
- package/dist/date-range/README.md +374 -0
- package/dist/date-range/README_CN.md +374 -0
- package/dist/dialog/DialogBoard.svelte +1 -1
- package/dist/dialog/README.md +596 -0
- package/dist/dialog/README_CN.md +596 -0
- package/dist/drawer/README.md +679 -1
- package/dist/drawer/README_CN.md +679 -0
- package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
- package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
- package/dist/group-box/group-check-box/README.md +749 -0
- package/dist/group-box/group-check-box/README_CN.md +750 -0
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
- package/dist/group-box/group-radio-box/README.md +920 -0
- package/dist/group-box/group-radio-box/README_CN.md +920 -0
- package/dist/image-files/README.md +1346 -0
- package/dist/image-files/README_CN.md +1346 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
- package/dist/lib/forwardAllEvents.d.ts +3 -0
- package/dist/lib/forwardAllEvents.js +24 -0
- package/dist/list-box/README.md +579 -0
- package/dist/list-box/README_CN.md +682 -0
- package/dist/lookup-editor/LookupEditor.svelte +15 -3
- package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
- package/dist/lookup-editor/README.md +684 -0
- package/dist/lookup-editor/README_CN.md +684 -0
- package/dist/memo-editor/MemoEditor.svelte +77 -27
- package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
- package/dist/memo-editor/README.md +819 -0
- package/dist/memo-editor/README_CN.md +819 -0
- package/dist/message-box/README.md +398 -0
- package/dist/message-box/README_CN.md +398 -0
- package/dist/number-editor/NumberEditor.svelte +2 -2
- package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
- package/dist/number-editor/README.md +353 -22
- package/dist/number-editor/README_CN.md +357 -0
- package/dist/number-range/README.md +443 -0
- package/dist/number-range/README_CN.md +443 -0
- package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
- package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
- package/dist/options-multi-select/README.md +480 -0
- package/dist/options-multi-select/README_CN.md +480 -0
- package/dist/options-select/OptionsSelect.svelte +36 -5
- package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
- package/dist/options-select/README.md +632 -0
- package/dist/options-select/README_CN.md +632 -0
- package/dist/page/README.md +605 -0
- package/dist/page/README_CN.md +605 -0
- package/dist/pagination/README.md +946 -0
- package/dist/pagination/README_CN.md +946 -0
- package/dist/pagination-panel/README.md +1075 -0
- package/dist/pagination-panel/README_CN.md +1075 -0
- package/dist/popup-hint/README.md +841 -0
- package/dist/popup-hint/README_CN.md +840 -0
- package/dist/progress-bar/README.md +242 -0
- package/dist/progress-bar/README_CN.md +242 -0
- package/dist/progress-step-bar/README.md +316 -0
- package/dist/progress-step-bar/README_CN.md +316 -0
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
- package/dist/prompts-text-editor/README.md +329 -0
- package/dist/prompts-text-editor/README_CN.md +329 -0
- package/dist/property-editor/README.md +969 -0
- package/dist/property-editor/README_CN.md +969 -0
- package/dist/radio-button/README.md +372 -0
- package/dist/radio-button/README_CN.md +372 -0
- package/dist/radio-button/RadioButton.svelte +32 -3
- package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
- package/dist/search-box/README.md +425 -0
- package/dist/search-box/README_CN.md +424 -0
- package/dist/search-box/SearchBox.svelte +22 -6
- package/dist/search-box/SearchBox.svelte.d.ts +4 -1
- package/dist/tabs/README.md +919 -0
- package/dist/tabs/README_CN.md +920 -0
- package/dist/tag/README.md +922 -0
- package/dist/tag/README_CN.md +922 -0
- package/dist/text-editor/PasswordEditor.svelte +17 -2
- package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
- package/dist/text-editor/PasswordEditor_README.md +551 -0
- package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
- package/dist/text-editor/README.md +466 -0
- package/dist/text-editor/README_CN.md +466 -0
- package/dist/text-editor/TextEditor.svelte +51 -19
- package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
- package/dist/ticatec-uniface-web.css +1 -0
- package/dist/time-editor/README.md +498 -24
- package/dist/time-editor/README_CN.md +498 -0
- package/dist/time-editor/TimeEditor.svelte +7 -3
- package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
- package/dist/toast/README.md +667 -0
- package/dist/toast/README_CN.md +667 -0
- package/dist/transfer/README.md +795 -0
- package/dist/transfer/Transfer.svelte +6 -4
- package/dist/transfer/Transfer.svelte.d.ts +3 -1
- package/dist/tree-view/README.md +761 -0
- package/dist/tree-view/README_CN.md +761 -0
- package/dist/tree-view/TreeView.svelte +5 -3
- package/dist/tree-view/TreeView.svelte.d.ts +3 -1
- package/dist/unit-number-editor/README.md +546 -20
- package/dist/unit-number-editor/README_CN.md +525 -0
- package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
- package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
- package/docs/form-field/cn/README_CN.md +364 -0
- package/docs/form-field/en/README.md +364 -0
- package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
- package/docs/form-panel/flex-form/en/README.md +586 -0
- package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
- package/docs/form-panel/flex-row-form/en/README.md +787 -0
- package/docs/form-panel/grid-form/en/README.md +744 -0
- package/package.json +1 -1
- package/dist/drawer/README-CN.md +0 -1
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
# Card Component
|
|
2
|
+
|
|
3
|
+
A flexible card container component that displays content in a structured format with optional header, action bar, and various styling options. Perfect for displaying structured information, user profiles, product details, and more.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Flexible Structure**: Header, content, and action bar sections
|
|
8
|
+
- **Multiple Header Options**: Simple title or custom header content via slots
|
|
9
|
+
- **Action Bar Support**: Built-in action buttons with icons/images and callbacks
|
|
10
|
+
- **Visual Variants**: Plain and 3D shadow variants
|
|
11
|
+
- **Custom Styling**: Flexible style customization
|
|
12
|
+
- **Slot-Based Content**: Rich content support through slots
|
|
13
|
+
- **Interactive Actions**: Click handling with debouncing and hover hints
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
```svelte
|
|
18
|
+
<script>
|
|
19
|
+
import Card from '@ticatec/uniface-element/Card';
|
|
20
|
+
|
|
21
|
+
const cardData = { id: 1, name: 'John Doe' };
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<Card
|
|
25
|
+
title="User Profile"
|
|
26
|
+
data={cardData}
|
|
27
|
+
>
|
|
28
|
+
<p>This is the card content area.</p>
|
|
29
|
+
</Card>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| `style` | `string` | `''` | Custom CSS styles |
|
|
37
|
+
| `title` | `string` | `null` | Simple header title text |
|
|
38
|
+
| `actions` | `CardAction[]` | `[]` | Array of action buttons |
|
|
39
|
+
| `variant` | `'plain' \| '3d'` | `'plain'` | Card visual variant |
|
|
40
|
+
| `iconColor` | `string \| null` | `null` | Custom color for action icons |
|
|
41
|
+
| `data` | `any` | `null` | Data object passed to action callbacks |
|
|
42
|
+
|
|
43
|
+
## CardAction Interface
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface CardAction {
|
|
47
|
+
icon?: string; // Icon font class (e.g., FontAwesome)
|
|
48
|
+
img?: string; // Image URL for custom icons
|
|
49
|
+
hint?: string; // Tooltip text on hover
|
|
50
|
+
disabled?: boolean; // Whether the action is disabled
|
|
51
|
+
callback: (data: any) => void; // Action callback function
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Slots
|
|
56
|
+
|
|
57
|
+
| Slot | Description |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| `header-bar` | Custom header content (overrides title prop) |
|
|
60
|
+
| `default` | Main card content |
|
|
61
|
+
| `action-bar` | Custom action bar content (when no actions prop) |
|
|
62
|
+
|
|
63
|
+
## Card Variants
|
|
64
|
+
|
|
65
|
+
```svelte
|
|
66
|
+
<!-- Plain card (default) -->
|
|
67
|
+
<Card title="Plain Card" variant="plain">
|
|
68
|
+
<p>Simple flat card design</p>
|
|
69
|
+
</Card>
|
|
70
|
+
|
|
71
|
+
<!-- 3D shadow card -->
|
|
72
|
+
<Card title="3D Card" variant="3d">
|
|
73
|
+
<p>Card with shadow effect</p>
|
|
74
|
+
</Card>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## With Actions
|
|
78
|
+
|
|
79
|
+
```svelte
|
|
80
|
+
<script>
|
|
81
|
+
import Card, { type CardAction } from '@ticatec/uniface-element/Card';
|
|
82
|
+
|
|
83
|
+
const userData = { id: 1, name: 'John Doe', email: 'john@example.com' };
|
|
84
|
+
|
|
85
|
+
const actions: CardAction[] = [
|
|
86
|
+
{
|
|
87
|
+
icon: 'fas fa-edit',
|
|
88
|
+
hint: 'Edit user',
|
|
89
|
+
callback: (data) => editUser(data)
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
icon: 'fas fa-trash',
|
|
93
|
+
hint: 'Delete user',
|
|
94
|
+
callback: (data) => deleteUser(data)
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
icon: 'fas fa-share',
|
|
98
|
+
hint: 'Share profile',
|
|
99
|
+
callback: (data) => shareProfile(data)
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const editUser = (user) => {
|
|
104
|
+
console.log('Editing user:', user);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const deleteUser = (user) => {
|
|
108
|
+
console.log('Deleting user:', user);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const shareProfile = (user) => {
|
|
112
|
+
console.log('Sharing profile:', user);
|
|
113
|
+
};
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<Card
|
|
117
|
+
title="User Profile"
|
|
118
|
+
{actions}
|
|
119
|
+
data={userData}
|
|
120
|
+
variant="3d"
|
|
121
|
+
>
|
|
122
|
+
<div class="profile-content">
|
|
123
|
+
<h3>{userData.name}</h3>
|
|
124
|
+
<p>{userData.email}</p>
|
|
125
|
+
</div>
|
|
126
|
+
</Card>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Custom Header with Slot
|
|
130
|
+
|
|
131
|
+
```svelte
|
|
132
|
+
<Card variant="3d">
|
|
133
|
+
<div slot="header-bar" class="custom-header">
|
|
134
|
+
<div class="header-left">
|
|
135
|
+
<img src="/avatar.jpg" alt="User" class="avatar" />
|
|
136
|
+
<h3>John Doe</h3>
|
|
137
|
+
</div>
|
|
138
|
+
<div class="header-right">
|
|
139
|
+
<span class="status online">Online</span>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="profile-details">
|
|
144
|
+
<p>Software Developer</p>
|
|
145
|
+
<p>San Francisco, CA</p>
|
|
146
|
+
</div>
|
|
147
|
+
</Card>
|
|
148
|
+
|
|
149
|
+
<style>
|
|
150
|
+
.custom-header {
|
|
151
|
+
display: flex;
|
|
152
|
+
justify-content: space-between;
|
|
153
|
+
align-items: center;
|
|
154
|
+
padding: 16px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.header-left {
|
|
158
|
+
display: flex;
|
|
159
|
+
align-items: center;
|
|
160
|
+
gap: 12px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.avatar {
|
|
164
|
+
width: 40px;
|
|
165
|
+
height: 40px;
|
|
166
|
+
border-radius: 50%;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.status.online {
|
|
170
|
+
color: #22c55e;
|
|
171
|
+
font-weight: 500;
|
|
172
|
+
}
|
|
173
|
+
</style>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Custom Action Bar
|
|
177
|
+
|
|
178
|
+
```svelte
|
|
179
|
+
<Card title="Project Card">
|
|
180
|
+
<div class="project-info">
|
|
181
|
+
<h4>Project Alpha</h4>
|
|
182
|
+
<p>A revolutionary new application</p>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div slot="action-bar" class="custom-actions">
|
|
186
|
+
<button class="btn-primary">View Details</button>
|
|
187
|
+
<button class="btn-secondary">Edit</button>
|
|
188
|
+
<button class="btn-danger">Delete</button>
|
|
189
|
+
</div>
|
|
190
|
+
</Card>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Advanced Examples
|
|
194
|
+
|
|
195
|
+
### Product Card
|
|
196
|
+
|
|
197
|
+
```svelte
|
|
198
|
+
<script>
|
|
199
|
+
const product = {
|
|
200
|
+
id: 101,
|
|
201
|
+
name: 'Wireless Headphones',
|
|
202
|
+
price: 199.99,
|
|
203
|
+
image: '/headphones.jpg'
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const productActions = [
|
|
207
|
+
{
|
|
208
|
+
icon: 'fas fa-heart',
|
|
209
|
+
hint: 'Add to favorites',
|
|
210
|
+
callback: (data) => addToFavorites(data)
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
icon: 'fas fa-shopping-cart',
|
|
214
|
+
hint: 'Add to cart',
|
|
215
|
+
callback: (data) => addToCart(data)
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
icon: 'fas fa-share',
|
|
219
|
+
hint: 'Share product',
|
|
220
|
+
callback: (data) => shareProduct(data)
|
|
221
|
+
}
|
|
222
|
+
];
|
|
223
|
+
</script>
|
|
224
|
+
|
|
225
|
+
<Card
|
|
226
|
+
actions={productActions}
|
|
227
|
+
data={product}
|
|
228
|
+
variant="3d"
|
|
229
|
+
style="max-width: 300px;"
|
|
230
|
+
>
|
|
231
|
+
<div slot="header-bar" class="product-header">
|
|
232
|
+
<img src={product.image} alt={product.name} class="product-image" />
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div class="product-details">
|
|
236
|
+
<h3>{product.name}</h3>
|
|
237
|
+
<div class="price">${product.price}</div>
|
|
238
|
+
<div class="rating">
|
|
239
|
+
⭐⭐⭐⭐⭐ (128 reviews)
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
</Card>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Dashboard Widget
|
|
246
|
+
|
|
247
|
+
```svelte
|
|
248
|
+
<script>
|
|
249
|
+
const widgetData = {
|
|
250
|
+
title: 'Sales Overview',
|
|
251
|
+
value: 12345,
|
|
252
|
+
change: '+15.3%'
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const widgetActions = [
|
|
256
|
+
{
|
|
257
|
+
icon: 'fas fa-refresh',
|
|
258
|
+
hint: 'Refresh data',
|
|
259
|
+
callback: (data) => refreshWidget(data)
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
icon: 'fas fa-cog',
|
|
263
|
+
hint: 'Settings',
|
|
264
|
+
callback: (data) => openSettings(data)
|
|
265
|
+
}
|
|
266
|
+
];
|
|
267
|
+
</script>
|
|
268
|
+
|
|
269
|
+
<Card
|
|
270
|
+
title={widgetData.title}
|
|
271
|
+
actions={widgetActions}
|
|
272
|
+
data={widgetData}
|
|
273
|
+
iconColor="#007acc"
|
|
274
|
+
>
|
|
275
|
+
<div class="widget-content">
|
|
276
|
+
<div class="metric-value">${widgetData.value.toLocaleString()}</div>
|
|
277
|
+
<div class="metric-change positive">{widgetData.change}</div>
|
|
278
|
+
</div>
|
|
279
|
+
</Card>
|
|
280
|
+
|
|
281
|
+
<style>
|
|
282
|
+
.widget-content {
|
|
283
|
+
text-align: center;
|
|
284
|
+
padding: 20px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.metric-value {
|
|
288
|
+
font-size: 2rem;
|
|
289
|
+
font-weight: bold;
|
|
290
|
+
color: #333;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.metric-change {
|
|
294
|
+
font-size: 1rem;
|
|
295
|
+
margin-top: 8px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.metric-change.positive {
|
|
299
|
+
color: #22c55e;
|
|
300
|
+
}
|
|
301
|
+
</style>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Blog Post Card
|
|
305
|
+
|
|
306
|
+
```svelte
|
|
307
|
+
<script>
|
|
308
|
+
const post = {
|
|
309
|
+
id: 1,
|
|
310
|
+
title: 'Getting Started with Svelte',
|
|
311
|
+
excerpt: 'Learn the basics of Svelte framework...',
|
|
312
|
+
author: 'Jane Smith',
|
|
313
|
+
date: '2024-03-15',
|
|
314
|
+
tags: ['svelte', 'javascript', 'tutorial']
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const postActions = [
|
|
318
|
+
{
|
|
319
|
+
icon: 'fas fa-bookmark',
|
|
320
|
+
hint: 'Bookmark post',
|
|
321
|
+
callback: (data) => bookmarkPost(data)
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
icon: 'fas fa-share',
|
|
325
|
+
hint: 'Share post',
|
|
326
|
+
callback: (data) => sharePost(data)
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
</script>
|
|
330
|
+
|
|
331
|
+
<Card
|
|
332
|
+
actions={postActions}
|
|
333
|
+
data={post}
|
|
334
|
+
variant="plain"
|
|
335
|
+
>
|
|
336
|
+
<div slot="header-bar" class="post-header">
|
|
337
|
+
<h2 class="post-title">{post.title}</h2>
|
|
338
|
+
<div class="post-meta">
|
|
339
|
+
<span>By {post.author}</span>
|
|
340
|
+
<span>{post.date}</span>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<div class="post-content">
|
|
345
|
+
<p>{post.excerpt}</p>
|
|
346
|
+
<div class="tags">
|
|
347
|
+
{#each post.tags as tag}
|
|
348
|
+
<span class="tag">#{tag}</span>
|
|
349
|
+
{/each}
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
</Card>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Contact Card
|
|
356
|
+
|
|
357
|
+
```svelte
|
|
358
|
+
<script>
|
|
359
|
+
const contact = {
|
|
360
|
+
name: 'Sarah Johnson',
|
|
361
|
+
role: 'Project Manager',
|
|
362
|
+
email: 'sarah@company.com',
|
|
363
|
+
phone: '+1 (555) 123-4567',
|
|
364
|
+
avatar: '/sarah.jpg'
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
const contactActions = [
|
|
368
|
+
{
|
|
369
|
+
icon: 'fas fa-envelope',
|
|
370
|
+
hint: 'Send email',
|
|
371
|
+
callback: (data) => sendEmail(data.email)
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
icon: 'fas fa-phone',
|
|
375
|
+
hint: 'Call',
|
|
376
|
+
callback: (data) => makeCall(data.phone)
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
icon: 'fas fa-edit',
|
|
380
|
+
hint: 'Edit contact',
|
|
381
|
+
callback: (data) => editContact(data)
|
|
382
|
+
}
|
|
383
|
+
];
|
|
384
|
+
</script>
|
|
385
|
+
|
|
386
|
+
<Card
|
|
387
|
+
actions={contactActions}
|
|
388
|
+
data={contact}
|
|
389
|
+
variant="3d"
|
|
390
|
+
>
|
|
391
|
+
<div class="contact-card">
|
|
392
|
+
<img src={contact.avatar} alt={contact.name} class="contact-avatar" />
|
|
393
|
+
<h3>{contact.name}</h3>
|
|
394
|
+
<p class="contact-role">{contact.role}</p>
|
|
395
|
+
<div class="contact-info">
|
|
396
|
+
<div class="contact-item">
|
|
397
|
+
<i class="fas fa-envelope"></i>
|
|
398
|
+
<span>{contact.email}</span>
|
|
399
|
+
</div>
|
|
400
|
+
<div class="contact-item">
|
|
401
|
+
<i class="fas fa-phone"></i>
|
|
402
|
+
<span>{contact.phone}</span>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
</Card>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Settings Card
|
|
410
|
+
|
|
411
|
+
```svelte
|
|
412
|
+
<script>
|
|
413
|
+
let notifications = true;
|
|
414
|
+
let darkMode = false;
|
|
415
|
+
|
|
416
|
+
const settingsData = { notifications, darkMode };
|
|
417
|
+
|
|
418
|
+
const saveSettings = (data) => {
|
|
419
|
+
console.log('Saving settings:', data);
|
|
420
|
+
// Save settings logic
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const resetSettings = (data) => {
|
|
424
|
+
notifications = true;
|
|
425
|
+
darkMode = false;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const settingsActions = [
|
|
429
|
+
{
|
|
430
|
+
icon: 'fas fa-save',
|
|
431
|
+
hint: 'Save settings',
|
|
432
|
+
callback: saveSettings
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
icon: 'fas fa-undo',
|
|
436
|
+
hint: 'Reset to defaults',
|
|
437
|
+
callback: resetSettings
|
|
438
|
+
}
|
|
439
|
+
];
|
|
440
|
+
</script>
|
|
441
|
+
|
|
442
|
+
<Card
|
|
443
|
+
title="Preferences"
|
|
444
|
+
actions={settingsActions}
|
|
445
|
+
data={settingsData}
|
|
446
|
+
>
|
|
447
|
+
<div class="settings-form">
|
|
448
|
+
<div class="setting-item">
|
|
449
|
+
<label>
|
|
450
|
+
<input type="checkbox" bind:checked={notifications} />
|
|
451
|
+
Enable notifications
|
|
452
|
+
</label>
|
|
453
|
+
</div>
|
|
454
|
+
<div class="setting-item">
|
|
455
|
+
<label>
|
|
456
|
+
<input type="checkbox" bind:checked={darkMode} />
|
|
457
|
+
Dark mode
|
|
458
|
+
</label>
|
|
459
|
+
</div>
|
|
460
|
+
</div>
|
|
461
|
+
</Card>
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## Action Types
|
|
465
|
+
|
|
466
|
+
### Icon Actions
|
|
467
|
+
|
|
468
|
+
```svelte
|
|
469
|
+
<script>
|
|
470
|
+
const iconActions = [
|
|
471
|
+
{
|
|
472
|
+
icon: 'fas fa-star',
|
|
473
|
+
hint: 'Mark as favorite',
|
|
474
|
+
callback: (data) => toggleFavorite(data)
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
icon: 'fas fa-download',
|
|
478
|
+
hint: 'Download',
|
|
479
|
+
callback: (data) => downloadFile(data)
|
|
480
|
+
}
|
|
481
|
+
];
|
|
482
|
+
</script>
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Image Actions
|
|
486
|
+
|
|
487
|
+
```svelte
|
|
488
|
+
<script>
|
|
489
|
+
const imageActions = [
|
|
490
|
+
{
|
|
491
|
+
img: '/icons/custom-icon.svg',
|
|
492
|
+
hint: 'Custom action',
|
|
493
|
+
callback: (data) => customAction(data)
|
|
494
|
+
}
|
|
495
|
+
];
|
|
496
|
+
</script>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Disabled Actions
|
|
500
|
+
|
|
501
|
+
```svelte
|
|
502
|
+
<script>
|
|
503
|
+
const mixedActions = [
|
|
504
|
+
{
|
|
505
|
+
icon: 'fas fa-edit',
|
|
506
|
+
hint: 'Edit (available)',
|
|
507
|
+
callback: (data) => editItem(data)
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
icon: 'fas fa-trash',
|
|
511
|
+
hint: 'Delete (not available)',
|
|
512
|
+
disabled: true,
|
|
513
|
+
callback: (data) => deleteItem(data)
|
|
514
|
+
}
|
|
515
|
+
];
|
|
516
|
+
</script>
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
## Styling
|
|
520
|
+
|
|
521
|
+
The component uses the following CSS classes:
|
|
522
|
+
|
|
523
|
+
- `.uniface-card` - Main card container
|
|
524
|
+
- `.shadowBox` - Applied when variant="3d"
|
|
525
|
+
- `.card-header` - Header section container
|
|
526
|
+
- `.card-header.simple` - Simple header with title only
|
|
527
|
+
- `.card-content` - Main content area
|
|
528
|
+
- `.card-action-bar` - Action bar container
|
|
529
|
+
- `.card-action-bar.simple` - Built-in action bar
|
|
530
|
+
- `.action-item` - Individual action button
|
|
531
|
+
- `.action-item.disabled` - Disabled action styling
|
|
532
|
+
|
|
533
|
+
### Example CSS
|
|
534
|
+
|
|
535
|
+
```css
|
|
536
|
+
.uniface-card {
|
|
537
|
+
border: 1px solid #e5e7eb;
|
|
538
|
+
border-radius: 8px;
|
|
539
|
+
background: white;
|
|
540
|
+
overflow: hidden;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.uniface-card.shadowBox {
|
|
544
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.card-header {
|
|
548
|
+
border-bottom: 1px solid #e5e7eb;
|
|
549
|
+
padding: 16px;
|
|
550
|
+
background: #f9fafb;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.card-content {
|
|
554
|
+
padding: 16px;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.card-action-bar {
|
|
558
|
+
border-top: 1px solid #e5e7eb;
|
|
559
|
+
padding: 8px 16px;
|
|
560
|
+
background: #f9fafb;
|
|
561
|
+
display: flex;
|
|
562
|
+
gap: 12px;
|
|
563
|
+
justify-content: flex-end;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.action-item {
|
|
567
|
+
cursor: pointer;
|
|
568
|
+
padding: 8px;
|
|
569
|
+
border-radius: 4px;
|
|
570
|
+
transition: background-color 0.2s;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.action-item:hover:not(.disabled) {
|
|
574
|
+
background: rgba(0, 0, 0, 0.05);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.action-item.disabled {
|
|
578
|
+
opacity: 0.5;
|
|
579
|
+
cursor: not-allowed;
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
## Best Practices
|
|
584
|
+
|
|
585
|
+
1. **Consistent Data Structure**: Use consistent data objects for similar card types
|
|
586
|
+
2. **Meaningful Actions**: Provide clear, actionable operations with descriptive hints
|
|
587
|
+
3. **Appropriate Variants**: Use 3D variant sparingly for emphasis
|
|
588
|
+
4. **Accessible Content**: Ensure content is readable and actions are clearly labeled
|
|
589
|
+
5. **Responsive Design**: Consider how cards stack and resize on different screen sizes
|
|
590
|
+
6. **Loading States**: Show loading indicators for dynamic content
|
|
591
|
+
7. **Error Handling**: Handle action callback errors gracefully
|
|
592
|
+
|
|
593
|
+
## Common Patterns
|
|
594
|
+
|
|
595
|
+
### Card Grid
|
|
596
|
+
|
|
597
|
+
```svelte
|
|
598
|
+
<div class="card-grid">
|
|
599
|
+
{#each items as item}
|
|
600
|
+
<Card title={item.title} actions={cardActions} data={item}>
|
|
601
|
+
<p>{item.description}</p>
|
|
602
|
+
</Card>
|
|
603
|
+
{/each}
|
|
604
|
+
</div>
|
|
605
|
+
|
|
606
|
+
<style>
|
|
607
|
+
.card-grid {
|
|
608
|
+
display: grid;
|
|
609
|
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
610
|
+
gap: 16px;
|
|
611
|
+
padding: 16px;
|
|
612
|
+
}
|
|
613
|
+
</style>
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### Card List
|
|
617
|
+
|
|
618
|
+
```svelte
|
|
619
|
+
<div class="card-list">
|
|
620
|
+
{#each items as item}
|
|
621
|
+
<Card variant="plain" actions={listActions} data={item}>
|
|
622
|
+
<div class="list-item">
|
|
623
|
+
<h4>{item.title}</h4>
|
|
624
|
+
<p>{item.description}</p>
|
|
625
|
+
</div>
|
|
626
|
+
</Card>
|
|
627
|
+
{/each}
|
|
628
|
+
</div>
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
### Dashboard Layout
|
|
632
|
+
|
|
633
|
+
```svelte
|
|
634
|
+
<div class="dashboard">
|
|
635
|
+
<div class="dashboard-row">
|
|
636
|
+
<Card title="Revenue" variant="3d">
|
|
637
|
+
<div class="metric">$45,230</div>
|
|
638
|
+
</Card>
|
|
639
|
+
<Card title="Users" variant="3d">
|
|
640
|
+
<div class="metric">1,234</div>
|
|
641
|
+
</Card>
|
|
642
|
+
</div>
|
|
643
|
+
</div>
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
## Accessibility
|
|
647
|
+
|
|
648
|
+
- Use semantic HTML within card content
|
|
649
|
+
- Provide meaningful action hints for screen readers
|
|
650
|
+
- Ensure sufficient color contrast
|
|
651
|
+
- Support keyboard navigation for actions
|
|
652
|
+
- Use appropriate heading levels in card content
|
|
653
|
+
|
|
654
|
+
## Browser Support
|
|
655
|
+
|
|
656
|
+
The Card component works in all modern browsers that support:
|
|
657
|
+
- ES6+ JavaScript
|
|
658
|
+
- CSS Grid and Flexbox
|
|
659
|
+
- Modern DOM APIs
|
|
660
|
+
|
|
661
|
+
## Performance
|
|
662
|
+
|
|
663
|
+
- Efficient action handling with built-in debouncing
|
|
664
|
+
- Minimal re-renders with proper key usage
|
|
665
|
+
- Lightweight DOM structure
|
|
666
|
+
- Optional lazy loading for card content
|