@webtides/element-library 0.1.2 → 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/CHANGELOG.md +390 -3
- package/README.md +61 -41
- package/all.js +28 -0
- package/catalog.d.ts +14 -0
- package/catalog.js +63 -0
- package/custom-elements.json +16604 -3420
- package/package.json +37 -25
- package/src/components/accordion/accordion.changelog.md +10 -0
- package/src/components/accordion/accordion.js +10 -7
- package/src/components/accordion/accordion.readme.md +2 -0
- package/src/components/accordion/accordion.style.js +8 -0
- package/src/components/amount-field/amount-field.changelog.md +23 -3
- package/src/components/amount-field/amount-field.js +53 -26
- package/src/components/amount-field/amount-field.readme.md +82 -20
- package/src/components/amount-field/amount-field.style.js +111 -47
- package/src/components/avatar/avatar.changelog.md +23 -0
- package/src/components/avatar/avatar.define.js +3 -0
- package/src/components/avatar/avatar.js +115 -0
- package/src/components/avatar/avatar.readme.md +132 -0
- package/src/components/avatar/avatar.style.js +67 -0
- package/src/components/badge/badge.changelog.md +23 -0
- package/src/components/badge/badge.define.js +3 -0
- package/src/components/badge/badge.js +59 -0
- package/src/components/badge/badge.readme.md +109 -0
- package/src/components/badge/badge.style.js +63 -0
- package/src/components/breadcrumb/breadcrumb.changelog.md +22 -0
- package/src/components/breadcrumb/breadcrumb.define.js +3 -0
- package/src/components/breadcrumb/breadcrumb.js +47 -0
- package/src/components/breadcrumb/breadcrumb.readme.md +108 -0
- package/src/components/breadcrumb/breadcrumb.style.js +20 -0
- package/src/components/breadcrumb-item/breadcrumb-item.changelog.md +23 -0
- package/src/components/breadcrumb-item/breadcrumb-item.define.js +3 -0
- package/src/components/breadcrumb-item/breadcrumb-item.js +82 -0
- package/src/components/breadcrumb-item/breadcrumb-item.readme.md +106 -0
- package/src/components/breadcrumb-item/breadcrumb-item.style.js +92 -0
- package/src/components/button/button.changelog.md +34 -1
- package/src/components/button/button.js +285 -29
- package/src/components/button/button.readme.md +130 -10
- package/src/components/button/button.style.js +99 -120
- package/src/components/button-group/button-group.changelog.md +24 -0
- package/src/components/button-group/button-group.define.js +3 -0
- package/src/components/button-group/button-group.js +53 -0
- package/src/components/button-group/button-group.readme.md +114 -0
- package/src/components/button-group/button-group.style.js +41 -0
- package/src/components/card/card.changelog.md +23 -0
- package/src/components/card/card.define.js +3 -0
- package/src/components/card/card.js +73 -0
- package/src/components/card/card.readme.md +136 -0
- package/src/components/card/card.style.js +99 -0
- package/src/components/carousel/carousel.changelog.md +20 -0
- package/src/components/carousel/carousel.js +89 -40
- package/src/components/carousel/carousel.readme.md +39 -6
- package/src/components/carousel/carousel.style.js +21 -77
- package/src/components/carousel/glide/components/ShadowAnchors.js +3 -1
- package/src/components/carousel/glide/components/ShadowClones.js +21 -24
- package/src/components/carousel/glide/components/ShadowGaps.js +2 -2
- package/src/components/carousel/glide/components/ShadowHtml.js +22 -3
- package/src/components/checkbox-field/checkbox-field.changelog.md +19 -0
- package/src/components/checkbox-field/checkbox-field.js +25 -10
- package/src/components/checkbox-field/checkbox-field.readme.md +17 -4
- package/src/components/checkbox-field/checkbox-field.style.js +15 -3
- package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +25 -0
- package/src/components/checkbox-group-field/checkbox-group-field.define.js +3 -0
- package/src/components/checkbox-group-field/checkbox-group-field.js +217 -0
- package/src/components/checkbox-group-field/checkbox-group-field.readme.md +95 -0
- package/src/components/checkbox-group-field/checkbox-group-field.style.js +62 -0
- package/src/components/color-field/color-field.changelog.md +24 -0
- package/src/components/color-field/color-field.define.js +3 -0
- package/src/components/color-field/color-field.js +184 -0
- package/src/components/color-field/color-field.readme.md +95 -0
- package/src/components/color-field/color-field.style.js +39 -0
- package/src/components/combobox-field/combobox-field.changelog.md +23 -0
- package/src/components/combobox-field/combobox-field.define.js +3 -0
- package/src/components/combobox-field/combobox-field.js +97 -0
- package/src/components/combobox-field/combobox-field.readme.md +93 -0
- package/src/components/combobox-field/combobox-field.style.js +56 -0
- package/src/components/copy-button/copy-button.changelog.md +24 -0
- package/src/components/copy-button/copy-button.define.js +3 -0
- package/src/components/copy-button/copy-button.events.js +4 -0
- package/src/components/copy-button/copy-button.js +237 -0
- package/src/components/copy-button/copy-button.readme.md +134 -0
- package/src/components/copy-button/copy-button.style.js +109 -0
- package/src/components/date-field/date-field.changelog.md +24 -0
- package/src/components/date-field/date-field.define.js +3 -0
- package/src/components/date-field/date-field.js +119 -0
- package/src/components/date-field/date-field.readme.md +110 -0
- package/src/components/date-field/date-field.style.js +53 -0
- package/src/components/dialog/dialog.changelog.md +16 -1
- package/src/components/dialog/dialog.js +252 -57
- package/src/components/dialog/dialog.readme.md +36 -4
- package/src/components/dialog/dialog.style.js +9 -109
- package/src/components/divider/divider.changelog.md +23 -0
- package/src/components/divider/divider.define.js +3 -0
- package/src/components/divider/divider.js +48 -0
- package/src/components/divider/divider.readme.md +101 -0
- package/src/components/divider/divider.style.js +50 -0
- package/src/components/drawer/drawer.changelog.md +25 -0
- package/src/components/drawer/drawer.define.js +3 -0
- package/src/components/drawer/drawer.events.js +8 -0
- package/src/components/drawer/drawer.js +80 -0
- package/src/components/drawer/drawer.readme.md +194 -0
- package/src/components/drawer/drawer.style.js +83 -0
- package/src/components/dropdown/dropdown.js +9 -7
- package/src/components/empty-state/empty-state.changelog.md +22 -0
- package/src/components/empty-state/empty-state.define.js +3 -0
- package/src/components/empty-state/empty-state.js +55 -0
- package/src/components/empty-state/empty-state.readme.md +114 -0
- package/src/components/empty-state/empty-state.style.js +60 -0
- package/src/components/file-field/file-field.changelog.md +24 -0
- package/src/components/file-field/file-field.define.js +3 -0
- package/src/components/file-field/file-field.js +205 -0
- package/src/components/file-field/file-field.readme.md +103 -0
- package/src/components/file-field/file-field.style.js +28 -0
- package/src/components/form-field/form-field.changelog.md +25 -0
- package/src/components/form-field/form-field.js +212 -15
- package/src/components/form-field/form-field.readme.md +82 -18
- package/src/components/form-field/form-field.style.js +6 -24
- package/src/components/input-field/input-field.changelog.md +24 -0
- package/src/components/input-field/input-field.js +82 -6
- package/src/components/input-field/input-field.readme.md +34 -5
- package/src/components/input-field/input-field.style.js +32 -13
- package/src/components/notification/notification.changelog.md +21 -1
- package/src/components/notification/notification.js +80 -74
- package/src/components/notification/notification.readme.md +54 -13
- package/src/components/notification/notification.style.js +37 -22
- package/src/components/otp-field/otp-field.changelog.md +23 -0
- package/src/components/otp-field/otp-field.define.js +3 -0
- package/src/components/otp-field/otp-field.events.js +3 -0
- package/src/components/otp-field/otp-field.js +172 -0
- package/src/components/otp-field/otp-field.readme.md +111 -0
- package/src/components/otp-field/otp-field.style.js +53 -0
- package/src/components/pagination/pagination.changelog.md +30 -0
- package/src/components/pagination/pagination.define.js +3 -0
- package/src/components/pagination/pagination.events.js +3 -0
- package/src/components/pagination/pagination.js +282 -0
- package/src/components/pagination/pagination.readme.md +167 -0
- package/src/components/pagination/pagination.style.js +162 -0
- package/src/components/password-field/password-field.changelog.md +24 -0
- package/src/components/password-field/password-field.js +7 -1
- package/src/components/password-field/password-field.readme.md +15 -6
- package/src/components/password-field/password-field.style.js +36 -13
- package/src/components/popover/popover.changelog.md +24 -0
- package/src/components/popover/popover.define.js +3 -0
- package/src/components/popover/popover.events.js +4 -0
- package/src/components/popover/popover.js +255 -0
- package/src/components/popover/popover.readme.md +132 -0
- package/src/components/popover/popover.style.js +41 -0
- package/src/components/progress-bar/progress-bar.changelog.md +23 -0
- package/src/components/progress-bar/progress-bar.define.js +3 -0
- package/src/components/progress-bar/progress-bar.js +80 -0
- package/src/components/progress-bar/progress-bar.readme.md +110 -0
- package/src/components/progress-bar/progress-bar.style.js +93 -0
- package/src/components/progress-ring/progress-ring.changelog.md +23 -0
- package/src/components/progress-ring/progress-ring.define.js +3 -0
- package/src/components/progress-ring/progress-ring.js +83 -0
- package/src/components/progress-ring/progress-ring.readme.md +115 -0
- package/src/components/progress-ring/progress-ring.style.js +85 -0
- package/src/components/radio-field/radio-field.changelog.md +16 -0
- package/src/components/radio-field/radio-field.js +34 -11
- package/src/components/radio-field/radio-field.readme.md +13 -8
- package/src/components/radio-field/radio-field.style.js +17 -65
- package/src/components/range-field/range-field.changelog.md +24 -0
- package/src/components/range-field/range-field.define.js +3 -0
- package/src/components/range-field/range-field.js +167 -0
- package/src/components/range-field/range-field.readme.md +87 -0
- package/src/components/range-field/range-field.style.js +41 -0
- package/src/components/rating-field/rating-field.changelog.md +24 -0
- package/src/components/rating-field/rating-field.define.js +3 -0
- package/src/components/rating-field/rating-field.js +195 -0
- package/src/components/rating-field/rating-field.readme.md +82 -0
- package/src/components/rating-field/rating-field.style.js +79 -0
- package/src/components/select-field/select-field.changelog.md +17 -0
- package/src/components/select-field/select-field.js +100 -8
- package/src/components/select-field/select-field.readme.md +32 -6
- package/src/components/select-field/select-field.style.js +19 -9
- package/src/components/skeleton/skeleton.changelog.md +22 -0
- package/src/components/skeleton/skeleton.define.js +3 -0
- package/src/components/skeleton/skeleton.js +49 -0
- package/src/components/skeleton/skeleton.readme.md +115 -0
- package/src/components/skeleton/skeleton.style.js +79 -0
- package/src/components/slider/slider.changelog.md +15 -0
- package/src/components/slider/slider.js +37 -5
- package/src/components/slider/slider.readme.md +28 -6
- package/src/components/slider/slider.style.js +7 -71
- package/src/components/spinner/spinner.changelog.md +22 -0
- package/src/components/spinner/spinner.define.js +3 -0
- package/src/components/spinner/spinner.js +48 -0
- package/src/components/spinner/spinner.readme.md +98 -0
- package/src/components/spinner/spinner.style.js +44 -0
- package/src/components/switch-field/switch-field.changelog.md +16 -0
- package/src/components/switch-field/switch-field.js +17 -9
- package/src/components/switch-field/switch-field.readme.md +11 -4
- package/src/components/switch-field/switch-field.style.js +13 -13
- package/src/components/tab-group/tab-group.changelog.md +19 -0
- package/src/components/tab-group/tab-group.js +122 -10
- package/src/components/tab-group/tab-group.readme.md +25 -4
- package/src/components/tab-link/tab-link.changelog.md +16 -0
- package/src/components/tab-link/tab-link.js +51 -8
- package/src/components/tab-link/tab-link.readme.md +14 -8
- package/src/components/tab-link/tab-link.style.js +13 -0
- package/src/components/tab-panel/tab-panel.changelog.md +8 -2
- package/src/components/tab-panel/tab-panel.js +7 -3
- package/src/components/tab-panel/tab-panel.readme.md +7 -5
- package/src/components/tag/tag.changelog.md +24 -0
- package/src/components/tag/tag.define.js +3 -0
- package/src/components/tag/tag.events.js +3 -0
- package/src/components/tag/tag.js +116 -0
- package/src/components/tag/tag.readme.md +119 -0
- package/src/components/tag/tag.style.js +101 -0
- package/src/components/tag-field/tag-field.changelog.md +25 -0
- package/src/components/tag-field/tag-field.define.js +3 -0
- package/src/components/tag-field/tag-field.js +359 -0
- package/src/components/tag-field/tag-field.readme.md +113 -0
- package/src/components/tag-field/tag-field.style.js +62 -0
- package/src/components/textarea-field/textarea-field.changelog.md +28 -4
- package/src/components/textarea-field/textarea-field.js +68 -14
- package/src/components/textarea-field/textarea-field.readme.md +45 -9
- package/src/components/textarea-field/textarea-field.style.js +45 -2
- package/src/components/toast/toast.changelog.md +24 -0
- package/src/components/toast/toast.define.js +3 -0
- package/src/components/toast/toast.js +193 -0
- package/src/components/toast/toast.readme.md +189 -0
- package/src/components/toast/toast.style.js +74 -0
- package/src/components/tooltip/tooltip.changelog.md +24 -0
- package/src/components/tooltip/tooltip.define.js +3 -0
- package/src/components/tooltip/tooltip.events.js +4 -0
- package/src/components/tooltip/tooltip.js +377 -0
- package/src/components/tooltip/tooltip.readme.md +172 -0
- package/src/components/tooltip/tooltip.style.js +107 -0
- package/src/components/transition-classes/transition-classes.js +6 -6
- package/src/styles/appearance.style.js +42 -0
- package/src/styles/arrow.style.js +65 -0
- package/src/styles/choice-group.style.js +94 -0
- package/src/styles/form-control.style.js +79 -0
- package/src/styles/host.style.js +55 -0
- package/src/styles/layers.css +31 -0
- package/src/styles/modal.style.js +146 -0
- package/src/styles/native.css +275 -0
- package/src/styles/size.style.js +48 -0
- package/src/styles/slide-controls.style.js +225 -0
- package/src/styles/utilities.css +30 -0
- package/src/styles/variants.style.js +78 -0
- package/src/themes/default.css +86 -142
- package/src/themes/high-contrast.css +72 -129
- package/src/themes/sketchy.css +95 -175
- package/src/utils/floating.js +71 -0
- package/src/utils/focus.js +18 -0
- package/src/utils/progress.js +25 -0
- package/src/utils/slots.js +21 -0
- package/src/utils/text-entry-attributes.js +51 -0
- package/types/all.d.ts +54 -1
- package/types/index.d.ts +1 -0
- package/types/src/components/accordion/accordion.d.ts +6 -4
- package/types/src/components/accordion/accordion.events.d.ts +3 -3
- package/types/src/components/accordion-group/accordion-group.d.ts +4 -3
- package/types/src/components/amount-field/amount-field.d.ts +30 -16
- package/types/src/components/avatar/avatar.d.ts +57 -0
- package/types/src/components/avatar/avatar.define.d.ts +1 -0
- package/types/src/components/avatar/avatar.style.d.ts +2 -0
- package/types/src/components/badge/badge.d.ts +32 -0
- package/types/src/components/badge/badge.define.d.ts +1 -0
- package/types/src/components/badge/badge.style.d.ts +2 -0
- package/types/src/components/breadcrumb/breadcrumb.d.ts +27 -0
- package/types/src/components/breadcrumb/breadcrumb.define.d.ts +1 -0
- package/types/src/components/breadcrumb/breadcrumb.style.d.ts +2 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.d.ts +38 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.define.d.ts +1 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.style.d.ts +2 -0
- package/types/src/components/button/button.d.ts +129 -14
- package/types/src/components/button-group/button-group.d.ts +28 -0
- package/types/src/components/button-group/button-group.define.d.ts +1 -0
- package/types/src/components/button-group/button-group.style.d.ts +2 -0
- package/types/src/components/card/card.d.ts +40 -0
- package/types/src/components/card/card.define.d.ts +1 -0
- package/types/src/components/card/card.style.d.ts +2 -0
- package/types/src/components/carousel/carousel.d.ts +22 -8
- package/types/src/components/carousel/carousel.events.d.ts +3 -3
- package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -1
- package/types/src/components/carousel/glide/components/ShadowClones.d.ts +8 -1
- package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -1
- package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -1
- package/types/src/components/carousel/glide/components/glide-html.d.ts +1 -1
- package/types/src/components/checkbox-field/checkbox-field.d.ts +22 -15
- package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +100 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.define.d.ts +1 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.style.d.ts +2 -0
- package/types/src/components/color-field/color-field.d.ts +102 -0
- package/types/src/components/color-field/color-field.define.d.ts +1 -0
- package/types/src/components/color-field/color-field.style.d.ts +2 -0
- package/types/src/components/combobox-field/combobox-field.d.ts +84 -0
- package/types/src/components/combobox-field/combobox-field.define.d.ts +1 -0
- package/types/src/components/combobox-field/combobox-field.style.d.ts +2 -0
- package/types/src/components/copy-button/copy-button.d.ts +93 -0
- package/types/src/components/copy-button/copy-button.define.d.ts +1 -0
- package/types/src/components/copy-button/copy-button.events.d.ts +5 -0
- package/types/src/components/copy-button/copy-button.style.d.ts +2 -0
- package/types/src/components/date-field/date-field.d.ts +102 -0
- package/types/src/components/date-field/date-field.define.d.ts +1 -0
- package/types/src/components/date-field/date-field.style.d.ts +2 -0
- package/types/src/components/dialog/dialog.d.ts +101 -19
- package/types/src/components/dialog/dialog.events.d.ts +8 -8
- package/types/src/components/divider/divider.d.ts +27 -0
- package/types/src/components/divider/divider.define.d.ts +1 -0
- package/types/src/components/divider/divider.style.d.ts +2 -0
- package/types/src/components/drawer/drawer.d.ts +70 -0
- package/types/src/components/drawer/drawer.define.d.ts +1 -0
- package/types/src/components/drawer/drawer.events.d.ts +9 -0
- package/types/src/components/drawer/drawer.style.d.ts +2 -0
- package/types/src/components/dropdown/dropdown.d.ts +5 -3
- package/types/src/components/empty-state/empty-state.d.ts +29 -0
- package/types/src/components/empty-state/empty-state.define.d.ts +1 -0
- package/types/src/components/empty-state/empty-state.style.d.ts +2 -0
- package/types/src/components/file-field/file-field.d.ts +115 -0
- package/types/src/components/file-field/file-field.define.d.ts +1 -0
- package/types/src/components/file-field/file-field.style.d.ts +2 -0
- package/types/src/components/form-field/form-field.d.ts +129 -14
- package/types/src/components/form-field/form-field.events.d.ts +4 -4
- package/types/src/components/input-field/input-field.d.ts +52 -5
- package/types/src/components/lazy-src/lazy-src.d.ts +7 -5
- package/types/src/components/lazy-src/lazy-src.events.d.ts +5 -5
- package/types/src/components/notification/notification.d.ts +18 -18
- package/types/src/components/notification/notification.events.d.ts +6 -6
- package/types/src/components/otp-field/otp-field.d.ts +130 -0
- package/types/src/components/otp-field/otp-field.define.d.ts +1 -0
- package/types/src/components/otp-field/otp-field.events.d.ts +4 -0
- package/types/src/components/otp-field/otp-field.style.d.ts +2 -0
- package/types/src/components/pagination/pagination.d.ts +117 -0
- package/types/src/components/pagination/pagination.define.d.ts +1 -0
- package/types/src/components/pagination/pagination.events.d.ts +4 -0
- package/types/src/components/pagination/pagination.style.d.ts +2 -0
- package/types/src/components/password-field/password-field.d.ts +29 -12
- package/types/src/components/popover/popover.d.ts +123 -0
- package/types/src/components/popover/popover.define.d.ts +1 -0
- package/types/src/components/popover/popover.events.d.ts +5 -0
- package/types/src/components/popover/popover.style.d.ts +2 -0
- package/types/src/components/progress-bar/progress-bar.d.ts +35 -0
- package/types/src/components/progress-bar/progress-bar.define.d.ts +1 -0
- package/types/src/components/progress-bar/progress-bar.style.d.ts +2 -0
- package/types/src/components/progress-ring/progress-ring.d.ts +40 -0
- package/types/src/components/progress-ring/progress-ring.define.d.ts +1 -0
- package/types/src/components/progress-ring/progress-ring.style.d.ts +2 -0
- package/types/src/components/radio-field/radio-field.d.ts +21 -9
- package/types/src/components/range-field/range-field.d.ts +94 -0
- package/types/src/components/range-field/range-field.define.d.ts +1 -0
- package/types/src/components/range-field/range-field.style.d.ts +2 -0
- package/types/src/components/rating-field/rating-field.d.ts +96 -0
- package/types/src/components/rating-field/rating-field.define.d.ts +1 -0
- package/types/src/components/rating-field/rating-field.style.d.ts +2 -0
- package/types/src/components/scroll-to/scroll-to.d.ts +3 -2
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +4 -2
- package/types/src/components/select-field/select-field.d.ts +55 -5
- package/types/src/components/skeleton/skeleton.d.ts +29 -0
- package/types/src/components/skeleton/skeleton.define.d.ts +1 -0
- package/types/src/components/skeleton/skeleton.style.d.ts +2 -0
- package/types/src/components/slider/slider.d.ts +14 -8
- package/types/src/components/slider/slider.events.d.ts +4 -4
- package/types/src/components/spinner/spinner.d.ts +28 -0
- package/types/src/components/spinner/spinner.define.d.ts +1 -0
- package/types/src/components/spinner/spinner.style.d.ts +2 -0
- package/types/src/components/sticky/sticky.d.ts +4 -2
- package/types/src/components/svg-use/svg-use.d.ts +4 -2
- package/types/src/components/switch-field/switch-field.d.ts +17 -15
- package/types/src/components/tab-group/tab-group.d.ts +44 -3
- package/types/src/components/tab-link/tab-link.d.ts +33 -10
- package/types/src/components/tab-panel/tab-panel.d.ts +8 -5
- package/types/src/components/tag/tag.d.ts +53 -0
- package/types/src/components/tag/tag.define.d.ts +1 -0
- package/types/src/components/tag/tag.events.d.ts +4 -0
- package/types/src/components/tag/tag.style.d.ts +2 -0
- package/types/src/components/tag-field/tag-field.d.ts +178 -0
- package/types/src/components/tag-field/tag-field.define.d.ts +1 -0
- package/types/src/components/tag-field/tag-field.style.d.ts +2 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +44 -4
- package/types/src/components/toast/toast.d.ts +110 -0
- package/types/src/components/toast/toast.define.d.ts +1 -0
- package/types/src/components/toast/toast.style.d.ts +2 -0
- package/types/src/components/tooltip/tooltip.d.ts +161 -0
- package/types/src/components/tooltip/tooltip.define.d.ts +1 -0
- package/types/src/components/tooltip/tooltip.events.d.ts +5 -0
- package/types/src/components/tooltip/tooltip.style.d.ts +2 -0
- package/types/src/components/transition-classes/transition-classes.d.ts +9 -8
- package/types/src/styles/appearance.style.d.ts +18 -0
- package/types/src/styles/arrow.style.d.ts +15 -0
- package/types/src/styles/choice-group.style.d.ts +23 -0
- package/types/src/styles/form-control.style.d.ts +26 -0
- package/types/src/styles/host.style.d.ts +24 -0
- package/types/src/styles/modal.style.d.ts +20 -0
- package/types/src/styles/size.style.d.ts +20 -0
- package/types/src/styles/slide-controls.style.d.ts +20 -0
- package/types/src/styles/variants.style.d.ts +32 -0
- package/types/src/utils/body-scroll.d.ts +12 -2
- package/types/src/utils/floating.d.ts +36 -0
- package/types/src/utils/focus.d.ts +16 -0
- package/types/src/utils/progress.d.ts +19 -0
- package/types/src/utils/slots.d.ts +19 -0
- package/types/src/utils/text-entry-attributes.d.ts +18 -0
- package/types/src/utils/transitions.d.ts +2 -2
- package/web-types.json +6590 -1584
|
@@ -1,58 +1,122 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import formControlStyle from '../../styles/form-control.style.js';
|
|
3
|
+
|
|
1
4
|
const css = String.raw;
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const style = css`
|
|
7
|
+
el-amount-field {
|
|
8
|
+
.stepper {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
align-items: center;
|
|
12
|
+
border: var(--el-border-width, 0) solid var(--el-color-border, transparent);
|
|
13
|
+
border-radius: var(--el-radius-md, 0);
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
width: fit-content;
|
|
16
|
+
/* As wide as its content in the row of the field as well, where it would shrink. */
|
|
17
|
+
flex: none;
|
|
18
|
+
}
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
.step {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
background: var(--el-color-bg-muted, transparent);
|
|
23
|
+
color: var(--el-color-fg, inherit);
|
|
24
|
+
border: 0;
|
|
25
|
+
padding: var(--el-space-2, 0) var(--el-space-3, 0);
|
|
26
|
+
min-height: var(--el-touch-target, auto);
|
|
27
|
+
font: inherit;
|
|
28
|
+
}
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/* The stepper cuts off what is outside of it, a ring around one of its parts as well. So the
|
|
31
|
+
part that has the keyboard focus shows it inside of itself. */
|
|
32
|
+
.step:focus-visible,
|
|
33
|
+
input:focus-visible {
|
|
34
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
|
|
35
|
+
outline-offset: calc(-1 * var(--el-focus-ring-width, 2px));
|
|
36
|
+
}
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
/* The ring of a button follows the inner corners of the stepper, on the side where the button
|
|
39
|
+
meets them. With the ring only: at rest the stepper cuts the corners of its buttons, and
|
|
40
|
+
they have none of their own. A radius of the theme that is not one length leaves the ring
|
|
41
|
+
square. */
|
|
42
|
+
.plus:focus-visible {
|
|
43
|
+
border-start-start-radius: max(0px, var(--el-radius-md, 0px) - var(--el-border-width, 0px));
|
|
44
|
+
border-end-start-radius: max(0px, var(--el-radius-md, 0px) - var(--el-border-width, 0px));
|
|
45
|
+
}
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-moz-appearance: textfield;
|
|
38
|
-
border: 0;
|
|
39
|
-
background: var(--el-color-bg, transparent);
|
|
40
|
-
color: var(--el-color-fg, inherit);
|
|
41
|
-
padding: var(--el-space-2, 0) var(--el-space-3, 0);
|
|
42
|
-
min-width: var(--el-touch-target, auto);
|
|
43
|
-
font: inherit;
|
|
44
|
-
}
|
|
47
|
+
.minus:focus-visible {
|
|
48
|
+
border-start-end-radius: max(0px, var(--el-radius-md, 0px) - var(--el-border-width, 0px));
|
|
49
|
+
border-end-end-radius: max(0px, var(--el-radius-md, 0px) - var(--el-border-width, 0px));
|
|
50
|
+
}
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
/* The signs are strings of the stylesheet, so a page can set its own. */
|
|
53
|
+
.plus::before {
|
|
54
|
+
content: var(--el-amount-field-plus, '+');
|
|
55
|
+
}
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
.minus::before {
|
|
58
|
+
content: var(--el-amount-field-minus, '-');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.step:hover:not(:disabled) {
|
|
62
|
+
background: var(--el-color-border, transparent);
|
|
63
|
+
}
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
.step:disabled {
|
|
66
|
+
opacity: 0.5;
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* A disabled field, by its own disabled or by a fieldset around it: the stepper fades as a
|
|
71
|
+
whole, as the control of every other field does, so the number says it as well. The
|
|
72
|
+
buttons do not fade a second time. A button at its bound alone is the rule above. */
|
|
73
|
+
.stepper:has(input:disabled) {
|
|
74
|
+
opacity: 0.55;
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.stepper:has(input:disabled) .step {
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
input:disabled {
|
|
83
|
+
cursor: not-allowed;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
input {
|
|
87
|
+
text-align: center;
|
|
88
|
+
appearance: none;
|
|
89
|
+
-webkit-appearance: none;
|
|
90
|
+
-moz-appearance: textfield;
|
|
91
|
+
border: 0;
|
|
92
|
+
background: var(--el-color-bg, transparent);
|
|
93
|
+
color: var(--el-color-fg, inherit);
|
|
94
|
+
padding: var(--el-space-2, 0) var(--el-space-3, 0);
|
|
95
|
+
min-width: var(--el-touch-target, auto);
|
|
96
|
+
font: inherit;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
input[type='number'] {
|
|
100
|
+
-moz-appearance: textfield;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input[type='number']::-webkit-outer-spin-button,
|
|
104
|
+
input[type='number']::-webkit-inner-spin-button {
|
|
105
|
+
-webkit-appearance: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Touch screens: the buttons are at least --el-touch-target wide as well, and the input fills
|
|
109
|
+
the height of the stepper, which the buttons set. */
|
|
110
|
+
@media (any-pointer: coarse) {
|
|
111
|
+
.step {
|
|
112
|
+
min-width: var(--el-touch-target, auto);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
input {
|
|
116
|
+
align-self: stretch;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
57
119
|
}
|
|
58
120
|
`;
|
|
121
|
+
|
|
122
|
+
export default [hostStyle('el-amount-field'), formControlStyle('el-amount-field'), style].join('\n');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.3.0] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial `el-avatar`: the picture that stands for a person or a thing. It shows the first of these that it has: the `image`, the `initials`, an icon (the `icon` slot, and the outline of a person without it). ([#79](https://github.com/webtides/element-library/issues/79))
|
|
20
|
+
- An image that cannot be loaded makes way for the initials or the icon, also when it had failed in server-rendered markup before the element was there. A new address is tried again.
|
|
21
|
+
- `label`: with it the avatar is an image with that name for assistive technology; without it, it is hidden as a decoration beside a name that is written out.
|
|
22
|
+
- `shape` (`circle`, `square`, `rounded`) and `size` (`small`, `medium`, `large`), both reflected. The width and the height of an avatar are the control height of its size; `--el-avatar-size` makes it any other size, and the initials and the icon grow with it.
|
|
23
|
+
- The background is an eighth of the text colour, so the avatar shows on any background and without a theme.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html, spreadAttributes } from '@webtides/element-js';
|
|
2
|
+
import style from './avatar.style.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An avatar: the picture that stands for a person or a thing. It shows the first of these that it
|
|
6
|
+
* has: the image, the initials, an icon. An image that cannot be loaded makes way for the next.
|
|
7
|
+
* With a `label` it is an image with that name for assistive technology; without one it is a
|
|
8
|
+
* decoration beside a name that is written out.
|
|
9
|
+
*
|
|
10
|
+
* @element el-avatar
|
|
11
|
+
*
|
|
12
|
+
* @slot icon - The icon that is shown without an image and without initials. Unset, it is the
|
|
13
|
+
* outline of a person.
|
|
14
|
+
*
|
|
15
|
+
* @csspart base - The shape of the avatar: background, radius. It carries the role and the label.
|
|
16
|
+
* @csspart image - The image.
|
|
17
|
+
* @csspart initials - The initials.
|
|
18
|
+
* @csspart icon - The region of the `icon` slot.
|
|
19
|
+
*
|
|
20
|
+
* @cssproperty --el-avatar-size - The width and the height of the avatar. Unset, the `size`
|
|
21
|
+
* decides.
|
|
22
|
+
*
|
|
23
|
+
* @property {string} image - The address of the image.
|
|
24
|
+
* @property {string} label - The accessible name of the avatar, the name of the person for
|
|
25
|
+
* example. Without it the avatar is hidden from assistive technology.
|
|
26
|
+
* @property {string} initials - One or two letters that are shown without an image.
|
|
27
|
+
* @property {'circle'|'square'|'rounded'} shape - The shape of the avatar. Default `'circle'`.
|
|
28
|
+
* Reflected to the `shape` attribute.
|
|
29
|
+
* @property {'small'|'medium'|'large'} size - The width and the height: the control height of that
|
|
30
|
+
* size, `--el-control-height` times 0.8, 1 or 1.25.
|
|
31
|
+
* Default `'medium'`. Reflected to the `size` attribute.
|
|
32
|
+
*/
|
|
33
|
+
export default class Avatar extends TemplateElement {
|
|
34
|
+
constructor() {
|
|
35
|
+
super({
|
|
36
|
+
styles: [style],
|
|
37
|
+
shadowRender: true,
|
|
38
|
+
// The stylesheet and the size module select the host by these attributes.
|
|
39
|
+
propertyOptions: {
|
|
40
|
+
shape: { reflect: true },
|
|
41
|
+
size: { reflect: true },
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
properties() {
|
|
47
|
+
return {
|
|
48
|
+
image: '',
|
|
49
|
+
label: '',
|
|
50
|
+
initials: '',
|
|
51
|
+
shape: 'circle',
|
|
52
|
+
size: 'medium',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
connected() {
|
|
57
|
+
// An image of server-rendered markup can have failed before the element was there to hear
|
|
58
|
+
// of it: the browser loads it while it parses.
|
|
59
|
+
const image = this.$refs.image;
|
|
60
|
+
if (image?.complete && image.naturalWidth === 0) this._giveUpOnImage();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
events() {
|
|
64
|
+
return {
|
|
65
|
+
'[ref=image]': {
|
|
66
|
+
error: () => this._giveUpOnImage(),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Remembers the image that could not be loaded, so that the next thing the avatar has is
|
|
73
|
+
* shown instead. Another address in `image` is tried again.
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
_giveUpOnImage() {
|
|
77
|
+
this._failedImage = this.image;
|
|
78
|
+
this.requestUpdate();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @private */
|
|
82
|
+
_contentTemplate() {
|
|
83
|
+
if (this.image && this.image !== this._failedImage) {
|
|
84
|
+
// The name is on the base, for the image, the initials and the icon alike.
|
|
85
|
+
return html`<img part="image" ref="image" src="${this.image}" alt="" />`;
|
|
86
|
+
}
|
|
87
|
+
if (this.initials) return html`<span part="initials">${this.initials}</span>`;
|
|
88
|
+
return html`
|
|
89
|
+
<span part="icon">
|
|
90
|
+
<slot name="icon">
|
|
91
|
+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
92
|
+
<circle cx="12" cy="8.5" r="4.5"></circle>
|
|
93
|
+
<path d="M3 22a9 9 0 0 1 18 0z"></path>
|
|
94
|
+
</svg>
|
|
95
|
+
</slot>
|
|
96
|
+
</span>
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
template() {
|
|
101
|
+
// Every name is in the map every time: the directive takes an attribute off again only when
|
|
102
|
+
// it finds its name there, with no value.
|
|
103
|
+
const naming = {
|
|
104
|
+
role: this.label ? 'img' : undefined,
|
|
105
|
+
'aria-label': this.label || undefined,
|
|
106
|
+
'aria-hidden': this.label ? undefined : 'true',
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return html`<span part="base" class="avatar" ${spreadAttributes(naming)}>${this._contentTemplate()}</span>`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function define() {
|
|
114
|
+
defineElement('el-avatar', Avatar);
|
|
115
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
`avatar` is the picture that stands for a person or a thing. It shows the first of these that it has: the image, the initials, an icon. An image that cannot be loaded makes way for the next.
|
|
4
|
+
|
|
5
|
+
It shows without a theme: its background is a share of the text colour.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
#### Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i --save @webtides/element-library
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### Use
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import '@webtides/element-library/avatar/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<!-- The image, and the initials in case it cannot be loaded -->
|
|
23
|
+
<el-avatar label="Ada Lovelace" image="/people/ada.jpg" initials="AL"></el-avatar>
|
|
24
|
+
|
|
25
|
+
<!-- Initials alone, or nothing but the icon -->
|
|
26
|
+
<el-avatar label="Grace Hopper" initials="GH"></el-avatar>
|
|
27
|
+
<el-avatar label="Unknown user"></el-avatar>
|
|
28
|
+
|
|
29
|
+
<!-- Beside the name: a decoration, without a label -->
|
|
30
|
+
<span><el-avatar size="small" initials="AL"></el-avatar> Ada Lovelace</span>
|
|
31
|
+
|
|
32
|
+
<!-- An icon of your own -->
|
|
33
|
+
<el-avatar label="Build bot" shape="rounded">
|
|
34
|
+
<svg slot="icon" width="24" height="24" aria-hidden="true">…</svg>
|
|
35
|
+
</el-avatar>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
#### Properties/Attributes
|
|
41
|
+
|
|
42
|
+
| Name | Type | Default | Description |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| `image` | `string` | `''` | The address of the image. |
|
|
45
|
+
| `label` | `string` | `''` | The accessible name, the name of the person for example. Without it the avatar is hidden from assistive technology. |
|
|
46
|
+
| `initials` | `string` | `''` | One or two letters that are shown without an image. |
|
|
47
|
+
| `shape` | `string` | `'circle'` | `circle`, `square` or `rounded`. Reflected. |
|
|
48
|
+
| `size` | `string` | `'medium'` | `small`, `medium` or `large`: the width and the height, the control height of that size. Reflected. |
|
|
49
|
+
|
|
50
|
+
#### Methods
|
|
51
|
+
|
|
52
|
+
_None._
|
|
53
|
+
|
|
54
|
+
#### Events
|
|
55
|
+
|
|
56
|
+
_None._
|
|
57
|
+
|
|
58
|
+
#### Slots
|
|
59
|
+
|
|
60
|
+
| Name | Description |
|
|
61
|
+
| ------ | --------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| `icon` | The icon that is shown without an image and without initials. Unset, it is the outline of a person. |
|
|
63
|
+
|
|
64
|
+
#### CSS Parts
|
|
65
|
+
|
|
66
|
+
| Name | Description |
|
|
67
|
+
| ---------- | ------------------------------------------------------------------------------- |
|
|
68
|
+
| `base` | The shape of the avatar: background, radius. It carries the role and the label. |
|
|
69
|
+
| `image` | The image. |
|
|
70
|
+
| `initials` | The initials. |
|
|
71
|
+
| `icon` | The region of the `icon` slot. |
|
|
72
|
+
|
|
73
|
+
#### CSS Custom Properties
|
|
74
|
+
|
|
75
|
+
| Name | Description |
|
|
76
|
+
| ------------------ | ------------------------------------------------------------------ |
|
|
77
|
+
| `--el-avatar-size` | The width and the height of the avatar. Unset, the `size` decides. |
|
|
78
|
+
|
|
79
|
+
Reads the standard library design tokens: `--el-color-fg`, `--el-control-height`, `--el-radius-md` and `--el-font-family`.
|
|
80
|
+
|
|
81
|
+
## What it shows
|
|
82
|
+
|
|
83
|
+
1. The image, when `image` is set and the image can be loaded. It fills the avatar and is cut to its shape, not squeezed into it.
|
|
84
|
+
2. The initials, when `initials` is set. They are written as given: the avatar does not derive them from the label and does not change their case.
|
|
85
|
+
3. The icon: what is slotted into `icon`, and the outline of a person without that.
|
|
86
|
+
|
|
87
|
+
An image that cannot be loaded makes way for the initials or the icon. That holds for an image of server-rendered markup that had failed before the element was there, too. A new address in `image` is tried again.
|
|
88
|
+
|
|
89
|
+
While an image is loading, the avatar shows its background.
|
|
90
|
+
|
|
91
|
+
## Shape and size
|
|
92
|
+
|
|
93
|
+
| `shape` | |
|
|
94
|
+
| --------- | ---------------------------------------------------------- |
|
|
95
|
+
| `circle` | A circle. The default. |
|
|
96
|
+
| `square` | A square with sharp corners. |
|
|
97
|
+
| `rounded` | A square with the corners of the theme (`--el-radius-md`). |
|
|
98
|
+
|
|
99
|
+
| `size` | With a control height of 2.5rem |
|
|
100
|
+
| -------- | ------------------------------------------ |
|
|
101
|
+
| `small` | 0.8 times `--el-control-height`: 2rem |
|
|
102
|
+
| `medium` | `--el-control-height`: 2.5rem |
|
|
103
|
+
| `large` | 1.25 times `--el-control-height`: 3.125rem |
|
|
104
|
+
|
|
105
|
+
2.5rem is the control height of the default and the sketchy theme, and the one without a theme; the high-contrast theme has 2.75rem. A button of the same size is at least that high, and a few pixels higher where its border and its text need more.
|
|
106
|
+
|
|
107
|
+
For any other size set `--el-avatar-size`, on the element or on anything around it; the `size` attribute has no say then:
|
|
108
|
+
|
|
109
|
+
```css
|
|
110
|
+
.profile el-avatar {
|
|
111
|
+
--el-avatar-size: 6rem;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The initials are two fifths of the avatar high, the icon three fifths. An icon of your own that is sized in `em` grows with the avatar as well.
|
|
116
|
+
|
|
117
|
+
Both properties are reflected: the element writes them onto itself as attributes, the defaults included (`<el-avatar shape="circle" size="medium">`). A value the avatar does not know is treated like the default.
|
|
118
|
+
|
|
119
|
+
There is no `variant`. For a background of your own, per person for example, paint the part: `el-avatar::part(base) { background: … }`.
|
|
120
|
+
|
|
121
|
+
The avatar stands in a line of text, in the middle of it (`inline-block`). The `hidden` attribute hides it.
|
|
122
|
+
|
|
123
|
+
## Accessibility
|
|
124
|
+
|
|
125
|
+
- With a `label` the avatar is an image with that name (`role="img"`), whatever it shows: the image, the initials or the icon. A screen reader reads the name, not the two letters.
|
|
126
|
+
- Without a `label` it is hidden from assistive technology. That is right where the name is written out beside it, and wrong where the avatar stands alone: give it a label there.
|
|
127
|
+
- An avatar is not a control. One that opens a menu or leads to a profile goes into a button or a link, which gets the name; the avatar inside needs no label then.
|
|
128
|
+
- The initials have the text colour on an eighth of that colour, a contrast far above 4.5 : 1 in every shipped theme.
|
|
129
|
+
|
|
130
|
+
## Server-side rendering
|
|
131
|
+
|
|
132
|
+
The avatar is fully part of the server-rendered markup (Declarative Shadow DOM): the image, the initials or the icon, the role and the name. An image that fails to load before the JavaScript has arrived stays a broken image until then, and makes way for the initials or the icon as soon as the element takes over.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import sizeStyle from '../../styles/size.style.js';
|
|
3
|
+
|
|
4
|
+
const css = String.raw;
|
|
5
|
+
|
|
6
|
+
const style = css`
|
|
7
|
+
:host {
|
|
8
|
+
/* The control height of its size, which is the least height of a button of that size.
|
|
9
|
+
--el-avatar-size takes its place for an avatar of any other size. */
|
|
10
|
+
--_el-avatar-size: var(--el-avatar-size, var(--_el-size-height));
|
|
11
|
+
|
|
12
|
+
display: inline-block;
|
|
13
|
+
width: var(--_el-avatar-size);
|
|
14
|
+
height: var(--_el-avatar-size);
|
|
15
|
+
vertical-align: middle;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.avatar {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
border-radius: 50%;
|
|
26
|
+
color: var(--el-color-fg, inherit);
|
|
27
|
+
/* A share of that text colour, as the skeleton has it: the avatar shows on the background
|
|
28
|
+
of the page and on a muted fill, in a light scheme and in a dark one, and without a
|
|
29
|
+
theme. */
|
|
30
|
+
background: color-mix(in srgb, currentColor 12%, transparent);
|
|
31
|
+
font-family: var(--el-font-family, inherit);
|
|
32
|
+
/* Two letters fill the avatar without touching its edge. */
|
|
33
|
+
font-size: calc(var(--_el-avatar-size) * 0.4);
|
|
34
|
+
font-weight: var(--el-font-weight-semibold, 600);
|
|
35
|
+
line-height: 1;
|
|
36
|
+
user-select: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([shape='square']) .avatar {
|
|
40
|
+
border-radius: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host([shape='rounded']) .avatar {
|
|
44
|
+
border-radius: var(--el-radius-md, 4px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* The image fills the avatar and is cut to its shape, not squeezed into it. */
|
|
48
|
+
[part~='image'] {
|
|
49
|
+
display: block;
|
|
50
|
+
width: 100%;
|
|
51
|
+
height: 100%;
|
|
52
|
+
object-fit: cover;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* An icon is sized by the font size, which is larger here than for the initials. */
|
|
56
|
+
[part~='icon'] {
|
|
57
|
+
display: flex;
|
|
58
|
+
font-size: calc(var(--_el-avatar-size) * 0.6);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[part~='icon'] svg {
|
|
62
|
+
width: 1em;
|
|
63
|
+
height: 1em;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export default [hostStyle(), sizeStyle(), style].join('\n');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.3.0] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial `el-badge`: a short label that marks something with a status or a count. Pure presentation, without a role and without behaviour. ([#74](https://github.com/webtides/element-library/issues/74))
|
|
20
|
+
- `variant` (`neutral`, `brand`, `success`, `warning`, `danger`) and `appearance` (`filled`, `outlined`, `plain`), the library's shared vocabulary, both reflected to attributes of the same name.
|
|
21
|
+
- `pill` for fully rounded ends. A badge with a single character is as wide as it is high: a square, and a circle as a pill.
|
|
22
|
+
- `pulse`: a ring in the colour of the variant spreads from the badge, again and again. It stands still for a user who prefers reduced motion.
|
|
23
|
+
- A badge is three quarters of the font size of the text it stands in, so it has no `size`.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html, classMap } from '@webtides/element-js';
|
|
2
|
+
import style from './badge.style.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A badge: a short label that marks something with a status or a count ("New", "3"). Pure
|
|
6
|
+
* presentation, without a role and without behaviour. It speaks the library's shared vocabulary
|
|
7
|
+
* for its colours, a semantic `variant` and an `appearance`, and is sized by the font size of the
|
|
8
|
+
* text it stands in.
|
|
9
|
+
*
|
|
10
|
+
* @element el-badge
|
|
11
|
+
*
|
|
12
|
+
* @slot - The text of the badge.
|
|
13
|
+
*
|
|
14
|
+
* @csspart base - The surface of the badge: background, border, radius.
|
|
15
|
+
*
|
|
16
|
+
* @property {'neutral'|'brand'|'success'|'warning'|'danger'} variant - Semantic variant, which
|
|
17
|
+
* picks the colours. Default `'neutral'`. Reflected to the `variant` attribute.
|
|
18
|
+
* @property {'filled'|'outlined'|'plain'} appearance - How the colours of the variant are painted:
|
|
19
|
+
* as a fill, as a border around a transparent badge, or as text only. Default `'filled'`.
|
|
20
|
+
* Reflected to the `appearance` attribute.
|
|
21
|
+
* @property {boolean} pill - Fully rounded ends. A badge with a single character is a circle.
|
|
22
|
+
* @property {boolean} pulse - Draws attention: a ring spreads from the badge, again and again.
|
|
23
|
+
*/
|
|
24
|
+
export default class Badge extends TemplateElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super({
|
|
27
|
+
styles: [style],
|
|
28
|
+
shadowRender: true,
|
|
29
|
+
// The shared style modules select the host by these attributes.
|
|
30
|
+
propertyOptions: {
|
|
31
|
+
variant: { reflect: true },
|
|
32
|
+
appearance: { reflect: true },
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
properties() {
|
|
38
|
+
return {
|
|
39
|
+
variant: 'neutral',
|
|
40
|
+
appearance: 'filled',
|
|
41
|
+
pill: false,
|
|
42
|
+
pulse: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
template() {
|
|
47
|
+
const classes = {
|
|
48
|
+
badge: true,
|
|
49
|
+
'badge--pill': !!this.pill,
|
|
50
|
+
'badge--pulse': !!this.pulse,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return html`<span part="base" class="${classMap(classes)}"><slot></slot></span>`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function define() {
|
|
58
|
+
defineElement('el-badge', Badge);
|
|
59
|
+
}
|