@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,513 @@
|
|
|
1
|
+
# IconButton Component
|
|
2
|
+
|
|
3
|
+
A specialized button component designed for icon-based actions, providing a clean and compact interface for toolbar actions, navigation controls, and interactive elements.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Icon-Focused Design**: Optimized for displaying icons as primary content
|
|
8
|
+
- **Multiple Types**: Default, primary, secondary, third, and forth button styles
|
|
9
|
+
- **Size Options**: Big, medium, and mini sizes
|
|
10
|
+
- **Event Handling**: Click, focus, and blur event support
|
|
11
|
+
- **Accessibility**: Proper semantic button element with disabled state
|
|
12
|
+
- **Debounce Protection**: Built-in click debouncing to prevent rapid firing
|
|
13
|
+
- **Custom Styling**: Flexible style customization
|
|
14
|
+
- **Slot Support**: Custom icon content via slots
|
|
15
|
+
|
|
16
|
+
## Basic Usage
|
|
17
|
+
|
|
18
|
+
```svelte
|
|
19
|
+
<script>
|
|
20
|
+
import IconButton from '@ticatec/uniface-element/IconButton';
|
|
21
|
+
|
|
22
|
+
const handleClick = (event) => {
|
|
23
|
+
console.log('Icon button clicked!', event);
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<IconButton
|
|
28
|
+
icon="fas fa-heart"
|
|
29
|
+
onclick={handleClick}
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Props
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
|------|------|---------|-------------|
|
|
37
|
+
| `type` | `'default' \| 'primary' \| 'secondary' \| 'third' \| 'forth'` | `'default'` | Button type/style |
|
|
38
|
+
| `disabled` | `boolean` | `false` | Whether the button is disabled |
|
|
39
|
+
| `size` | `'big' \| 'medium' \| 'mini'` | `'medium'` | Button size |
|
|
40
|
+
| `style` | `string` | `''` | Custom CSS styles |
|
|
41
|
+
| `icon` | `string` | `''` | Icon class name (e.g., FontAwesome classes) |
|
|
42
|
+
| `onclick` | `(event: MouseEvent) => void` | - | Click event handler |
|
|
43
|
+
| `onfocus` | `(event: FocusEvent) => void` | `() => {}` | Focus event handler |
|
|
44
|
+
| `onblur` | `(event: FocusEvent) => void` | `() => {}` | Blur event handler |
|
|
45
|
+
|
|
46
|
+
## Button Types
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<!-- Default icon button -->
|
|
50
|
+
<IconButton icon="fas fa-star" type="default" onclick={handleClick} />
|
|
51
|
+
|
|
52
|
+
<!-- Primary icon button -->
|
|
53
|
+
<IconButton icon="fas fa-plus" type="primary" onclick={handleClick} />
|
|
54
|
+
|
|
55
|
+
<!-- Secondary icon button -->
|
|
56
|
+
<IconButton icon="fas fa-edit" type="secondary" onclick={handleClick} />
|
|
57
|
+
|
|
58
|
+
<!-- Third level icon button -->
|
|
59
|
+
<IconButton icon="fas fa-share" type="third" onclick={handleClick} />
|
|
60
|
+
|
|
61
|
+
<!-- Fourth level icon button -->
|
|
62
|
+
<IconButton icon="fas fa-info" type="forth" onclick={handleClick} />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Button Sizes
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<!-- Mini icon button -->
|
|
69
|
+
<IconButton icon="fas fa-search" size="mini" onclick={handleClick} />
|
|
70
|
+
|
|
71
|
+
<!-- Medium icon button (default) -->
|
|
72
|
+
<IconButton icon="fas fa-search" size="medium" onclick={handleClick} />
|
|
73
|
+
|
|
74
|
+
<!-- Big icon button -->
|
|
75
|
+
<IconButton icon="fas fa-search" size="big" onclick={handleClick} />
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Common Use Cases
|
|
79
|
+
|
|
80
|
+
### Toolbar Actions
|
|
81
|
+
|
|
82
|
+
```svelte
|
|
83
|
+
<div class="toolbar">
|
|
84
|
+
<IconButton icon="fas fa-bold" onclick={toggleBold} />
|
|
85
|
+
<IconButton icon="fas fa-italic" onclick={toggleItalic} />
|
|
86
|
+
<IconButton icon="fas fa-underline" onclick={toggleUnderline} />
|
|
87
|
+
<IconButton icon="fas fa-link" onclick={insertLink} />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<style>
|
|
91
|
+
.toolbar {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: 4px;
|
|
94
|
+
padding: 8px;
|
|
95
|
+
border: 1px solid #ddd;
|
|
96
|
+
border-radius: 4px;
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Navigation Controls
|
|
102
|
+
|
|
103
|
+
```svelte
|
|
104
|
+
<div class="navigation">
|
|
105
|
+
<IconButton icon="fas fa-chevron-left" onclick={goBack} />
|
|
106
|
+
<IconButton icon="fas fa-home" onclick={goHome} />
|
|
107
|
+
<IconButton icon="fas fa-chevron-right" onclick={goForward} />
|
|
108
|
+
</div>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Action Buttons
|
|
112
|
+
|
|
113
|
+
```svelte
|
|
114
|
+
<div class="actions">
|
|
115
|
+
<IconButton icon="fas fa-heart" type="primary" onclick={toggleFavorite} />
|
|
116
|
+
<IconButton icon="fas fa-share" type="secondary" onclick={shareItem} />
|
|
117
|
+
<IconButton icon="fas fa-bookmark" onclick={bookmarkItem} />
|
|
118
|
+
<IconButton icon="fas fa-trash" type="secondary" onclick={deleteItem} />
|
|
119
|
+
</div>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Event Handling
|
|
123
|
+
|
|
124
|
+
```svelte
|
|
125
|
+
<script>
|
|
126
|
+
let isLiked = false;
|
|
127
|
+
|
|
128
|
+
const handleLike = (event) => {
|
|
129
|
+
isLiked = !isLiked;
|
|
130
|
+
console.log('Like toggled:', isLiked);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleFocus = (event) => {
|
|
134
|
+
// Show tooltip or highlight
|
|
135
|
+
showTooltip = true;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const handleBlur = (event) => {
|
|
139
|
+
// Hide tooltip
|
|
140
|
+
showTooltip = false;
|
|
141
|
+
};
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<IconButton
|
|
145
|
+
icon={isLiked ? "fas fa-heart" : "far fa-heart"}
|
|
146
|
+
type={isLiked ? "primary" : "default"}
|
|
147
|
+
onclick={handleLike}
|
|
148
|
+
onfocus={handleFocus}
|
|
149
|
+
onblur={handleBlur}
|
|
150
|
+
/>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Disabled State
|
|
154
|
+
|
|
155
|
+
```svelte
|
|
156
|
+
<IconButton
|
|
157
|
+
icon="fas fa-save"
|
|
158
|
+
disabled={true}
|
|
159
|
+
onclick={handleSave}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Custom Styling
|
|
164
|
+
|
|
165
|
+
```svelte
|
|
166
|
+
<IconButton
|
|
167
|
+
icon="fas fa-star"
|
|
168
|
+
style="
|
|
169
|
+
background: linear-gradient(45deg, #ffd700, #ffed4e);
|
|
170
|
+
color: #333;
|
|
171
|
+
border: 2px solid #ffd700;
|
|
172
|
+
border-radius: 50%;
|
|
173
|
+
"
|
|
174
|
+
onclick={handleClick}
|
|
175
|
+
/>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Slot Usage
|
|
179
|
+
|
|
180
|
+
```svelte
|
|
181
|
+
<!-- Custom icon content -->
|
|
182
|
+
<IconButton onclick={handleCustomAction}>
|
|
183
|
+
<svg width="16" height="16" viewBox="0 0 24 24">
|
|
184
|
+
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
|
|
185
|
+
</svg>
|
|
186
|
+
</IconButton>
|
|
187
|
+
|
|
188
|
+
<!-- Multiple icons or complex content -->
|
|
189
|
+
<IconButton onclick={handleMultiAction}>
|
|
190
|
+
<div class="multi-icon">
|
|
191
|
+
<i class="fas fa-plus"></i>
|
|
192
|
+
<i class="fas fa-file"></i>
|
|
193
|
+
</div>
|
|
194
|
+
</IconButton>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Advanced Examples
|
|
198
|
+
|
|
199
|
+
### Toggle Button
|
|
200
|
+
|
|
201
|
+
```svelte
|
|
202
|
+
<script>
|
|
203
|
+
let isToggled = false;
|
|
204
|
+
|
|
205
|
+
const handleToggle = (event) => {
|
|
206
|
+
isToggled = !isToggled;
|
|
207
|
+
};
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<IconButton
|
|
211
|
+
icon={isToggled ? "fas fa-toggle-on" : "fas fa-toggle-off"}
|
|
212
|
+
type={isToggled ? "primary" : "default"}
|
|
213
|
+
onclick={handleToggle}
|
|
214
|
+
/>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Loading State
|
|
218
|
+
|
|
219
|
+
```svelte
|
|
220
|
+
<script>
|
|
221
|
+
let isLoading = false;
|
|
222
|
+
|
|
223
|
+
const handleRefresh = async (event) => {
|
|
224
|
+
isLoading = true;
|
|
225
|
+
try {
|
|
226
|
+
await refreshData();
|
|
227
|
+
} finally {
|
|
228
|
+
isLoading = false;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
</script>
|
|
232
|
+
|
|
233
|
+
<IconButton
|
|
234
|
+
icon={isLoading ? "fas fa-spinner fa-spin" : "fas fa-sync"}
|
|
235
|
+
disabled={isLoading}
|
|
236
|
+
onclick={handleRefresh}
|
|
237
|
+
/>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Contextual Actions
|
|
241
|
+
|
|
242
|
+
```svelte
|
|
243
|
+
<script>
|
|
244
|
+
let showMenu = false;
|
|
245
|
+
|
|
246
|
+
const toggleMenu = (event) => {
|
|
247
|
+
showMenu = !showMenu;
|
|
248
|
+
};
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<div class="menu-container">
|
|
252
|
+
<IconButton
|
|
253
|
+
icon="fas fa-ellipsis-v"
|
|
254
|
+
type={showMenu ? "primary" : "default"}
|
|
255
|
+
onclick={toggleMenu}
|
|
256
|
+
/>
|
|
257
|
+
|
|
258
|
+
{#if showMenu}
|
|
259
|
+
<div class="dropdown-menu">
|
|
260
|
+
<button on:click={editItem}>Edit</button>
|
|
261
|
+
<button on:click={duplicateItem}>Duplicate</button>
|
|
262
|
+
<button on:click={deleteItem}>Delete</button>
|
|
263
|
+
</div>
|
|
264
|
+
{/if}
|
|
265
|
+
</div>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Notification Button
|
|
269
|
+
|
|
270
|
+
```svelte
|
|
271
|
+
<script>
|
|
272
|
+
let notificationCount = 3;
|
|
273
|
+
|
|
274
|
+
const handleNotifications = (event) => {
|
|
275
|
+
// Open notifications panel
|
|
276
|
+
openNotificationsPanel();
|
|
277
|
+
};
|
|
278
|
+
</script>
|
|
279
|
+
|
|
280
|
+
<div class="notification-button">
|
|
281
|
+
<IconButton
|
|
282
|
+
icon="fas fa-bell"
|
|
283
|
+
type={notificationCount > 0 ? "primary" : "default"}
|
|
284
|
+
onclick={handleNotifications}
|
|
285
|
+
/>
|
|
286
|
+
{#if notificationCount > 0}
|
|
287
|
+
<span class="notification-badge">{notificationCount}</span>
|
|
288
|
+
{/if}
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
<style>
|
|
292
|
+
.notification-button {
|
|
293
|
+
position: relative;
|
|
294
|
+
display: inline-block;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.notification-badge {
|
|
298
|
+
position: absolute;
|
|
299
|
+
top: -8px;
|
|
300
|
+
right: -8px;
|
|
301
|
+
background: #ff4444;
|
|
302
|
+
color: white;
|
|
303
|
+
border-radius: 50%;
|
|
304
|
+
width: 20px;
|
|
305
|
+
height: 20px;
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
justify-content: center;
|
|
309
|
+
font-size: 10px;
|
|
310
|
+
font-weight: bold;
|
|
311
|
+
}
|
|
312
|
+
</style>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Media Controls
|
|
316
|
+
|
|
317
|
+
```svelte
|
|
318
|
+
<script>
|
|
319
|
+
let isPlaying = false;
|
|
320
|
+
|
|
321
|
+
const togglePlay = (event) => {
|
|
322
|
+
isPlaying = !isPlaying;
|
|
323
|
+
if (isPlaying) {
|
|
324
|
+
startPlayback();
|
|
325
|
+
} else {
|
|
326
|
+
pausePlayback();
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
</script>
|
|
330
|
+
|
|
331
|
+
<div class="media-controls">
|
|
332
|
+
<IconButton icon="fas fa-step-backward" onclick={previousTrack} />
|
|
333
|
+
<IconButton
|
|
334
|
+
icon={isPlaying ? "fas fa-pause" : "fas fa-play"}
|
|
335
|
+
type="primary"
|
|
336
|
+
size="big"
|
|
337
|
+
onclick={togglePlay}
|
|
338
|
+
/>
|
|
339
|
+
<IconButton icon="fas fa-step-forward" onclick={nextTrack} />
|
|
340
|
+
</div>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Accessibility
|
|
344
|
+
|
|
345
|
+
The IconButton component follows accessibility best practices:
|
|
346
|
+
|
|
347
|
+
- Uses semantic `<button>` element
|
|
348
|
+
- Supports keyboard navigation (Tab, Enter, Space)
|
|
349
|
+
- Proper disabled state handling
|
|
350
|
+
- Focus and blur events for screen readers
|
|
351
|
+
|
|
352
|
+
### Adding ARIA Labels
|
|
353
|
+
|
|
354
|
+
```svelte
|
|
355
|
+
<!-- For screen readers, add aria-label when using icons only -->
|
|
356
|
+
<IconButton
|
|
357
|
+
icon="fas fa-search"
|
|
358
|
+
onclick={handleSearch}
|
|
359
|
+
style="aria-label: Search"
|
|
360
|
+
/>
|
|
361
|
+
|
|
362
|
+
<!-- Or use title attribute for tooltips -->
|
|
363
|
+
<IconButton
|
|
364
|
+
icon="fas fa-print"
|
|
365
|
+
onclick={handlePrint}
|
|
366
|
+
style="title: Print document"
|
|
367
|
+
/>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Styling
|
|
371
|
+
|
|
372
|
+
The component uses the following CSS classes:
|
|
373
|
+
|
|
374
|
+
- `.uniface-button` - Base button class
|
|
375
|
+
- `.icon-button` - Icon button specific styling
|
|
376
|
+
- `.{size}` - Size-specific styles (big, medium, mini)
|
|
377
|
+
- `.{type}` - Type-specific styles (default, primary, etc.)
|
|
378
|
+
- `.disabled` - Disabled state styles
|
|
379
|
+
|
|
380
|
+
### Example CSS
|
|
381
|
+
|
|
382
|
+
```css
|
|
383
|
+
.uniface-button.icon-button {
|
|
384
|
+
display: inline-flex;
|
|
385
|
+
align-items: center;
|
|
386
|
+
justify-content: center;
|
|
387
|
+
width: 32px;
|
|
388
|
+
height: 32px;
|
|
389
|
+
padding: 6px;
|
|
390
|
+
border: 1px solid #ddd;
|
|
391
|
+
background: #fff;
|
|
392
|
+
color: #333;
|
|
393
|
+
border-radius: 4px;
|
|
394
|
+
cursor: pointer;
|
|
395
|
+
transition: all 0.2s ease;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.uniface-button.icon-button:hover:not(.disabled) {
|
|
399
|
+
background: #f5f5f5;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.uniface-button.icon-button:focus {
|
|
403
|
+
outline: 2px solid #007acc;
|
|
404
|
+
outline-offset: 2px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.uniface-button.icon-button.big {
|
|
408
|
+
width: 48px;
|
|
409
|
+
height: 48px;
|
|
410
|
+
padding: 12px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.uniface-button.icon-button.mini {
|
|
414
|
+
width: 24px;
|
|
415
|
+
height: 24px;
|
|
416
|
+
padding: 4px;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.uniface-button.icon-button.primary {
|
|
420
|
+
background: #007acc;
|
|
421
|
+
color: white;
|
|
422
|
+
border-color: #007acc;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.uniface-button.icon-button.disabled {
|
|
426
|
+
opacity: 0.6;
|
|
427
|
+
cursor: not-allowed;
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Best Practices
|
|
432
|
+
|
|
433
|
+
1. **Consistent Icon Library**: Use a consistent icon library (e.g., FontAwesome) across your application
|
|
434
|
+
2. **Appropriate Sizing**: Choose appropriate sizes based on context (toolbar = mini/medium, main actions = big)
|
|
435
|
+
3. **Accessibility**: Always provide aria-label or title for screen readers
|
|
436
|
+
4. **Visual Feedback**: Use different types to indicate state or importance
|
|
437
|
+
5. **Grouping**: Group related icon buttons together
|
|
438
|
+
6. **Tooltips**: Consider adding tooltips for better user experience
|
|
439
|
+
7. **Context**: Ensure icons are easily recognizable and contextually appropriate
|
|
440
|
+
|
|
441
|
+
## Common Patterns
|
|
442
|
+
|
|
443
|
+
### Button Group
|
|
444
|
+
|
|
445
|
+
```svelte
|
|
446
|
+
<div class="icon-button-group">
|
|
447
|
+
<IconButton icon="fas fa-align-left" onclick={alignLeft} />
|
|
448
|
+
<IconButton icon="fas fa-align-center" onclick={alignCenter} />
|
|
449
|
+
<IconButton icon="fas fa-align-right" onclick={alignRight} />
|
|
450
|
+
</div>
|
|
451
|
+
|
|
452
|
+
<style>
|
|
453
|
+
.icon-button-group {
|
|
454
|
+
display: flex;
|
|
455
|
+
border: 1px solid #ddd;
|
|
456
|
+
border-radius: 4px;
|
|
457
|
+
overflow: hidden;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.icon-button-group :global(.uniface-button) {
|
|
461
|
+
border-radius: 0;
|
|
462
|
+
border-left: none;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.icon-button-group :global(.uniface-button:first-child) {
|
|
466
|
+
border-left: 1px solid #ddd;
|
|
467
|
+
}
|
|
468
|
+
</style>
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Floating Action Button
|
|
472
|
+
|
|
473
|
+
```svelte
|
|
474
|
+
<IconButton
|
|
475
|
+
icon="fas fa-plus"
|
|
476
|
+
type="primary"
|
|
477
|
+
size="big"
|
|
478
|
+
onclick={addNewItem}
|
|
479
|
+
style="
|
|
480
|
+
position: fixed;
|
|
481
|
+
bottom: 20px;
|
|
482
|
+
right: 20px;
|
|
483
|
+
border-radius: 50%;
|
|
484
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
485
|
+
"
|
|
486
|
+
/>
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
## Integration with Tooltips
|
|
490
|
+
|
|
491
|
+
```svelte
|
|
492
|
+
<script>
|
|
493
|
+
import Tooltip from '@ticatec/uniface-element/Tooltip';
|
|
494
|
+
</script>
|
|
495
|
+
|
|
496
|
+
<Tooltip text="Save document">
|
|
497
|
+
<IconButton icon="fas fa-save" onclick={handleSave} />
|
|
498
|
+
</Tooltip>
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## Browser Support
|
|
502
|
+
|
|
503
|
+
The IconButton component works in all modern browsers that support:
|
|
504
|
+
- ES6+ JavaScript
|
|
505
|
+
- CSS Flexbox
|
|
506
|
+
- Semantic button elements
|
|
507
|
+
|
|
508
|
+
## Performance
|
|
509
|
+
|
|
510
|
+
- Lightweight icon-focused design
|
|
511
|
+
- Built-in click debouncing
|
|
512
|
+
- Efficient event handling
|
|
513
|
+
- Minimal DOM footprint
|