@webtides/element-library 0.1.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 +109 -0
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/all.js +26 -0
- package/custom-elements.json +7683 -0
- package/index.js +3 -0
- package/package.json +132 -0
- package/patches/@glidejs+glide+3.6.2.patch +11 -0
- package/src/components/accordion/accordion.changelog.md +47 -0
- package/src/components/accordion/accordion.define.js +3 -0
- package/src/components/accordion/accordion.events.js +3 -0
- package/src/components/accordion/accordion.js +144 -0
- package/src/components/accordion/accordion.readme.md +71 -0
- package/src/components/accordion/accordion.style.js +64 -0
- package/src/components/accordion-group/accordion-group.changelog.md +35 -0
- package/src/components/accordion-group/accordion-group.define.js +3 -0
- package/src/components/accordion-group/accordion-group.js +63 -0
- package/src/components/accordion-group/accordion-group.readme.md +56 -0
- package/src/components/amount-field/amount-field.changelog.md +40 -0
- package/src/components/amount-field/amount-field.define.js +3 -0
- package/src/components/amount-field/amount-field.js +91 -0
- package/src/components/amount-field/amount-field.readme.md +65 -0
- package/src/components/amount-field/amount-field.style.js +58 -0
- package/src/components/button/button.changelog.md +19 -0
- package/src/components/button/button.define.js +3 -0
- package/src/components/button/button.js +174 -0
- package/src/components/button/button.readme.md +91 -0
- package/src/components/button/button.style.js +251 -0
- package/src/components/carousel/carousel.changelog.md +58 -0
- package/src/components/carousel/carousel.define.js +3 -0
- package/src/components/carousel/carousel.events.js +3 -0
- package/src/components/carousel/carousel.js +232 -0
- package/src/components/carousel/carousel.readme.md +78 -0
- package/src/components/carousel/carousel.style.js +142 -0
- package/src/components/carousel/glide/components/ShadowAnchors.js +12 -0
- package/src/components/carousel/glide/components/ShadowClones.js +41 -0
- package/src/components/carousel/glide/components/ShadowGaps.js +28 -0
- package/src/components/carousel/glide/components/ShadowHtml.js +32 -0
- package/src/components/checkbox-field/checkbox-field.changelog.md +47 -0
- package/src/components/checkbox-field/checkbox-field.define.js +3 -0
- package/src/components/checkbox-field/checkbox-field.js +102 -0
- package/src/components/checkbox-field/checkbox-field.readme.md +66 -0
- package/src/components/checkbox-field/checkbox-field.style.js +69 -0
- package/src/components/dialog/dialog.changelog.md +24 -0
- package/src/components/dialog/dialog.define.js +3 -0
- package/src/components/dialog/dialog.events.js +8 -0
- package/src/components/dialog/dialog.js +271 -0
- package/src/components/dialog/dialog.readme.md +122 -0
- package/src/components/dialog/dialog.style.js +124 -0
- package/src/components/dropdown/dropdown.changelog.md +39 -0
- package/src/components/dropdown/dropdown.define.js +3 -0
- package/src/components/dropdown/dropdown.js +98 -0
- package/src/components/dropdown/dropdown.readme.md +69 -0
- package/src/components/dropdown/dropdown.style.js +17 -0
- package/src/components/form-field/form-field.changelog.md +35 -0
- package/src/components/form-field/form-field.define.js +3 -0
- package/src/components/form-field/form-field.events.js +4 -0
- package/src/components/form-field/form-field.js +210 -0
- package/src/components/form-field/form-field.readme.md +80 -0
- package/src/components/form-field/form-field.style.js +25 -0
- package/src/components/input-field/input-field.changelog.md +39 -0
- package/src/components/input-field/input-field.define.js +3 -0
- package/src/components/input-field/input-field.js +71 -0
- package/src/components/input-field/input-field.readme.md +90 -0
- package/src/components/input-field/input-field.style.js +33 -0
- package/src/components/lazy-src/lazy-src.changelog.md +57 -0
- package/src/components/lazy-src/lazy-src.define.js +3 -0
- package/src/components/lazy-src/lazy-src.events.js +5 -0
- package/src/components/lazy-src/lazy-src.js +100 -0
- package/src/components/lazy-src/lazy-src.readme.md +63 -0
- package/src/components/notification/notification.changelog.md +22 -0
- package/src/components/notification/notification.define.js +3 -0
- package/src/components/notification/notification.events.js +6 -0
- package/src/components/notification/notification.js +280 -0
- package/src/components/notification/notification.readme.md +98 -0
- package/src/components/notification/notification.style.js +113 -0
- package/src/components/password-field/password-field.changelog.md +22 -0
- package/src/components/password-field/password-field.define.js +3 -0
- package/src/components/password-field/password-field.js +113 -0
- package/src/components/password-field/password-field.readme.md +60 -0
- package/src/components/password-field/password-field.style.js +62 -0
- package/src/components/radio-field/radio-field.changelog.md +21 -0
- package/src/components/radio-field/radio-field.define.js +3 -0
- package/src/components/radio-field/radio-field.js +140 -0
- package/src/components/radio-field/radio-field.readme.md +72 -0
- package/src/components/radio-field/radio-field.style.js +108 -0
- package/src/components/scroll-to/scroll-to.changelog.md +39 -0
- package/src/components/scroll-to/scroll-to.define.js +3 -0
- package/src/components/scroll-to/scroll-to.js +40 -0
- package/src/components/scroll-to/scroll-to.readme.md +50 -0
- package/src/components/scroll-to-top/scroll-to-top.changelog.md +39 -0
- package/src/components/scroll-to-top/scroll-to-top.define.js +3 -0
- package/src/components/scroll-to-top/scroll-to-top.js +78 -0
- package/src/components/scroll-to-top/scroll-to-top.readme.md +48 -0
- package/src/components/scroll-to-top/scroll-to-top.style.js +9 -0
- package/src/components/select-field/select-field.changelog.md +30 -0
- package/src/components/select-field/select-field.define.js +3 -0
- package/src/components/select-field/select-field.js +83 -0
- package/src/components/select-field/select-field.readme.md +131 -0
- package/src/components/select-field/select-field.style.js +24 -0
- package/src/components/slider/slider.changelog.md +177 -0
- package/src/components/slider/slider.define.js +3 -0
- package/src/components/slider/slider.events.js +4 -0
- package/src/components/slider/slider.js +338 -0
- package/src/components/slider/slider.readme.md +87 -0
- package/src/components/slider/slider.style.js +107 -0
- package/src/components/sticky/sticky.changelog.md +43 -0
- package/src/components/sticky/sticky.define.js +3 -0
- package/src/components/sticky/sticky.js +105 -0
- package/src/components/sticky/sticky.readme.md +63 -0
- package/src/components/sticky/sticky.style.js +21 -0
- package/src/components/svg-use/svg-use.changelog.md +41 -0
- package/src/components/svg-use/svg-use.define.js +3 -0
- package/src/components/svg-use/svg-use.js +39 -0
- package/src/components/svg-use/svg-use.readme.md +50 -0
- package/src/components/svg-use/svg-use.style.js +20 -0
- package/src/components/switch-field/switch-field.changelog.md +21 -0
- package/src/components/switch-field/switch-field.define.js +3 -0
- package/src/components/switch-field/switch-field.js +99 -0
- package/src/components/switch-field/switch-field.readme.md +58 -0
- package/src/components/switch-field/switch-field.style.js +98 -0
- package/src/components/tab-group/tab-group.changelog.md +35 -0
- package/src/components/tab-group/tab-group.define.js +3 -0
- package/src/components/tab-group/tab-group.js +109 -0
- package/src/components/tab-group/tab-group.readme.md +61 -0
- package/src/components/tab-group/tab-group.style.js +7 -0
- package/src/components/tab-link/tab-link.changelog.md +35 -0
- package/src/components/tab-link/tab-link.define.js +3 -0
- package/src/components/tab-link/tab-link.js +50 -0
- package/src/components/tab-link/tab-link.readme.md +66 -0
- package/src/components/tab-link/tab-link.style.js +32 -0
- package/src/components/tab-panel/tab-panel.changelog.md +39 -0
- package/src/components/tab-panel/tab-panel.define.js +3 -0
- package/src/components/tab-panel/tab-panel.js +30 -0
- package/src/components/tab-panel/tab-panel.readme.md +57 -0
- package/src/components/tab-panel/tab-panel.style.js +7 -0
- package/src/components/textarea-field/textarea-field.changelog.md +39 -0
- package/src/components/textarea-field/textarea-field.define.js +3 -0
- package/src/components/textarea-field/textarea-field.js +62 -0
- package/src/components/textarea-field/textarea-field.readme.md +102 -0
- package/src/components/textarea-field/textarea-field.style.js +7 -0
- package/src/components/transition-classes/transition-classes.changelog.md +39 -0
- package/src/components/transition-classes/transition-classes.define.js +3 -0
- package/src/components/transition-classes/transition-classes.js +154 -0
- package/src/components/transition-classes/transition-classes.readme.md +71 -0
- package/src/themes/default.css +165 -0
- package/src/themes/high-contrast.css +147 -0
- package/src/themes/sketchy.css +238 -0
- package/types/all.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/src/components/accordion/accordion.d.ts +60 -0
- package/types/src/components/accordion/accordion.define.d.ts +1 -0
- package/types/src/components/accordion/accordion.events.d.ts +4 -0
- package/types/src/components/accordion/accordion.style.d.ts +2 -0
- package/types/src/components/accordion-group/accordion-group.d.ts +28 -0
- package/types/src/components/accordion-group/accordion-group.define.d.ts +1 -0
- package/types/src/components/amount-field/amount-field.d.ts +53 -0
- package/types/src/components/amount-field/amount-field.define.d.ts +1 -0
- package/types/src/components/amount-field/amount-field.style.d.ts +2 -0
- package/types/src/components/button/button.d.ts +73 -0
- package/types/src/components/button/button.define.d.ts +1 -0
- package/types/src/components/button/button.style.d.ts +2 -0
- package/types/src/components/carousel/carousel.d.ts +79 -0
- package/types/src/components/carousel/carousel.define.d.ts +1 -0
- package/types/src/components/carousel/carousel.events.d.ts +4 -0
- package/types/src/components/carousel/carousel.style.d.ts +2 -0
- package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowClones.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -0
- package/types/src/components/checkbox-field/checkbox-field.d.ts +69 -0
- package/types/src/components/checkbox-field/checkbox-field.define.d.ts +1 -0
- package/types/src/components/checkbox-field/checkbox-field.style.d.ts +2 -0
- package/types/src/components/dialog/dialog.d.ts +103 -0
- package/types/src/components/dialog/dialog.define.d.ts +1 -0
- package/types/src/components/dialog/dialog.events.d.ts +9 -0
- package/types/src/components/dialog/dialog.style.d.ts +2 -0
- package/types/src/components/dropdown/dropdown.d.ts +45 -0
- package/types/src/components/dropdown/dropdown.define.d.ts +1 -0
- package/types/src/components/dropdown/dropdown.style.d.ts +2 -0
- package/types/src/components/form-field/form-field.d.ts +110 -0
- package/types/src/components/form-field/form-field.define.d.ts +1 -0
- package/types/src/components/form-field/form-field.events.d.ts +5 -0
- package/types/src/components/form-field/form-field.style.d.ts +2 -0
- package/types/src/components/input-field/input-field.d.ts +38 -0
- package/types/src/components/input-field/input-field.define.d.ts +1 -0
- package/types/src/components/input-field/input-field.style.d.ts +2 -0
- package/types/src/components/lazy-src/lazy-src.d.ts +46 -0
- package/types/src/components/lazy-src/lazy-src.define.d.ts +1 -0
- package/types/src/components/lazy-src/lazy-src.events.d.ts +6 -0
- package/types/src/components/notification/notification.d.ts +92 -0
- package/types/src/components/notification/notification.define.d.ts +1 -0
- package/types/src/components/notification/notification.events.d.ts +7 -0
- package/types/src/components/notification/notification.style.d.ts +2 -0
- package/types/src/components/password-field/password-field.d.ts +66 -0
- package/types/src/components/password-field/password-field.define.d.ts +1 -0
- package/types/src/components/password-field/password-field.style.d.ts +2 -0
- package/types/src/components/radio-field/radio-field.d.ts +62 -0
- package/types/src/components/radio-field/radio-field.define.d.ts +1 -0
- package/types/src/components/radio-field/radio-field.style.d.ts +2 -0
- package/types/src/components/scroll-to/scroll-to.d.ts +24 -0
- package/types/src/components/scroll-to/scroll-to.define.d.ts +1 -0
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +32 -0
- package/types/src/components/scroll-to-top/scroll-to-top.define.d.ts +1 -0
- package/types/src/components/scroll-to-top/scroll-to-top.style.d.ts +2 -0
- package/types/src/components/select-field/select-field.d.ts +39 -0
- package/types/src/components/select-field/select-field.define.d.ts +1 -0
- package/types/src/components/select-field/select-field.style.d.ts +2 -0
- package/types/src/components/slider/slider.d.ts +129 -0
- package/types/src/components/slider/slider.define.d.ts +1 -0
- package/types/src/components/slider/slider.events.d.ts +5 -0
- package/types/src/components/slider/slider.style.d.ts +2 -0
- package/types/src/components/sticky/sticky.d.ts +47 -0
- package/types/src/components/sticky/sticky.define.d.ts +1 -0
- package/types/src/components/sticky/sticky.style.d.ts +2 -0
- package/types/src/components/svg-use/svg-use.d.ts +18 -0
- package/types/src/components/svg-use/svg-use.define.d.ts +1 -0
- package/types/src/components/svg-use/svg-use.style.d.ts +2 -0
- package/types/src/components/switch-field/switch-field.d.ts +67 -0
- package/types/src/components/switch-field/switch-field.define.d.ts +1 -0
- package/types/src/components/switch-field/switch-field.style.d.ts +2 -0
- package/types/src/components/tab-group/tab-group.d.ts +48 -0
- package/types/src/components/tab-group/tab-group.define.d.ts +1 -0
- package/types/src/components/tab-group/tab-group.style.d.ts +2 -0
- package/types/src/components/tab-link/tab-link.d.ts +30 -0
- package/types/src/components/tab-link/tab-link.define.d.ts +1 -0
- package/types/src/components/tab-link/tab-link.style.d.ts +2 -0
- package/types/src/components/tab-panel/tab-panel.d.ts +18 -0
- package/types/src/components/tab-panel/tab-panel.define.d.ts +1 -0
- package/types/src/components/tab-panel/tab-panel.style.d.ts +2 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +34 -0
- package/types/src/components/textarea-field/textarea-field.define.d.ts +1 -0
- package/types/src/components/textarea-field/textarea-field.style.d.ts +2 -0
- package/types/src/components/transition-classes/transition-classes.d.ts +52 -0
- package/types/src/components/transition-classes/transition-classes.define.d.ts +1 -0
- package/types/src/utils/body-scroll.d.ts +4 -0
- package/types/src/utils/transitions.d.ts +9 -0
- package/web-types.json +3956 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
ol,
|
|
10
|
+
ul,
|
|
11
|
+
li {
|
|
12
|
+
list-style: none;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.scroller {
|
|
18
|
+
display: flex;
|
|
19
|
+
overflow-x: scroll;
|
|
20
|
+
position: relative;
|
|
21
|
+
-webkit-overflow-scrolling: touch;
|
|
22
|
+
scrollbar-width: none;
|
|
23
|
+
counter-reset: item;
|
|
24
|
+
scroll-snap-type: x mandatory;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.scroller::-webkit-scrollbar {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
::slotted(.item) {
|
|
32
|
+
position: relative;
|
|
33
|
+
flex-grow: 0;
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
scroll-snap-align: var(--snap-align, center);
|
|
36
|
+
width: var(--item-width, 100%);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[part~='dots'] {
|
|
40
|
+
display: flex;
|
|
41
|
+
position: relative;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
|
|
44
|
+
[part~='dot'] {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
background: none;
|
|
47
|
+
border: none;
|
|
48
|
+
color: var(--el-color-fg, currentColor);
|
|
49
|
+
padding: var(--el-space-1, 4px);
|
|
50
|
+
font-size: 22px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[part~='dot']::after {
|
|
54
|
+
content: '○';
|
|
55
|
+
padding: var(--el-space-1, 4px);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[part~='dot']:hover {
|
|
59
|
+
color: var(--el-color-accent, #666);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[part~='dot']:active {
|
|
63
|
+
color: var(--el-color-accent, #999);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[part~='dot'][aria-pressed='true'] {
|
|
67
|
+
color: var(--el-color-accent, currentColor);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[part~='dot'][aria-pressed='true']::after {
|
|
71
|
+
content: '●';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[part~='arrows'] {
|
|
76
|
+
position: absolute;
|
|
77
|
+
left: 0;
|
|
78
|
+
top: 0;
|
|
79
|
+
right: 0;
|
|
80
|
+
bottom: 0;
|
|
81
|
+
display: flex;
|
|
82
|
+
justify-content: space-between;
|
|
83
|
+
align-items: center;
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
|
|
86
|
+
/* The arrow <button> *is* the part element (it wraps a <slot>), so style
|
|
87
|
+
it directly — a nested "button" selector would match nothing. */
|
|
88
|
+
[part~='arrow'] {
|
|
89
|
+
pointer-events: all;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
font-size: 18px;
|
|
92
|
+
background: var(--el-color-bg, transparent);
|
|
93
|
+
color: var(--el-color-fg, inherit);
|
|
94
|
+
border-radius: var(--el-radius-md, 0);
|
|
95
|
+
border: var(--el-border-width, 0) solid var(--el-color-border, transparent);
|
|
96
|
+
padding: var(--el-space-2, 8px) var(--el-space-4, 16px);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[part~='arrow-left'] {
|
|
100
|
+
left: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[part~='arrow-right'] {
|
|
104
|
+
right: 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
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.1.0] - 2026-06-03
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- BREAKING: renamed the component — tag `el-sticky-element` → `el-sticky`, import subpaths `@webtides/element-library/sticky-element` → `/sticky` (and `/sticky-element/define` → `/sticky/define`), and exported class `StickyElement` → `Sticky`.
|
|
20
|
+
- BREAKING: replaced the `.is-sticky`, `.is-up`, `.is-down` host classes with the custom states `:state(sticky)`, `:state(up)`, `:state(down)`. Consumers that styled on the old class names should switch to `el-sticky:state(...) { … }`.
|
|
21
|
+
- Sticky transition reads `--el-duration-md` and `--el-ease` (with the previous `0.3s ease` as fallback).
|
|
22
|
+
|
|
23
|
+
## Legacy (pre-merge)
|
|
24
|
+
|
|
25
|
+
The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
|
|
26
|
+
|
|
27
|
+
## 0.2.1 (2021-07-21)
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
update element-js version
|
|
32
|
+
|
|
33
|
+
## [0.2.0] - 2020-12-22
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Added `ResizeOberver` to listen for when the size of the `sticky` changes. With this it will now correctly calculate the height of the element even if it contains other custom elements that render after the connected callback.
|
|
38
|
+
|
|
39
|
+
## [0.1.0] - 2020-07-07
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- initial release
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { StyledElement, defineElement } from '@webtides/element-js';
|
|
2
|
+
import style from './sticky.style.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sticky positioning helper. Toggles `sticky`, `up` and `down` custom states on the host
|
|
6
|
+
* element based on the page's scroll position and direction so consumers can drive styling
|
|
7
|
+
* from CSS (e.g. `el-sticky:state(sticky):state(up) { … }`). Publishes the host's
|
|
8
|
+
* height as the `--sticky-height` custom property.
|
|
9
|
+
*
|
|
10
|
+
* @element el-sticky
|
|
11
|
+
*
|
|
12
|
+
* @slot - Default slot for the sticky content (e.g. a `<nav>`).
|
|
13
|
+
*
|
|
14
|
+
* @cssstate sticky - Set when the element has scrolled past its initial position.
|
|
15
|
+
* @cssstate up - Set while the page is scrolling up past the threshold.
|
|
16
|
+
* @cssstate down - Set while the page is scrolling down past the threshold.
|
|
17
|
+
*
|
|
18
|
+
* @cssproperty --sticky-height - Auto-set to the host's `clientHeight`. Maintained via a
|
|
19
|
+
* `ResizeObserver` and useful for transform calculations or layout offsets.
|
|
20
|
+
*
|
|
21
|
+
* @property {boolean} forceDown - When `true`, the element always shows the `down` state
|
|
22
|
+
* regardless of scroll direction. Useful for navigation that should remain visible.
|
|
23
|
+
*/
|
|
24
|
+
export default class Sticky extends StyledElement {
|
|
25
|
+
/** @private */
|
|
26
|
+
height = 0;
|
|
27
|
+
/** @private */
|
|
28
|
+
lastScrollTop = 0;
|
|
29
|
+
/** @private */
|
|
30
|
+
resizeObserver = undefined;
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super({ styles: [style] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
properties() {
|
|
37
|
+
return {
|
|
38
|
+
forceDown: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
connected() {
|
|
43
|
+
this.height = this.offsetHeight;
|
|
44
|
+
this.calcCSSProperties();
|
|
45
|
+
try {
|
|
46
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
47
|
+
this.calcCSSProperties();
|
|
48
|
+
});
|
|
49
|
+
this.resizeObserver.observe(this);
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
disconnected() {
|
|
54
|
+
if (this.resizeObserver) this.resizeObserver.disconnect();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
events() {
|
|
58
|
+
return {
|
|
59
|
+
document: {
|
|
60
|
+
scroll: () => this.hasScrolled(window.scrollY),
|
|
61
|
+
},
|
|
62
|
+
window: {
|
|
63
|
+
load: () => {
|
|
64
|
+
//wait for window to be loaded - otherwise width won't respect the scrollbar
|
|
65
|
+
this.calcCSSProperties();
|
|
66
|
+
},
|
|
67
|
+
resize: () => {
|
|
68
|
+
this.calcCSSProperties();
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @private */
|
|
75
|
+
calcCSSProperties() {
|
|
76
|
+
this.style.setProperty('--sticky-height', this.clientHeight + 'px');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @private */
|
|
80
|
+
hasScrolled(scrollY) {
|
|
81
|
+
if (scrollY > this.height && scrollY > 0) {
|
|
82
|
+
this._internals.states.add('sticky');
|
|
83
|
+
} else {
|
|
84
|
+
this._internals.states.delete('sticky');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (scrollY > this.lastScrollTop && scrollY > this.height) {
|
|
88
|
+
// Scroll Down
|
|
89
|
+
this._internals.states.delete('down');
|
|
90
|
+
this._internals.states.add('up');
|
|
91
|
+
} else {
|
|
92
|
+
// Scroll Up
|
|
93
|
+
if (scrollY < this.lastScrollTop) {
|
|
94
|
+
this._internals.states.delete('up');
|
|
95
|
+
this._internals.states.add('down');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this.lastScrollTop = scrollY;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function define() {
|
|
104
|
+
defineElement('el-sticky', Sticky);
|
|
105
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Sticky
|
|
2
|
+
|
|
3
|
+
`sticky` is a component that creates smart sticky positioning behavior. It automatically toggles custom states based on scroll position and direction, allowing you to create headers or navigation elements that stick to the top of the viewport and can hide/show based on scroll direction.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/sticky/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<el-sticky>
|
|
21
|
+
<nav>
|
|
22
|
+
<a href="#">Home</a>
|
|
23
|
+
<a href="#">About</a>
|
|
24
|
+
<a href="#">Contact</a>
|
|
25
|
+
</nav>
|
|
26
|
+
</el-sticky>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
#### Properties/Attribute
|
|
32
|
+
|
|
33
|
+
| Name | Type | Default | Description |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| `forceDown` | `boolean` | `false` | When set to `true`, prevents the element from hiding when scrolling up. Useful for keeping navigation always visible. |
|
|
36
|
+
|
|
37
|
+
#### Methods
|
|
38
|
+
|
|
39
|
+
_None_
|
|
40
|
+
|
|
41
|
+
#### Events
|
|
42
|
+
|
|
43
|
+
_None_
|
|
44
|
+
|
|
45
|
+
#### CSS Custom Properties
|
|
46
|
+
|
|
47
|
+
| Name | Default | Description |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `--sticky-height` | Auto-calculated | The height of the sticky element. Automatically set by the component using ResizeObserver. Used for transform calculations. |
|
|
50
|
+
|
|
51
|
+
#### Slots
|
|
52
|
+
|
|
53
|
+
_None_ (uses default slot for content)
|
|
54
|
+
|
|
55
|
+
#### CSS States
|
|
56
|
+
|
|
57
|
+
The component automatically toggles these custom states based on scroll behavior. Style them with `el-sticky:state(sticky)`, `el-sticky:state(up)`, etc.:
|
|
58
|
+
|
|
59
|
+
| State | Description |
|
|
60
|
+
| -------- | --------------------------------------------------------- |
|
|
61
|
+
| `sticky` | Set once the page has scrolled past the element's height. |
|
|
62
|
+
| `up` | Set when scrolling up. |
|
|
63
|
+
| `down` | Set when scrolling down. |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
el-sticky {
|
|
5
|
+
position: sticky;
|
|
6
|
+
display: block;
|
|
7
|
+
transition: transform var(--el-duration-md, 0.3s) var(--el-ease, ease);
|
|
8
|
+
|
|
9
|
+
--sticky-height: 100%;
|
|
10
|
+
|
|
11
|
+
&:state(sticky) {
|
|
12
|
+
&:state(up):not([force-down]) {
|
|
13
|
+
transform: translateY(-100%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:state(down) {
|
|
17
|
+
transform: translateY(calc(-100% + var(--sticky-height)));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
<!-- ### Added -->
|
|
15
|
+
<!-- ### Changed -->
|
|
16
|
+
<!-- ### Removed -->
|
|
17
|
+
<!-- ### Fixed -->
|
|
18
|
+
|
|
19
|
+
## [0.1.0] - 2026-06-03
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Migrated into the single-repo `@webtides/element-library` package. No API changes.
|
|
24
|
+
|
|
25
|
+
## Legacy (pre-merge)
|
|
26
|
+
|
|
27
|
+
The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
|
|
28
|
+
|
|
29
|
+
## 0.1.1 (2021-07-21)
|
|
30
|
+
|
|
31
|
+
## 0.1.1 (2021-07-21)
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
update element-js version
|
|
36
|
+
|
|
37
|
+
## [0.1.0] - 2020-07-07
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
|
|
41
|
+
- initial release
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TemplateElement, defineElement } from '@webtides/element-js';
|
|
2
|
+
import style from './svg-use.style.js';
|
|
3
|
+
|
|
4
|
+
// TODO: think about setting spritePath globally ?!
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Thin wrapper around `<svg><use href>` that references a symbol from an SVG sprite
|
|
8
|
+
* (either external via `spritePath` or embedded in the parent document).
|
|
9
|
+
*
|
|
10
|
+
* @element el-svg-use
|
|
11
|
+
*
|
|
12
|
+
* @property {string} name - `id` of the `<symbol>` to render from the sprite.
|
|
13
|
+
* @property {string} spritePath - Path to an external SVG sprite. When empty, the symbol is
|
|
14
|
+
* assumed to be embedded in the parent document.
|
|
15
|
+
*/
|
|
16
|
+
export default class SvgUse extends TemplateElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({ styles: [style] });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
properties() {
|
|
22
|
+
return {
|
|
23
|
+
name: '',
|
|
24
|
+
spritePath: '',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
template() {
|
|
29
|
+
return `
|
|
30
|
+
<svg>
|
|
31
|
+
<use href="${this.spritePath}#${this.name}"></use>
|
|
32
|
+
</svg>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function define() {
|
|
38
|
+
defineElement('el-svg-use', SvgUse);
|
|
39
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SvgUse
|
|
2
|
+
|
|
3
|
+
`svg-use` is a component that simplifies the use of SVG icons from sprite sheets. It wraps the SVG `<use>` element to reference symbols from either an external sprite file or embedded SVG sprites in the document.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/svg-use/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<!-- Using an external sprite file -->
|
|
21
|
+
<el-svg-use name="icon-home" sprite-path="/assets/icons.svg"></el-svg-use>
|
|
22
|
+
|
|
23
|
+
<!-- Using an embedded sprite (no sprite-path needed) -->
|
|
24
|
+
<el-svg-use name="icon-search"></el-svg-use>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
#### Properties/Attribute
|
|
30
|
+
|
|
31
|
+
| Name | Type | Default | Description |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `name` | `string` | `''` | The ID of the SVG symbol to display from the sprite. This corresponds to the `id` attribute of a `<symbol>` element in the SVG sprite. |
|
|
34
|
+
| `spritePath` | `string` | `''` | The path to an external SVG sprite file. If empty, the component assumes the sprite is embedded in the parent document. |
|
|
35
|
+
|
|
36
|
+
#### Methods
|
|
37
|
+
|
|
38
|
+
_None_
|
|
39
|
+
|
|
40
|
+
#### Events
|
|
41
|
+
|
|
42
|
+
_None_
|
|
43
|
+
|
|
44
|
+
#### CSS Custom Properties
|
|
45
|
+
|
|
46
|
+
_None_
|
|
47
|
+
|
|
48
|
+
#### Slots
|
|
49
|
+
|
|
50
|
+
_None_
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
el-svg-use {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
position: relative;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
|
|
9
|
+
svg {
|
|
10
|
+
position: absolute;
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
top: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
fill: currentColor;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.1.0] - 2026-06-03
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial release of `el-switch-field` — an on/off toggle extending `FormField`. Renders a native `<input type="checkbox">` with `role="switch"` (announced as a switch, submits with forms) behind a custom, headless-by-default track/thumb.
|
|
20
|
+
- `checked` property reflected to the `checked` attribute, plus a `checked` custom state on the host.
|
|
21
|
+
- Inherits the `input-change` event and `touched` / `valid` / `invalid` states from `FormField`.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { html, defineElement, classMap, unsafeHTML } from '@webtides/element-js';
|
|
2
|
+
import FormField, { FormFieldEvents } from '../form-field/form-field.js';
|
|
3
|
+
import style from './switch-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An on/off toggle switch. Renders a native `<input type="checkbox">` with `role="switch"` (so it
|
|
7
|
+
* is announced as a switch and submits with forms) behind a custom track/thumb. Extends
|
|
8
|
+
* `FormField` and inherits its label / help / error / required surface.
|
|
9
|
+
*
|
|
10
|
+
* @element el-switch-field
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent<string>} input-change - Fired when the on/off state changes. `detail` is the
|
|
13
|
+
* input's `value`. Bubbles.
|
|
14
|
+
*
|
|
15
|
+
* @cssstate checked - Set on the host while the switch is on. Style with
|
|
16
|
+
* `el-switch-field:state(checked) { … }`. Inherits `touched`, `valid` and `invalid` from
|
|
17
|
+
* `FormField`.
|
|
18
|
+
*
|
|
19
|
+
* @property {boolean} checked - Whether the switch is on. Reflected to the `checked` attribute.
|
|
20
|
+
*/
|
|
21
|
+
export default class SwitchField extends FormField {
|
|
22
|
+
/** @private */
|
|
23
|
+
uuid = Math.random().toString(36).substr(2, 5);
|
|
24
|
+
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super({ shadowRender: false, styles: [style], ...options });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
properties() {
|
|
30
|
+
return {
|
|
31
|
+
...super.properties(),
|
|
32
|
+
checked: false,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
connected() {
|
|
37
|
+
this.setAttribute('checked', this.checked === true ? 'true' : 'false');
|
|
38
|
+
if (this.checked) this._internals.states.add('checked');
|
|
39
|
+
this.syncValidationStates();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
watch() {
|
|
43
|
+
return {
|
|
44
|
+
...super.watch(),
|
|
45
|
+
checked: (checked) => {
|
|
46
|
+
this.setAttribute('checked', checked ? 'true' : 'false');
|
|
47
|
+
if (checked) this._internals.states.add('checked');
|
|
48
|
+
else this._internals.states.delete('checked');
|
|
49
|
+
this.dispatch(FormFieldEvents.INPUT_CHANGE, this.$refs.input.value);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
events() {
|
|
55
|
+
return {
|
|
56
|
+
...super.events(),
|
|
57
|
+
input: {
|
|
58
|
+
change: () => {
|
|
59
|
+
this.checked = this.$refs.input.checked;
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The switch renders its label inline next to the track (see `fieldTemplate`), so the base
|
|
67
|
+
* FormField label is suppressed.
|
|
68
|
+
* @returns {null}
|
|
69
|
+
*/
|
|
70
|
+
labelTemplate() {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fieldTemplate() {
|
|
75
|
+
const classes = { 'is-checked': !!this.checked };
|
|
76
|
+
return html`
|
|
77
|
+
<label for="switch-${this.uuid}">
|
|
78
|
+
<input
|
|
79
|
+
ref="input"
|
|
80
|
+
type="checkbox"
|
|
81
|
+
role="switch"
|
|
82
|
+
id="switch-${this.uuid}"
|
|
83
|
+
aria-describedby="${this.name}-help-message"
|
|
84
|
+
value="${this.value}"
|
|
85
|
+
name="${this.name}"
|
|
86
|
+
?disabled="${this.disabled}"
|
|
87
|
+
?checked="${this.checked}"
|
|
88
|
+
?required="${this.required}"
|
|
89
|
+
/>
|
|
90
|
+
<span class="switch-track ${classMap(classes)}"><span class="switch-thumb"></span></span>
|
|
91
|
+
<span class="label">${this.label ? unsafeHTML(this.label) : ''}</span>
|
|
92
|
+
</label>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function define() {
|
|
98
|
+
defineElement('el-switch-field', SwitchField);
|
|
99
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# SwitchField
|
|
2
|
+
|
|
3
|
+
`switch-field` is an on/off toggle. It renders a native `<input type="checkbox">` with `role="switch"` — so it is announced as a switch and submits with forms — behind a custom track/thumb. It extends `form-field`, inheriting the label, help text, error message, `required` and touched-state handling.
|
|
4
|
+
|
|
5
|
+
It is headless by default: without a theme the track falls back to a `currentColor` outline with a `currentColor` thumb.
|
|
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/switch-field/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-switch-field name="notifications" label="Enable notifications"></el-switch-field>
|
|
23
|
+
<el-switch-field name="darkmode" label="Dark mode" checked="true"></el-switch-field>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
#### Properties/Attributes
|
|
29
|
+
|
|
30
|
+
Inherits all of `form-field`'s properties (`name`, `value`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
|
|
31
|
+
|
|
32
|
+
| Name | Type | Default | Description |
|
|
33
|
+
| --------- | --------- | ------- | --------------------------------------------------------------- |
|
|
34
|
+
| `checked` | `boolean` | `false` | Whether the switch is on. Reflected to the `checked` attribute. |
|
|
35
|
+
|
|
36
|
+
#### Events
|
|
37
|
+
|
|
38
|
+
| Name | Detail | Description |
|
|
39
|
+
| -------------- | -------------------- | ------------------------------------ |
|
|
40
|
+
| `input-change` | `string` (the value) | Fired when the on/off state changes. |
|
|
41
|
+
|
|
42
|
+
#### CSS States
|
|
43
|
+
|
|
44
|
+
| Name | Description |
|
|
45
|
+
| --------- | ---------------------------------------------------------------------------------------- |
|
|
46
|
+
| `checked` | Present on the host while the switch is on. Style with `el-switch-field:state(checked)`. |
|
|
47
|
+
| `touched` | Set once the switch has been focused and blurred. |
|
|
48
|
+
| `valid` | Set while the field passes validation. |
|
|
49
|
+
| `invalid` | Set while the field fails validation. |
|
|
50
|
+
|
|
51
|
+
#### CSS Custom Properties
|
|
52
|
+
|
|
53
|
+
Headless by default; reads the library's `--el-*` design tokens (`--el-color-accent`, `--el-color-border`, `--el-color-bg`, `--el-space-2`, `--el-border-width`, `--el-focus-ring-width`, `--el-duration-md`, `--el-ease`, `--el-color-fg-muted`, `--el-color-danger`). Skin it via a theme — see the Storybook _Docs / Theming_ page.
|
|
54
|
+
|
|
55
|
+
## Accessibility
|
|
56
|
+
|
|
57
|
+
- The native control is a `<input type="checkbox" role="switch">`, so it is announced as a switch with an on/off state and is keyboard-operable (Space toggles).
|
|
58
|
+
- The native input stays in the accessibility tree and focusable; it is only hidden visually, with keyboard focus reflected onto the custom track via `:focus-visible`.
|