@kubex/zinc 1.0.25 → 1.0.98
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/.claude/project.md +556 -0
- package/.github/workflows/js_build_and_deploy.yaml +9 -10
- package/dist/custom-elements.json +13431 -8728
- package/dist/vscode.html-custom-data.json +571 -37
- package/dist/web-types.json +1439 -181
- package/dist/zn.d.ts +1642 -661
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1406 -891
- package/docs/_utilities/code-previews.cjs +10 -1
- package/docs/assets/scripts/docs.js +42 -18
- package/docs/data/data-table.json +229 -66
- package/docs/data/empty.json +6 -0
- package/docs/data/products-table.json +41 -193
- package/docs/pages/components/action-bar.md +121 -6
- package/docs/pages/components/alert.md +118 -15
- package/docs/pages/components/animated-button.md +299 -0
- package/docs/pages/components/audio-select.md +534 -0
- package/docs/pages/components/bulk-actions.md +79 -5
- package/docs/pages/components/button-group.md +235 -27
- package/docs/pages/components/button.md +139 -1
- package/docs/pages/components/chart.md +365 -9
- package/docs/pages/components/checkbox.md +387 -58
- package/docs/pages/components/chip.md +253 -33
- package/docs/pages/components/collapsible.md +393 -46
- package/docs/pages/components/cols.md +152 -30
- package/docs/pages/components/confirm.md +182 -16
- package/docs/pages/components/copy-button.md +169 -6
- package/docs/pages/components/data-select.md +194 -15
- package/docs/pages/components/data-table-filter.md +96 -5
- package/docs/pages/components/data-table-search.md +451 -0
- package/docs/pages/components/data-table-sort.md +66 -5
- package/docs/pages/components/data-table.md +727 -66
- package/docs/pages/components/datepicker.md +402 -7
- package/docs/pages/components/defined-label.md +120 -5
- package/docs/pages/components/dialog.md +339 -59
- package/docs/pages/components/dropdown.md +366 -11
- package/docs/pages/components/editor.md +604 -7
- package/docs/pages/components/empty-state.md +315 -16
- package/docs/pages/components/expanding-action.md +212 -28
- package/docs/pages/components/file.md +421 -12
- package/docs/pages/components/filter-container.md +158 -5
- package/docs/pages/components/filter-wrapper.md +167 -6
- package/docs/pages/components/form-group.md +383 -6
- package/docs/pages/components/hover-container.md +237 -6
- package/docs/pages/components/icon-picker.md +121 -0
- package/docs/pages/components/icon.md +454 -48
- package/docs/pages/components/inline-edit.md +787 -19
- package/docs/pages/components/input-group.md +207 -13
- package/docs/pages/components/input.md +194 -0
- package/docs/pages/components/key-container.md +115 -0
- package/docs/pages/components/key.md +101 -0
- package/docs/pages/components/menu.md +512 -6
- package/docs/pages/components/note.md +239 -36
- package/docs/pages/components/opt-group.md +107 -0
- package/docs/pages/components/pagination.md +332 -6
- package/docs/pages/components/pane.md +222 -6
- package/docs/pages/components/panel.md +213 -26
- package/docs/pages/components/popup.md +1354 -6
- package/docs/pages/components/priority-list.md +233 -0
- package/docs/pages/components/progress-bar.md +387 -6
- package/docs/pages/components/radio-group.md +242 -5
- package/docs/pages/components/radio.md +474 -6
- package/docs/pages/components/rating.md +331 -7
- package/docs/pages/components/reveal.md +524 -6
- package/docs/pages/components/scroll-container.md +552 -6
- package/docs/pages/components/select.md +762 -160
- package/docs/pages/components/skeleton.md +473 -30
- package/docs/pages/components/slideout.md +261 -5
- package/docs/pages/components/sp.md +99 -41
- package/docs/pages/components/split-button.md +347 -9
- package/docs/pages/components/split-pane.md +445 -6
- package/docs/pages/components/stat.md +549 -9
- package/docs/pages/components/status-indicator.md +230 -1
- package/docs/pages/components/stepper.md +563 -6
- package/docs/pages/components/tabs.md +439 -13
- package/docs/pages/components/textarea.md +415 -17
- package/docs/pages/components/tile.md +385 -26
- package/docs/pages/components/toggle.md +424 -6
- package/docs/pages/components/tooltip.md +367 -0
- package/docs/pages/components/translation-group.md +210 -0
- package/docs/pages/components/translations.md +319 -19
- package/docs/pages/components/vertical-stepper.md +401 -8
- package/docs/pages/components/well.md +300 -3
- package/docs/pages/getting-started/form-controls.md +162 -0
- package/docs/pages/index.md +116 -15
- package/package.json +5 -6
- package/scss/_global-spacing.scss +4 -0
- package/scss/_root.scss +2 -2
- package/scss/boot.scss +19 -0
- package/scss/shared/layout.scss +5 -0
- package/scss/themes/_light.scss +3 -3
- package/src/components/alert/alert.scss +1 -0
- package/src/components/animated-button/README.md +306 -0
- package/src/components/animated-button/animated-button.component.ts +229 -0
- package/src/components/animated-button/animated-button.scss +228 -0
- package/src/components/animated-button/animated-button.test.ts +143 -0
- package/src/components/animated-button/index.ts +12 -0
- package/src/components/button/button.component.ts +5 -0
- package/src/components/button-group/button-group.component.ts +25 -13
- package/src/components/button-group/button-group.scss +6 -0
- package/src/components/checkbox/checkbox.component.ts +4 -0
- package/src/components/checkbox/checkbox.scss +7 -4
- package/src/components/checkbox-group/checkbox-group.scss +7 -0
- package/src/components/chip/chip.component.ts +7 -2
- package/src/components/chip/chip.scss +16 -2
- package/src/components/collapsible/collapsible.component.ts +27 -20
- package/src/components/cols/cols.component.ts +14 -2
- package/src/components/cols/cols.scss +6 -12
- package/src/components/confirm/confirm.component.ts +7 -0
- package/src/components/copy-button/copy-button.component.ts +12 -11
- package/src/components/data-select/data-select.component.ts +215 -44
- package/src/components/data-select/data-select.scss +66 -6
- package/src/components/data-select/providers/currency-data-provider.ts +20 -6
- package/src/components/data-select/providers/provider.ts +1 -0
- package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
- package/src/components/data-table/data-table.component.ts +81 -22
- package/src/components/data-table-search/data-table-search.component.ts +184 -0
- package/src/components/data-table-search/data-table-search.scss +17 -0
- package/src/components/data-table-search/data-table-search.test.ts +11 -0
- package/src/components/data-table-search/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +347 -13
- package/src/components/dialog/dialog.component.ts +1 -1
- package/src/components/empty-state/empty-state.scss +6 -1
- package/src/components/header/header.scss +3 -3
- package/src/components/icon/icon.component.ts +23 -1
- package/src/components/icon/icon.scss +23 -0
- package/src/components/icon-picker/brand-icons.ts +24 -0
- package/src/components/icon-picker/icon-picker.component.ts +407 -0
- package/src/components/icon-picker/icon-picker.scss +205 -0
- package/src/components/icon-picker/index.ts +12 -0
- package/src/components/icon-picker/line-icons.ts +612 -0
- package/src/components/icon-picker/material-icons.ts +14543 -0
- package/src/components/inline-edit/inline-edit.component.ts +190 -46
- package/src/components/inline-edit/inline-edit.scss +29 -0
- package/src/components/inline-edit/inline-edit.test.ts +314 -1
- package/src/components/input/input.component.ts +324 -5
- package/src/components/input/input.scss +87 -0
- package/src/components/input-group/input-group.component.ts +28 -7
- package/src/components/input-group/input-group.scss +48 -10
- package/src/components/item/item.component.ts +11 -2
- package/src/components/item/item.scss +7 -0
- package/src/components/key/index.ts +12 -0
- package/src/components/key/key.component.ts +47 -0
- package/src/components/key/key.scss +38 -0
- package/src/components/key-container/index.ts +12 -0
- package/src/components/key-container/key-container.component.ts +142 -0
- package/src/components/key-container/key-container.scss +33 -0
- package/src/components/menu-item/menu-item.component.ts +20 -0
- package/src/components/menu-item/menu-item.scss +69 -2
- package/src/components/navbar/navbar.component.ts +103 -11
- package/src/components/navbar/navbar.scss +6 -1
- package/src/components/opt-group/index.ts +12 -0
- package/src/components/opt-group/opt-group.component.ts +74 -0
- package/src/components/opt-group/opt-group.scss +37 -0
- package/src/components/opt-group/opt-group.test.ts +27 -0
- package/src/components/option/option.component.ts +1 -16
- package/src/components/option/option.scss +4 -0
- package/src/components/panel/panel.component.ts +10 -8
- package/src/components/panel/panel.scss +20 -0
- package/src/components/priority-list/index.ts +12 -0
- package/src/components/priority-list/priority-list.component.ts +611 -0
- package/src/components/priority-list/priority-list.scss +185 -0
- package/src/components/priority-list/priority-list.test.ts +139 -0
- package/src/components/progress-bar/progress-bar.component.ts +22 -16
- package/src/components/radio/radio.scss +10 -3
- package/src/components/select/select.component.ts +812 -72
- package/src/components/select/select.scss +108 -2
- package/src/components/select/select.test.ts +147 -2
- package/src/components/settings-container/settings-container.component.ts +44 -19
- package/src/components/settings-container/settings-container.scss +1 -1
- package/src/components/skeleton/skeleton.component.ts +6 -1
- package/src/components/slideout/slideout.scss +8 -3
- package/src/components/sp/sp.component.ts +3 -1
- package/src/components/sp/sp.scss +19 -0
- package/src/components/stepper/stepper.component.ts +16 -10
- package/src/components/textarea/textarea.scss +0 -4
- package/src/components/tile/tile.component.ts +12 -3
- package/src/components/tile/tile.scss +1 -1
- package/src/components/timer/timer.component.ts +15 -2
- package/src/components/toggle/toggle.component.ts +29 -26
- package/src/components/toggle/toggle.scss +13 -1
- package/src/components/translation-group/index.ts +12 -0
- package/src/components/translation-group/translation-group.component.ts +207 -0
- package/src/components/translation-group/translation-group.scss +8 -0
- package/src/components/translations/translations.component.ts +90 -44
- package/src/components/translations/translations.scss +4 -0
- package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
- package/src/events/events.ts +12 -7
- package/src/events/zn-language-change.ts +7 -0
- package/src/events/zn-purchase.ts +11 -0
- package/src/events/zn-redirect.ts +7 -0
- package/src/events/zn-reorder.ts +7 -0
- package/src/events/zn-search-change.ts +11 -0
- package/src/events/zn-submit.ts +1 -1
- package/src/form-control.scss +4 -0
- package/src/internal/form-navigation.ts +510 -0
- package/src/internal/form.ts +6 -0
- package/src/zinc.ts +91 -83
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Rating
|
|
4
|
-
description:
|
|
4
|
+
description: Ratings allow users to view and provide feedback using a star rating system.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,20 +9,344 @@ layout: component
|
|
|
9
9
|
<zn-rating></zn-rating>
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
:::tip
|
|
13
|
+
This component works with standard `<form>` elements. Please refer to the section
|
|
14
|
+
on [form controls](/getting-started/form-controls) to learn more about form submission and client-side validation.
|
|
15
|
+
:::
|
|
16
|
+
|
|
12
17
|
## Examples
|
|
13
18
|
|
|
14
|
-
###
|
|
19
|
+
### Basic Rating
|
|
20
|
+
|
|
21
|
+
A basic rating component displays stars that can be clicked to set a rating value.
|
|
22
|
+
|
|
23
|
+
```html:preview
|
|
24
|
+
<zn-rating label="Rate this product"></zn-rating>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### With Value
|
|
28
|
+
|
|
29
|
+
Use the `value` attribute to set an initial rating value.
|
|
30
|
+
|
|
31
|
+
```html:preview
|
|
32
|
+
<zn-rating value="3" label="Product rating"></zn-rating>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Maximum Rating
|
|
36
|
+
|
|
37
|
+
Use the `max` attribute to change the maximum number of stars. The default is 5.
|
|
38
|
+
|
|
39
|
+
```html:preview
|
|
40
|
+
<zn-rating max="10" value="7" label="Rate out of 10"></zn-rating>
|
|
41
|
+
<br />
|
|
42
|
+
<zn-rating max="3" value="2" label="Difficulty level"></zn-rating>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Precision
|
|
46
|
+
|
|
47
|
+
Use the `precision` attribute to control the granularity of ratings. The default precision is 1 (whole stars).
|
|
48
|
+
|
|
49
|
+
```html:preview
|
|
50
|
+
<zn-rating value="2.5" precision="0.5" label="Half star precision"></zn-rating>
|
|
51
|
+
<br />
|
|
52
|
+
<zn-rating value="3.75" precision="0.25" label="Quarter star precision"></zn-rating>
|
|
53
|
+
<br />
|
|
54
|
+
<zn-rating value="3.33" precision="0.1" label="Tenth star precision"></zn-rating>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Readonly
|
|
58
|
+
|
|
59
|
+
Use the `readonly` attribute to display a rating that cannot be changed. This is useful for showing existing ratings.
|
|
60
|
+
|
|
61
|
+
```html:preview
|
|
62
|
+
<zn-rating value="4" readonly label="Average rating"></zn-rating>
|
|
63
|
+
<br />
|
|
64
|
+
<zn-rating value="3.5" precision="0.5" readonly label="Customer reviews"></zn-rating>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Disabled
|
|
68
|
+
|
|
69
|
+
Use the `disabled` attribute to disable the rating component.
|
|
70
|
+
|
|
71
|
+
```html:preview
|
|
72
|
+
<zn-rating disabled label="Rating disabled"></zn-rating>
|
|
73
|
+
<br />
|
|
74
|
+
<zn-rating value="3" disabled label="Rating disabled with value"></zn-rating>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Sizes
|
|
78
|
+
|
|
79
|
+
Use the `size` attribute to change the rating size. Available sizes are `small`, `medium` (default), and `large`.
|
|
80
|
+
|
|
81
|
+
```html:preview
|
|
82
|
+
<zn-rating size="small" value="3" label="Small rating"></zn-rating>
|
|
83
|
+
<br />
|
|
84
|
+
<zn-rating size="medium" value="3" label="Medium rating"></zn-rating>
|
|
85
|
+
<br />
|
|
86
|
+
<zn-rating size="large" value="3" label="Large rating"></zn-rating>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Custom Symbols
|
|
90
|
+
|
|
91
|
+
Use the `getSymbol` property to customize the symbols displayed. By default, the component uses star icons from the Material icon library.
|
|
92
|
+
|
|
93
|
+
```html:preview
|
|
94
|
+
<zn-rating id="custom-symbol-heart" value="3" label="Rate with hearts"></zn-rating>
|
|
95
|
+
<br />
|
|
96
|
+
<zn-rating id="custom-symbol-emoji" value="4" max="5" label="Rate with emojis"></zn-rating>
|
|
97
|
+
|
|
98
|
+
<script type="module">
|
|
99
|
+
const heartRating = document.querySelector('#custom-symbol-heart');
|
|
100
|
+
heartRating.getSymbol = () => '<zn-icon src="favorite" library="material"></zn-icon>';
|
|
101
|
+
|
|
102
|
+
const emojiRating = document.querySelector('#custom-symbol-emoji');
|
|
103
|
+
emojiRating.getSymbol = () => '<zn-icon src="sentiment_satisfied" library="material"></zn-icon>';
|
|
104
|
+
</script>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Hover Effects
|
|
108
|
+
|
|
109
|
+
The rating component displays hover effects by default, scaling the hovered star and all preceding stars.
|
|
15
110
|
|
|
16
111
|
```html:preview
|
|
112
|
+
<zn-rating value="0" label="Hover to preview rating"></zn-rating>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
:::tip
|
|
116
|
+
**Usage:** Hover effects provide visual feedback to help users understand which rating they will select. The hover effect is automatically disabled for `readonly` and `disabled` ratings.
|
|
117
|
+
:::
|
|
17
118
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
119
|
+
### Form Integration
|
|
120
|
+
|
|
121
|
+
Ratings work seamlessly with forms and will be submitted with form data using the `name` attribute.
|
|
122
|
+
|
|
123
|
+
```html:preview
|
|
124
|
+
<form id="rating-form">
|
|
125
|
+
<zn-rating name="product-rating" value="0" label="Rate this product" required></zn-rating>
|
|
126
|
+
<br />
|
|
127
|
+
<zn-rating name="service-rating" value="4" label="Rate our service"></zn-rating>
|
|
128
|
+
<br /><br />
|
|
129
|
+
<zn-button type="submit" color="primary">Submit Review</zn-button>
|
|
130
|
+
<zn-button type="reset" color="secondary">Reset</zn-button>
|
|
21
131
|
</form>
|
|
132
|
+
|
|
133
|
+
<script type="module">
|
|
134
|
+
const form = document.querySelector('#rating-form');
|
|
135
|
+
form.addEventListener('submit', (event) => {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
const formData = new FormData(form);
|
|
138
|
+
const data = Object.fromEntries(formData.entries());
|
|
139
|
+
alert('Form submitted: ' + JSON.stringify(data, null, 2));
|
|
140
|
+
});
|
|
141
|
+
</script>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Interactive Example with Value Display
|
|
145
|
+
|
|
146
|
+
This example demonstrates how the rating value changes as you interact with the component.
|
|
147
|
+
|
|
148
|
+
```html:preview
|
|
149
|
+
<div>
|
|
150
|
+
<zn-rating id="interactive-rating" value="0" precision="0.5" label="Rate your experience"></zn-rating>
|
|
151
|
+
<div id="rating-value" style="margin-top: 1rem; padding: 0.75rem; background: #f5f5f5; border-radius: 4px;">
|
|
152
|
+
<strong>Current Rating:</strong> <span id="rating-display">0</span> out of 5
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<script type="module">
|
|
157
|
+
const rating = document.querySelector('#interactive-rating');
|
|
158
|
+
const display = document.querySelector('#rating-display');
|
|
159
|
+
|
|
160
|
+
// Update display when rating changes
|
|
161
|
+
const updateDisplay = () => {
|
|
162
|
+
display.textContent = rating.value || '0';
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Listen for value changes
|
|
166
|
+
rating.addEventListener('click', updateDisplay);
|
|
167
|
+
|
|
168
|
+
// Update initial display
|
|
169
|
+
updateDisplay();
|
|
170
|
+
</script>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Clearable Rating
|
|
174
|
+
|
|
175
|
+
Click on the currently selected rating to clear it and set the value back to 0.
|
|
176
|
+
|
|
177
|
+
```html:preview
|
|
178
|
+
<zn-rating value="3" label="Click selected rating to clear"></zn-rating>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
:::tip
|
|
182
|
+
**Usage:** This feature allows users to remove their rating if they change their mind. Clicking on the currently selected star will reset the rating to 0.
|
|
183
|
+
:::
|
|
184
|
+
|
|
185
|
+
### Display Patterns
|
|
186
|
+
|
|
187
|
+
Common patterns for displaying ratings in user interfaces.
|
|
188
|
+
|
|
189
|
+
```html:preview
|
|
190
|
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
|
191
|
+
<zn-rating value="4.5" precision="0.5" readonly size="small"></zn-rating>
|
|
192
|
+
<span style="font-size: 14px; color: #6D7176;">4.5 out of 5 (1,234 reviews)</span>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<br />
|
|
196
|
+
|
|
197
|
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
|
198
|
+
<zn-rating value="3.75" precision="0.25" readonly></zn-rating>
|
|
199
|
+
<span style="font-weight: 600;">3.75</span>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<br />
|
|
203
|
+
|
|
204
|
+
<div style="border: 1px solid #E5E7EB; border-radius: 8px; padding: 1.5rem; max-width: 400px;">
|
|
205
|
+
<h3 style="margin: 0 0 0.5rem 0; font-size: 18px;">Customer Reviews</h3>
|
|
206
|
+
<div style="display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem;">
|
|
207
|
+
<zn-rating value="4.2" precision="0.1" readonly></zn-rating>
|
|
208
|
+
<span style="font-size: 20px; font-weight: 600;">4.2</span>
|
|
209
|
+
<span style="color: #6D7176;">based on 856 reviews</span>
|
|
210
|
+
</div>
|
|
211
|
+
<zn-rating value="0" label="Rate this product"></zn-rating>
|
|
212
|
+
</div>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Accessibility
|
|
216
|
+
|
|
217
|
+
The rating component includes ARIA attributes for accessibility:
|
|
218
|
+
|
|
219
|
+
- Uses `role="slider"` to indicate interactive rating control
|
|
220
|
+
- Provides `aria-label` for screen readers (set via the `label` attribute)
|
|
221
|
+
- Includes `aria-valuenow`, `aria-valuemin`, and `aria-valuemax` attributes
|
|
222
|
+
- Respects `aria-disabled` and `aria-readonly` states
|
|
223
|
+
|
|
224
|
+
```html:preview
|
|
225
|
+
<zn-rating value="3" label="Product quality rating" max="5"></zn-rating>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
:::tip
|
|
229
|
+
**Best Practice:** Always provide a descriptive `label` attribute to ensure screen reader users understand what they are rating.
|
|
230
|
+
:::
|
|
231
|
+
|
|
232
|
+
### Touch Support
|
|
233
|
+
|
|
234
|
+
The rating component fully supports touch interactions for mobile devices.
|
|
235
|
+
|
|
236
|
+
```html:preview
|
|
237
|
+
<zn-rating value="0" label="Try on touch device"></zn-rating>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
:::tip
|
|
241
|
+
**Usage:** Touch events are handled alongside mouse events, allowing users to drag their finger across the stars to preview and select a rating. The component will update the rating when the touch ends.
|
|
242
|
+
:::
|
|
243
|
+
|
|
244
|
+
### Custom Styling
|
|
245
|
+
|
|
246
|
+
Use CSS custom properties to customize the appearance of the rating component.
|
|
247
|
+
|
|
248
|
+
```html:preview
|
|
249
|
+
<style>
|
|
250
|
+
.custom-rating {
|
|
251
|
+
--symbol-color: #CBD5E1;
|
|
252
|
+
--symbol-color-active: #3B82F6;
|
|
253
|
+
--symbol-size: 2rem;
|
|
254
|
+
--symbol-spacing: 8px;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.custom-rating-gold {
|
|
258
|
+
--symbol-color: #E5E7EB;
|
|
259
|
+
--symbol-color-active: #F59E0B;
|
|
260
|
+
--symbol-size: 1.5rem;
|
|
261
|
+
}
|
|
262
|
+
</style>
|
|
263
|
+
|
|
264
|
+
<zn-rating class="custom-rating" value="4" label="Custom blue rating"></zn-rating>
|
|
265
|
+
<br />
|
|
266
|
+
<zn-rating class="custom-rating-gold" value="3.5" precision="0.5" label="Custom gold rating"></zn-rating>
|
|
22
267
|
```
|
|
23
268
|
|
|
24
|
-
|
|
269
|
+
Available CSS custom properties:
|
|
270
|
+
|
|
271
|
+
- `--symbol-color` - Color of unfilled symbols
|
|
272
|
+
- `--symbol-color-active` - Color of filled/active symbols
|
|
273
|
+
- `--symbol-size` - Size of the symbols
|
|
274
|
+
- `--symbol-spacing` - Spacing between symbols
|
|
275
|
+
|
|
276
|
+
### Complete Example
|
|
277
|
+
|
|
278
|
+
Here's a comprehensive example demonstrating multiple rating features in a product review form:
|
|
279
|
+
|
|
280
|
+
```html:preview
|
|
281
|
+
<form id="complete-rating-form" style="max-width: 500px; padding: 1.5rem; border: 1px solid #E5E7EB; border-radius: 8px;">
|
|
282
|
+
<h3 style="margin: 0 0 1.5rem 0;">Product Review</h3>
|
|
283
|
+
|
|
284
|
+
<zn-rating
|
|
285
|
+
name="overall-rating"
|
|
286
|
+
value="0"
|
|
287
|
+
label="Overall Rating"
|
|
288
|
+
max="5"
|
|
289
|
+
precision="0.5"
|
|
290
|
+
required
|
|
291
|
+
></zn-rating>
|
|
292
|
+
|
|
293
|
+
<br />
|
|
294
|
+
|
|
295
|
+
<zn-rating
|
|
296
|
+
name="quality-rating"
|
|
297
|
+
value="0"
|
|
298
|
+
label="Quality"
|
|
299
|
+
max="5"
|
|
300
|
+
size="small"
|
|
301
|
+
></zn-rating>
|
|
302
|
+
|
|
303
|
+
<br />
|
|
304
|
+
|
|
305
|
+
<zn-rating
|
|
306
|
+
name="value-rating"
|
|
307
|
+
value="0"
|
|
308
|
+
label="Value for Money"
|
|
309
|
+
max="5"
|
|
310
|
+
size="small"
|
|
311
|
+
></zn-rating>
|
|
312
|
+
|
|
313
|
+
<br />
|
|
25
314
|
|
|
26
|
-
|
|
315
|
+
<zn-rating
|
|
316
|
+
name="ease-rating"
|
|
317
|
+
value="0"
|
|
318
|
+
label="Ease of Use"
|
|
319
|
+
max="5"
|
|
320
|
+
size="small"
|
|
321
|
+
></zn-rating>
|
|
322
|
+
|
|
323
|
+
<br /><br />
|
|
324
|
+
<zn-button type="submit" color="primary">Submit Review</zn-button>
|
|
325
|
+
<zn-button type="reset" color="secondary">Reset</zn-button>
|
|
326
|
+
</form>
|
|
327
|
+
|
|
328
|
+
<div id="review-output" style="margin-top: 1rem; padding: 1rem; background: #f5f5f5; border-radius: 4px; display: none;">
|
|
329
|
+
<strong>Review Data:</strong>
|
|
330
|
+
<pre id="review-data" style="margin-top: 0.5rem; white-space: pre-wrap;"></pre>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
<script type="module">
|
|
334
|
+
const form = document.querySelector('#complete-rating-form');
|
|
335
|
+
const output = document.querySelector('#review-output');
|
|
336
|
+
const dataDisplay = document.querySelector('#review-data');
|
|
337
|
+
|
|
338
|
+
form.addEventListener('submit', (event) => {
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
const formData = new FormData(form);
|
|
341
|
+
const data = Object.fromEntries(formData.entries());
|
|
342
|
+
dataDisplay.textContent = JSON.stringify(data, null, 2);
|
|
343
|
+
output.style.display = 'block';
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
form.addEventListener('reset', () => {
|
|
347
|
+
output.style.display = 'none';
|
|
348
|
+
});
|
|
349
|
+
</script>
|
|
350
|
+
```
|
|
27
351
|
|
|
28
352
|
|