@webtides/element-library 0.3.1 → 0.4.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.
Files changed (195) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +14723 -10220
  6. package/package.json +1 -1
  7. package/src/components/accordion/accordion.changelog.md +11 -0
  8. package/src/components/accordion/accordion.js +15 -3
  9. package/src/components/accordion/accordion.readme.md +27 -1
  10. package/src/components/accordion/accordion.style.js +19 -0
  11. package/src/components/app-bar/app-bar.changelog.md +24 -0
  12. package/src/components/app-bar/app-bar.define.js +3 -0
  13. package/src/components/app-bar/app-bar.js +91 -0
  14. package/src/components/app-bar/app-bar.readme.md +130 -0
  15. package/src/components/app-bar/app-bar.style.js +103 -0
  16. package/src/components/app-frame/app-frame.changelog.md +45 -0
  17. package/src/components/app-frame/app-frame.define.js +3 -0
  18. package/src/components/app-frame/app-frame.events.js +6 -0
  19. package/src/components/app-frame/app-frame.js +1073 -0
  20. package/src/components/app-frame/app-frame.readme.md +416 -0
  21. package/src/components/app-frame/app-frame.style.js +527 -0
  22. package/src/components/button/button.changelog.md +15 -0
  23. package/src/components/button/button.events.js +3 -0
  24. package/src/components/button/button.js +145 -3
  25. package/src/components/button/button.readme.md +72 -4
  26. package/src/components/button/button.style.js +161 -7
  27. package/src/components/description-list/description-list.changelog.md +25 -0
  28. package/src/components/description-list/description-list.define.js +3 -0
  29. package/src/components/description-list/description-list.js +44 -0
  30. package/src/components/description-list/description-list.readme.md +135 -0
  31. package/src/components/description-list/description-list.style.js +140 -0
  32. package/src/components/dialog/dialog.changelog.md +7 -0
  33. package/src/components/dialog/dialog.readme.md +5 -0
  34. package/src/components/dialog/dialog.style.js +17 -2
  35. package/src/components/drawer/drawer.changelog.md +7 -0
  36. package/src/components/drawer/drawer.readme.md +7 -6
  37. package/src/components/drawer/drawer.style.js +35 -2
  38. package/src/components/dropdown/dropdown.readme.md +6 -1
  39. package/src/components/list/list.changelog.md +24 -0
  40. package/src/components/list/list.define.js +3 -0
  41. package/src/components/list/list.js +66 -0
  42. package/src/components/list/list.readme.md +122 -0
  43. package/src/components/list/list.style.js +56 -0
  44. package/src/components/list-item/list-item.changelog.md +24 -0
  45. package/src/components/list-item/list-item.define.js +3 -0
  46. package/src/components/list-item/list-item.js +128 -0
  47. package/src/components/list-item/list-item.readme.md +126 -0
  48. package/src/components/list-item/list-item.style.js +234 -0
  49. package/src/components/menu/menu.changelog.md +27 -0
  50. package/src/components/menu/menu.define.js +3 -0
  51. package/src/components/menu/menu.events.js +5 -0
  52. package/src/components/menu/menu.js +570 -0
  53. package/src/components/menu/menu.readme.md +272 -0
  54. package/src/components/menu/menu.style.js +55 -0
  55. package/src/components/menu-group/menu-group.changelog.md +20 -0
  56. package/src/components/menu-group/menu-group.define.js +3 -0
  57. package/src/components/menu-group/menu-group.js +44 -0
  58. package/src/components/menu-group/menu-group.readme.md +74 -0
  59. package/src/components/menu-group/menu-group.style.js +38 -0
  60. package/src/components/menu-item/menu-item.changelog.md +24 -0
  61. package/src/components/menu-item/menu-item.define.js +3 -0
  62. package/src/components/menu-item/menu-item.js +130 -0
  63. package/src/components/menu-item/menu-item.readme.md +94 -0
  64. package/src/components/menu-item/menu-item.style.js +87 -0
  65. package/src/components/nav/nav.changelog.md +35 -0
  66. package/src/components/nav/nav.define.js +3 -0
  67. package/src/components/nav/nav.js +212 -0
  68. package/src/components/nav/nav.readme.md +248 -0
  69. package/src/components/nav/nav.style.js +269 -0
  70. package/src/components/nav-item/nav-item.changelog.md +25 -0
  71. package/src/components/nav-item/nav-item.define.js +3 -0
  72. package/src/components/nav-item/nav-item.js +75 -0
  73. package/src/components/nav-item/nav-item.readme.md +111 -0
  74. package/src/components/nav-item/nav-item.style.js +159 -0
  75. package/src/components/pagination/pagination.changelog.md +8 -0
  76. package/src/components/pagination/pagination.js +123 -49
  77. package/src/components/pagination/pagination.readme.md +24 -6
  78. package/src/components/pagination/pagination.style.js +11 -1
  79. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  80. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  81. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  82. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  83. package/src/components/segmented-field/segmented-field.define.js +3 -0
  84. package/src/components/segmented-field/segmented-field.js +175 -0
  85. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  86. package/src/components/segmented-field/segmented-field.style.js +193 -0
  87. package/src/components/splitter/splitter.changelog.md +24 -0
  88. package/src/components/splitter/splitter.define.js +3 -0
  89. package/src/components/splitter/splitter.events.js +4 -0
  90. package/src/components/splitter/splitter.js +237 -0
  91. package/src/components/splitter/splitter.readme.md +164 -0
  92. package/src/components/splitter/splitter.style.js +100 -0
  93. package/src/components/status-bar/status-bar.changelog.md +25 -0
  94. package/src/components/status-bar/status-bar.define.js +3 -0
  95. package/src/components/status-bar/status-bar.js +74 -0
  96. package/src/components/status-bar/status-bar.readme.md +139 -0
  97. package/src/components/status-bar/status-bar.style.js +122 -0
  98. package/src/components/tab-group/tab-group.changelog.md +7 -0
  99. package/src/components/tab-group/tab-group.js +30 -9
  100. package/src/components/tab-group/tab-group.readme.md +14 -0
  101. package/src/components/toast/toast.changelog.md +6 -0
  102. package/src/components/toast/toast.readme.md +5 -3
  103. package/src/components/toast/toast.style.js +22 -6
  104. package/src/components/toolbar/toolbar.changelog.md +24 -0
  105. package/src/components/toolbar/toolbar.define.js +3 -0
  106. package/src/components/toolbar/toolbar.js +233 -0
  107. package/src/components/toolbar/toolbar.readme.md +156 -0
  108. package/src/components/toolbar/toolbar.style.js +49 -0
  109. package/src/components/tooltip/tooltip.changelog.md +11 -0
  110. package/src/components/tooltip/tooltip.js +51 -4
  111. package/src/components/tooltip/tooltip.readme.md +26 -1
  112. package/src/components/tree/tree.changelog.md +23 -0
  113. package/src/components/tree/tree.define.js +3 -0
  114. package/src/components/tree/tree.js +138 -0
  115. package/src/components/tree/tree.readme.md +119 -0
  116. package/src/components/tree/tree.style.js +16 -0
  117. package/src/components/tree-item/tree-item.changelog.md +23 -0
  118. package/src/components/tree-item/tree-item.define.js +3 -0
  119. package/src/components/tree-item/tree-item.events.js +3 -0
  120. package/src/components/tree-item/tree-item.js +246 -0
  121. package/src/components/tree-item/tree-item.readme.md +128 -0
  122. package/src/components/tree-item/tree-item.style.js +226 -0
  123. package/src/styles/appearance.style.js +47 -0
  124. package/src/styles/choice-group.style.js +1 -1
  125. package/src/styles/modal.style.js +14 -1
  126. package/src/styles/size.style.js +41 -0
  127. package/src/utils/focus.js +69 -0
  128. package/src/utils/scroll.js +24 -0
  129. package/types/all.d.ts +16 -0
  130. package/types/src/components/accordion/accordion.d.ts +3 -1
  131. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  132. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  133. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  134. package/types/src/components/app-frame/app-frame.d.ts +491 -0
  135. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  136. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  137. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  138. package/types/src/components/button/button.d.ts +61 -0
  139. package/types/src/components/button/button.events.d.ts +4 -0
  140. package/types/src/components/description-list/description-list.d.ts +29 -0
  141. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  142. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  143. package/types/src/components/list/list.d.ts +39 -0
  144. package/types/src/components/list/list.define.d.ts +1 -0
  145. package/types/src/components/list/list.style.d.ts +2 -0
  146. package/types/src/components/list-item/list-item.d.ts +62 -0
  147. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  148. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  149. package/types/src/components/menu/menu.d.ts +266 -0
  150. package/types/src/components/menu/menu.define.d.ts +1 -0
  151. package/types/src/components/menu/menu.events.d.ts +6 -0
  152. package/types/src/components/menu/menu.style.d.ts +2 -0
  153. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  154. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  155. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  156. package/types/src/components/menu-item/menu-item.d.ts +59 -0
  157. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  158. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  159. package/types/src/components/nav/nav.d.ts +103 -0
  160. package/types/src/components/nav/nav.define.d.ts +1 -0
  161. package/types/src/components/nav/nav.style.d.ts +2 -0
  162. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  163. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  164. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  165. package/types/src/components/pagination/pagination.d.ts +31 -2
  166. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  167. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  168. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  169. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  170. package/types/src/components/splitter/splitter.d.ts +127 -0
  171. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  172. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  173. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  174. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  175. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  176. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  177. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  178. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  179. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  180. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  181. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  182. package/types/src/components/tree/tree.d.ts +62 -0
  183. package/types/src/components/tree/tree.define.d.ts +1 -0
  184. package/types/src/components/tree/tree.style.d.ts +2 -0
  185. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  186. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  187. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  188. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  189. package/types/src/styles/appearance.style.d.ts +31 -0
  190. package/types/src/styles/choice-group.style.d.ts +1 -1
  191. package/types/src/styles/modal.style.d.ts +5 -0
  192. package/types/src/styles/size.style.d.ts +24 -0
  193. package/types/src/utils/focus.d.ts +25 -0
  194. package/types/src/utils/scroll.d.ts +11 -0
  195. package/web-types.json +2530 -393
@@ -0,0 +1,111 @@
1
+ # Nav Item
2
+
3
+ `nav-item` is one destination of an [`el-nav`](../nav/nav.readme.md): a link with an icon and a short text under it. The destination of the current view is marked. It is the same in a bar and in a rail.
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/nav/define';
17
+ import '@webtides/element-library/nav-item/define';
18
+ ```
19
+
20
+ ```html
21
+ <el-nav label="Main">
22
+ <el-nav-item href="/inbox" current="true">
23
+ <svg slot="icon" aria-hidden="true">…</svg>
24
+ Inbox
25
+ <el-badge slot="badge" variant="danger" pill="true">12</el-badge>
26
+ </el-nav-item>
27
+ </el-nav>
28
+ ```
29
+
30
+ > Boolean attributes are passed as strings (`current="true"`), matching the rest of the library.
31
+
32
+ ## API
33
+
34
+ #### Properties/Attributes
35
+
36
+ | Name | Type | Default | Description |
37
+ | --- | --- | --- | --- |
38
+ | `href` | `string` | `''` | The address the destination leads to. |
39
+ | `target` | `string` | `''` | Where to open the address. |
40
+ | `rel` | `string` | `'noreferrer noopener'` | `rel` attribute for the link, written when `target` is set. |
41
+ | `current` | `boolean` | `false` | The destination of the current view: the link gets `aria-current="page"`, a heavier text and a shape behind its icon. |
42
+
43
+ #### Methods
44
+
45
+ _None._
46
+
47
+ #### Events
48
+
49
+ _None._
50
+
51
+ #### Slots
52
+
53
+ | Name | Description |
54
+ | --------- | ---------------------------------------------------------------------- |
55
+ | (default) | The short text of the destination. One line: what does not fit is cut. |
56
+ | `icon` | The icon of the destination: a decoration, the text is the name. |
57
+ | `badge` | A count or a dot, an `el-badge` as a rule: at the corner of the icon. |
58
+
59
+ #### CSS Parts
60
+
61
+ | Name | Description |
62
+ | ------- | ---------------------------------------------------------------------- |
63
+ | `base` | The entry of the list (`role="listitem"`). |
64
+ | `link` | The link: the whole destination is its target. |
65
+ | `icon` | The icon, with the shape behind it that marks the current destination. |
66
+ | `label` | The text of the destination. |
67
+ | `badge` | The place of the badge: the corner of the icon, the end of a row. |
68
+
69
+ #### CSS Custom Properties
70
+
71
+ Reads `--el-color-fg-muted` for a destination and `--el-color-fg` for the current one, `--el-color-bg-muted` for the shape behind the icon, `--el-font-size-xs` for the text and `--el-font-size-md` for the icon, `--el-control-height`, `--el-space-1`, `--el-space-2` and `--el-space-3` for its sizes, `--el-focus-ring-width` and `--el-color-focus-ring` for the focus, and `--el-touch-target` on a touch screen. As a row of a list it reads `--el-font-size-sm` for its text and `--el-radius-md` for the corners of its surface.
72
+
73
+ ## The icon and the text
74
+
75
+ The icon is a decoration: give it `aria-hidden="true"`. The text is the name of the destination, so keep it to a word or two. It is one line, and what does not fit is cut with an ellipsis. Assistive technology reads all of it.
76
+
77
+ Where the `el-nav` shows icons alone (`labels="false"`), the text is off the screen. It stays the name of the link, and the `el-nav` shows it as a tooltip. Write the text in every case.
78
+
79
+ ## The current destination
80
+
81
+ `current="true"` marks the destination of the view the user is at. The link gets `aria-current="page"`, and for the eye:
82
+
83
+ - the colour of the text instead of the muted one,
84
+ - a heavier text,
85
+ - a shape behind the icon.
86
+
87
+ The weight and the shape are there for a user who does not see the difference of two colours. Where the user forces colours the shape is an outline: it has a border. Without a theme the weight is what marks the destination.
88
+
89
+ ## In a bar, a rail and a list
90
+
91
+ What a destination looks like is the business of the `el-nav` around it, which says so in CSS properties that are inherited:
92
+
93
+ - **In a bar and in a rail** the icon is over the text, and the shape of the current destination is behind its icon.
94
+ - **In a list** (`layout="list"`, or `column="list"` in the column of a frame) the text is beside the icon, in a row that is as high as a control. The shape of the current destination is behind the whole row, and what is in the `badge` slot is at the end of the row, in the flow.
95
+
96
+ The markup is the same in all three.
97
+
98
+ ## A count or a dot
99
+
100
+ An `el-badge` in the `badge` slot sits on the corner of the icon and takes no room. In a list it is at the end of the row. It is part of the link and comes after the text, so a screen reader reads it with the name: "Inbox 12". Say what a bare number counts, and give a dot a text, for assistive technology alone:
101
+
102
+ ```html
103
+ <el-badge slot="badge" pill="true">12 <span class="el-visually-hidden">unread</span></el-badge>
104
+ ```
105
+
106
+ ## Accessibility
107
+
108
+ - An entry of a list (`role="listitem"`) with a link in it. The whole destination is the target of the link.
109
+ - The focus of the keyboard shows as a ring inside of the destination.
110
+ - On a touch screen the link is at least `--el-touch-target` wide and high. Without the token nothing changes.
111
+ - The shape of a destination under the pointer shows only where a pointer can hover.
@@ -0,0 +1,159 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ /*
7
+ * What a destination looks like is the business of the el-nav around it: a bar, a rail or a
8
+ * list. It says so in properties that are inherited, and every rule here reads one of them and
9
+ * falls back to the value of a bar.
10
+ */
11
+ :host {
12
+ display: block;
13
+ /* In a bar a destination is as wide as its part of the bar, whatever its text needs. In a
14
+ rail and in a list it is as high as it is. */
15
+ flex: var(--_el-nav-item-flex, 1 1 0);
16
+ min-inline-size: 0;
17
+ }
18
+
19
+ .item {
20
+ block-size: 100%;
21
+ }
22
+
23
+ /*
24
+ * The whole destination is the link: the icon, and the text under it. As high as an app bar,
25
+ * so the two bars of a phone are the same. In a list the text is beside the icon, and the row
26
+ * is as high as a control.
27
+ *
28
+ * The mark of the current row of a list is a surface behind the whole of it, with a border.
29
+ * A row that is not the current one has no border, and the room of one as padding: forced
30
+ * colours would paint a border.
31
+ */
32
+ .link {
33
+ position: relative;
34
+ display: flex;
35
+ flex-direction: var(--_el-nav-item-direction, column);
36
+ align-items: center;
37
+ justify-content: var(--_el-nav-item-justify, center);
38
+ gap: var(--_el-nav-item-gap, 0.125rem);
39
+ box-sizing: border-box;
40
+ block-size: 100%;
41
+ min-block-size: var(
42
+ --_el-nav-item-min-block-size,
43
+ calc(var(--el-control-height, 2.5rem) + 2 * var(--el-space-2, 0.5rem))
44
+ );
45
+ padding: calc(
46
+ var(--_el-nav-item-padding-block, var(--el-space-1, 0.25rem)) + var(--_el-nav-item-mark-width, 0px)
47
+ )
48
+ calc(var(--_el-nav-item-padding-inline, var(--el-space-1, 0.25rem)) + var(--_el-nav-item-mark-width, 0px));
49
+ border-radius: var(--_el-nav-item-radius, 0);
50
+ color: var(--el-color-fg-muted, inherit);
51
+ font-size: var(--_el-nav-item-font-size, var(--el-font-size-xs, 0.75rem));
52
+ line-height: 1.2;
53
+ text-decoration: none;
54
+ }
55
+
56
+ /* The ring is inside of the destination: a bar has the edge of the screen around it. */
57
+ .link:focus-visible {
58
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
59
+ outline-offset: calc(-1 * var(--el-focus-ring-width, 2px));
60
+ }
61
+
62
+ /* The icon, and a shape behind it. The shape of a destination that is not the current one has
63
+ no border, and the room of one as padding: forced colours would paint a border. In a list
64
+ the icon has no shape, the row has. */
65
+ .icon {
66
+ position: relative;
67
+ display: inline-flex;
68
+ flex: none;
69
+ align-items: center;
70
+ justify-content: center;
71
+ min-inline-size: 1.5em;
72
+ min-block-size: 1.5em;
73
+ padding: calc(var(--_el-nav-icon-padding-block, 0.125rem) + var(--_el-nav-icon-mark-width, 1px))
74
+ calc(var(--_el-nav-icon-padding-inline, var(--el-space-3, 0.75rem)) + var(--_el-nav-icon-mark-width, 1px));
75
+ border-radius: 999px;
76
+ /* An icon is larger than the text under it. */
77
+ font-size: var(--el-font-size-md, 1rem);
78
+ }
79
+
80
+ /* The badge sits on the corner of the icon at the end, and takes no room. It is after the
81
+ text in the link, where a screen reader reads it, and placed from the middle of the link.
82
+ In a list it is at the end of the row. */
83
+ .badge {
84
+ position: var(--_el-nav-badge-position, absolute);
85
+ inset-block-start: 0.125rem;
86
+ inset-inline-start: 50%;
87
+ flex: none;
88
+ margin-inline-start: var(--_el-nav-badge-margin, var(--el-space-1, 0.25rem));
89
+ display: inline-flex;
90
+ }
91
+
92
+ /* One line. What does not fit is cut, and the bar keeps its height. In a list the text takes
93
+ the room between the icon and the end of the row.
94
+ Where the el-nav shows icons alone, the text is off the screen and stays the name of the
95
+ link. */
96
+ .label {
97
+ position: var(--_el-nav-label-position, static);
98
+ flex: var(--_el-nav-label-flex, 0 1 auto);
99
+ inline-size: var(--_el-nav-label-size, auto);
100
+ block-size: var(--_el-nav-label-size, auto);
101
+ min-inline-size: 0;
102
+ max-inline-size: 100%;
103
+ overflow: hidden;
104
+ clip-path: var(--_el-nav-label-clip, none);
105
+ text-overflow: ellipsis;
106
+ white-space: nowrap;
107
+ }
108
+
109
+ /*
110
+ * The current destination: the colour of the text, a heavier text, and the shape behind the
111
+ * icon, or behind the row in a list. The shape has a border, transparent here: where the user
112
+ * forces colours, a border is painted in a colour of the system, and the shape stays.
113
+ */
114
+ .item--current .link {
115
+ padding: var(--_el-nav-item-padding-block, var(--el-space-1, 0.25rem))
116
+ var(--_el-nav-item-padding-inline, var(--el-space-1, 0.25rem));
117
+ border: var(--_el-nav-item-mark-width, 0px) solid transparent;
118
+ background: var(--_el-nav-item-mark-background, transparent);
119
+ color: var(--el-color-fg, inherit);
120
+ font-weight: var(--el-font-weight-semibold, 600);
121
+ }
122
+
123
+ .item--current .icon {
124
+ padding: var(--_el-nav-icon-padding-block, 0.125rem)
125
+ var(--_el-nav-icon-padding-inline, var(--el-space-3, 0.75rem));
126
+ border: var(--_el-nav-icon-mark-width, 1px) solid transparent;
127
+ background: var(--_el-nav-icon-mark-background, var(--el-color-bg-muted, transparent));
128
+ }
129
+
130
+ /* Under the pointer the shape shows for every destination. Only where a pointer can hover: a
131
+ touch screen leaves the state on what was tapped last. */
132
+ @media (hover: hover) {
133
+ .link:hover {
134
+ background: var(--_el-nav-item-mark-background, transparent);
135
+ color: var(--el-color-fg, inherit);
136
+ }
137
+
138
+ .link:hover .icon {
139
+ background: var(--_el-nav-icon-mark-background, var(--el-color-bg-muted, transparent));
140
+ }
141
+ }
142
+
143
+ /* On a touch screen a destination is at least as large as a finger needs, in both directions.
144
+ Without the token the sizes stay as they are. */
145
+ @media (any-pointer: coarse) {
146
+ .link {
147
+ min-inline-size: var(--el-touch-target, auto);
148
+ min-block-size: max(
149
+ var(
150
+ --_el-nav-item-min-block-size,
151
+ calc(var(--el-control-height, 2.5rem) + 2 * var(--el-space-2, 0.5rem))
152
+ ),
153
+ var(--el-touch-target, 0px)
154
+ );
155
+ }
156
+ }
157
+ `;
158
+
159
+ export default [hostStyle(), style].join('\n');
@@ -12,6 +12,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.4.0] - 2026-11-27
16
+
17
+ ### Added
18
+
19
+ - `href`: the address of a page, with `{page}` in the place of its number (`/notes?page={page}`). With it the pages, the page before and the page after are links, in the server-rendered markup as well: a list that is rendered a page at a time is paged without JavaScript, a page opens in a new tab, and its address can be copied. Without it the pagination is buttons, as before. ([#189](https://github.com/webtides/element-library/issues/189))
20
+ - The current page is a link to its own address with `aria-current="page"`. On the first page the way back, and on the last one the way on, is a link without an address: no stop of the Tab key, and announced as a link that is not available (`role="link"`, `aria-disabled="true"`).
21
+ - A link fires no `pagination-change` and does not set `page`: the address brings the next page. The parts, the sizes, the focus ring and the touch targets are the ones of the buttons.
22
+
15
23
  ## [0.3.0] - 2026-11-17
16
24
 
17
25
  ### Added
@@ -5,6 +5,9 @@ import Events from './pagination.events.js';
5
5
  /** What `perPage` is without a value that can be used. */
6
6
  const PER_PAGE = 10;
7
7
 
8
+ /** What stands for the number of a page in `href`. */
9
+ const PAGE = '{page}';
10
+
8
11
  /**
9
12
  * A whole number that is not negative, from a property that may hold anything.
10
13
  * @param {*} value
@@ -24,17 +27,24 @@ function count(value, fallback) {
24
27
  * The pagination does not load anything. A button sets `page` and fires `pagination-change`, and
25
28
  * the page shows the entries that belong to it.
26
29
  *
30
+ * A list that a server renders a page at a time has the page in its address. With `href`, the
31
+ * address of a page with `{page}` in the place of its number, the pages are links: they are in
32
+ * the server-rendered markup, lead to their page without a script, open in a new tab and can be
33
+ * copied. A link fires nothing and changes nothing: the address it leads to brings the next page.
34
+ *
27
35
  * @element el-pagination
28
36
  *
29
37
  * @fires {CustomEvent<{ page: number }>} pagination-change - Fired when a button has changed the
30
- * page. `detail.page` is the new page. Not fired when `page` is set from a script.
38
+ * page. `detail.page` is the new page. Not fired when `page` is set from a script, and not by
39
+ * a link.
31
40
  *
32
41
  * @slot previous-icon - The icon of the button for the page before. Unset, an arrow head.
33
42
  * @slot next-icon - The icon of the button for the page after. Unset, an arrow head.
34
43
  *
35
44
  * @csspart base - The `nav` landmark.
36
45
  * @csspart list - The row of the buttons.
37
- * @csspart button - Every button: the pages, the page before and the page after.
46
+ * @csspart button - Every button: the pages, the page before and the page after. With `href`
47
+ * they are links, and keep their parts.
38
48
  * @csspart page - The button of a page.
39
49
  * @csspart current - The button of the current page.
40
50
  * @csspart previous - The button for the page before.
@@ -43,6 +53,9 @@ function count(value, fallback) {
43
53
  *
44
54
  * @property {number} page - The current page, counted from 1. A page that does not exist is shown
45
55
  * as the nearest one that does. Default `1`. Reflected to the `page` attribute.
56
+ * @property {string} href - The address of a page, with `{page}` in the place of its number:
57
+ * `/notes?page={page}`. With it the pages, the page before and the page after are links.
58
+ * Default `''`: buttons.
46
59
  * @property {number} total - The number of entries in the whole list. Default `0`.
47
60
  * @property {number} perPage - The number of entries on one page. Default `10`.
48
61
  * @property {number} siblings - How many pages are shown on each side of the current page.
@@ -76,6 +89,7 @@ export default class Pagination extends TemplateElement {
76
89
  properties() {
77
90
  return {
78
91
  page: 1,
92
+ href: '',
79
93
  total: 0,
80
94
  perPage: PER_PAGE,
81
95
  siblings: 1,
@@ -194,13 +208,42 @@ export default class Pagination extends TemplateElement {
194
208
  ];
195
209
  }
196
210
 
211
+ /**
212
+ * The address of a page: `href` with the number in the place of its mark.
213
+ * @private
214
+ * @param {number} page
215
+ * @returns {string}
216
+ */
217
+ _address(page) {
218
+ return String(this.href).replaceAll(PAGE, String(page));
219
+ }
220
+
197
221
  /** @private */
198
222
  _pageTemplate(page, current) {
199
223
  const isCurrent = page === current;
224
+ const part = isCurrent ? 'button page current' : 'button page';
225
+
226
+ // A link to the page. The current one is a link as well, to the address the user is at:
227
+ // it can be copied and opened again.
228
+ if (this.href) {
229
+ return html`
230
+ <li>
231
+ <a
232
+ part="${part}"
233
+ href="${this._address(page)}"
234
+ aria-label="${this.pageLabel} ${page}"
235
+ aria-current="${isCurrent ? 'page' : null}"
236
+ >
237
+ ${page}
238
+ </a>
239
+ </li>
240
+ `;
241
+ }
242
+
200
243
  return html`
201
244
  <li>
202
245
  <button
203
- part="${isCurrent ? 'button page current' : 'button page'}"
246
+ part="${part}"
204
247
  type="button"
205
248
  aria-label="${this.pageLabel} ${page}"
206
249
  aria-current="${isCurrent ? 'page' : undefined}"
@@ -212,63 +255,94 @@ export default class Pagination extends TemplateElement {
212
255
  `;
213
256
  }
214
257
 
258
+ /**
259
+ * The way to the page before or after, as a link. Where there is no such page, at the first
260
+ * page and at the last one, it is a link without an address: no stop of the Tab key, and one
261
+ * that says to assistive technology that it leads nowhere now.
262
+ * @private
263
+ * @param {'previous'|'next'} name
264
+ * @param {number} page - The page it leads to.
265
+ * @param {string} label
266
+ * @param {*} icon - The slot of its icon.
267
+ */
268
+ _stepLinkTemplate(name, page, label, icon) {
269
+ const there = page >= 1 && page <= this.pages;
270
+ return html`
271
+ <li>
272
+ <a
273
+ part="button ${name}"
274
+ href="${there ? this._address(page) : null}"
275
+ rel="${there ? (name === 'previous' ? 'prev' : 'next') : null}"
276
+ role="${there ? null : 'link'}"
277
+ aria-disabled="${there ? null : 'true'}"
278
+ aria-label="${label}"
279
+ >
280
+ ${icon}
281
+ </a>
282
+ </li>
283
+ `;
284
+ }
285
+
215
286
  template() {
216
287
  const current = this._currentPage();
288
+ const arrow = (points) => html`
289
+ <svg
290
+ viewBox="0 0 24 24"
291
+ fill="none"
292
+ stroke="currentColor"
293
+ stroke-width="2"
294
+ stroke-linecap="round"
295
+ stroke-linejoin="round"
296
+ aria-hidden="true"
297
+ >
298
+ <polyline points="${points}"></polyline>
299
+ </svg>
300
+ `;
301
+ const previousIcon = html`<slot name="previous-icon">${arrow('15 18 9 12 15 6')}</slot>`;
302
+ const nextIcon = html`<slot name="next-icon">${arrow('9 18 15 12 9 6')}</slot>`;
217
303
 
218
304
  return html`
219
305
  <nav part="base" aria-label="${this.label}">
220
306
  <ul part="list" role="list">
221
- <li>
222
- <button
223
- part="button previous"
224
- type="button"
225
- aria-label="${this.previousLabel}"
226
- ?disabled="${current <= 1}"
227
- data-step="-1"
228
- >
229
- <slot name="previous-icon">
230
- <svg
231
- viewBox="0 0 24 24"
232
- fill="none"
233
- stroke="currentColor"
234
- stroke-width="2"
235
- stroke-linecap="round"
236
- stroke-linejoin="round"
237
- aria-hidden="true"
238
- >
239
- <polyline points="15 18 9 12 15 6"></polyline>
240
- </svg>
241
- </slot>
242
- </button>
243
- </li>
307
+ ${
308
+ this.href
309
+ ? this._stepLinkTemplate('previous', current - 1, this.previousLabel, previousIcon)
310
+ : html`
311
+ <li>
312
+ <button
313
+ part="button previous"
314
+ type="button"
315
+ aria-label="${this.previousLabel}"
316
+ ?disabled="${current <= 1}"
317
+ data-step="-1"
318
+ >
319
+ ${previousIcon}
320
+ </button>
321
+ </li>
322
+ `
323
+ }
244
324
  ${this._items().map((page) =>
245
325
  page === null
246
326
  ? html`<li part="ellipsis" aria-hidden="true">…</li>`
247
327
  : this._pageTemplate(page, current),
248
328
  )}
249
- <li>
250
- <button
251
- part="button next"
252
- type="button"
253
- aria-label="${this.nextLabel}"
254
- ?disabled="${current >= this.pages}"
255
- data-step="1"
256
- >
257
- <slot name="next-icon">
258
- <svg
259
- viewBox="0 0 24 24"
260
- fill="none"
261
- stroke="currentColor"
262
- stroke-width="2"
263
- stroke-linecap="round"
264
- stroke-linejoin="round"
265
- aria-hidden="true"
266
- >
267
- <polyline points="9 18 15 12 9 6"></polyline>
268
- </svg>
269
- </slot>
270
- </button>
271
- </li>
329
+ ${
330
+ this.href
331
+ ? this._stepLinkTemplate('next', current + 1, this.nextLabel, nextIcon)
332
+ : html`
333
+ <li>
334
+ <button
335
+ part="button next"
336
+ type="button"
337
+ aria-label="${this.nextLabel}"
338
+ ?disabled="${current >= this.pages}"
339
+ data-step="1"
340
+ >
341
+ ${nextIcon}
342
+ </button>
343
+ </li>
344
+ `
345
+ }
272
346
  </ul>
273
347
  </nav>
274
348
  `;
@@ -2,7 +2,7 @@
2
2
 
3
3
  `pagination` is the way through a list that is split into pages. It shows the current page, the pages around it, the first and the last, and a button for the page before and the page after. The pages in between are left out, and the row keeps its length while the current page moves.
4
4
 
5
- It loads nothing itself: a button sets `page` and fires `pagination-change`, and the page shows the entries that belong to it.
5
+ It loads nothing itself: a button sets `page` and fires `pagination-change`, and the page shows the entries that belong to it. For a list that a server renders a page at a time, the pages are links instead: see [Pages as links](#pages-as-links).
6
6
 
7
7
  ## How to use
8
8
 
@@ -41,6 +41,7 @@ pagination.addEventListener('pagination-change', (event) => {
41
41
  | Name | Type | Default | Description |
42
42
  | --- | --- | --- | --- |
43
43
  | `page` | `number` | `1` | The current page, counted from 1. Reflected. |
44
+ | `href` | `string` | `''` | The address of a page, with `{page}` in the place of its number: `/notes?page={page}`. With it the pages are links. |
44
45
  | `total` | `number` | `0` | The number of entries in the whole list. |
45
46
  | `per-page` | `number` | `10` | The number of entries on one page. |
46
47
  | `siblings` | `number` | `1` | How many pages are shown on each side of the current page. |
@@ -60,7 +61,7 @@ _None._
60
61
 
61
62
  | Name | Detail | Description |
62
63
  | --- | --- | --- |
63
- | `pagination-change` | `{ page: number }` | Fired when a button has changed the page. Not fired when `page` is set from a script. |
64
+ | `pagination-change` | `{ page: number }` | Fired when a button has changed the page. Not fired when `page` is set from a script, and not by a link. |
64
65
 
65
66
  #### Slots
66
67
 
@@ -75,7 +76,7 @@ _None._
75
76
  | ---------- | ------------------------------------------------------------ |
76
77
  | `base` | The `nav` landmark. |
77
78
  | `list` | The row of the buttons. |
78
- | `button` | Every button: the pages, the page before and the page after. |
79
+ | `button` | Every button, or link: the pages, the page before and after. |
79
80
  | `page` | The button of a page. |
80
81
  | `current` | The button of the current page. |
81
82
  | `previous` | The button for the page before. |
@@ -122,7 +123,24 @@ Where the row does not fit into its container it breaks into a second row. With
122
123
 
123
124
  A click on the current page does nothing. `page` set from a script changes the row without an event.
124
125
 
125
- The pagination renders buttons, not links: it does not change the address of the page. Write the page into the address in the listener where a page should be reachable by a link.
126
+ A button does not change the address of the page. Where every page of the list has an address, give the pagination `href`: its pages are links then, and fire nothing.
127
+
128
+ ## Pages as links
129
+
130
+ A list that a server renders a page at a time has the page in its address: `/notes?page=3`. Such a list works before any script has run, a page of it opens in a new tab and can be sent to somebody, and a step back leads to the page before. `href` says how the address of a page is formed, with `{page}` in the place of the number:
131
+
132
+ ```html
133
+ <el-pagination href="/notes?page={page}" total="182" page="3"></el-pagination>
134
+ ```
135
+
136
+ - **The pages, the page before and the page after are links** (`<a href>`), in the server-rendered markup as well. They lead to their page without JavaScript, and a click with a modifier key or the middle button is the browser's.
137
+ - **The mark can be anywhere in the address**, and more than once: `/notes/page/{page}` works as `?page={page}` does.
138
+ - **What else is in the address stays**, because the page writes all of it: `href="/search?q=tea&sort=new&page={page}"`. The element does not read the address of the document. A server does not have one to read, and the markup of the server would differ from the one of the browser.
139
+ - **The current page** is a link too, to the address the user is at, with `aria-current="page"`.
140
+ - **On the first page there is no way back, and on the last one no way on.** That entry is a link without an address there: the Tab key does not stop at it, and it says to assistive technology that it is a link and that it is not available (`role="link"`, `aria-disabled="true"`).
141
+ - **A link fires nothing and sets nothing.** `pagination-change` is the event of a button. The address the link leads to brings the next page, and with it the `page` of the element. An application that changes the view without loading hears the click as it hears the one of any link, and sets `page` when the view has changed.
142
+ - The parts, the sizes, the focus ring and the touch targets are the ones of the buttons. `::part(button)`, `::part(page)`, `::part(current)`, `::part(previous)` and `::part(next)` select a link as they select a button.
143
+ - Without `href` the pagination is buttons, as before.
126
144
 
127
145
  ## Size and look
128
146
 
@@ -153,7 +171,7 @@ Both `page` and `size` are reflected: the element writes them onto itself as att
153
171
  ## Accessibility
154
172
 
155
173
  - The pagination is a navigation landmark (`nav`) with the name in `label`. Two paginations on one page need two names, "Pages of the results" and "Pages of the comments" for example.
156
- - The row is a list of buttons. Every button has a name: "Page 3", "Previous page", "Next page". The button of the current page is marked with `aria-current="page"`.
174
+ - The row is a list of buttons, or of links with `href`. Every one has a name: "Page 3", "Previous page", "Next page". The current page is marked with `aria-current="page"`.
157
175
  - The names are English by default. For another language set `label`, `page-label`, `previous-label` and `next-label`.
158
176
  - The ellipsis and the arrow heads are hidden from assistive technology.
159
177
  - All buttons are reached with `Tab` and pressed with `Enter` or `Space`. The button for the page before is disabled on the first page, the one for the page after on the last.
@@ -164,4 +182,4 @@ Both `page` and `size` are reflected: the element writes them onto itself as att
164
182
 
165
183
  ## Server-side rendering
166
184
 
167
- The pagination is fully part of the server-rendered markup (Declarative Shadow DOM): the row for the `page`, `total` and `per-page` of the element, the current page and the disabled buttons. Without JavaScript the buttons do nothing.
185
+ The pagination is fully part of the server-rendered markup (Declarative Shadow DOM): the row for the `page`, `total` and `per-page` of the element, the current page and the disabled buttons. Without JavaScript the buttons do nothing. With `href` the row is links, which lead to their pages without it.
@@ -57,6 +57,13 @@ const style = css`
57
57
  transition: background var(--el-duration-md, 0s) var(--el-ease, linear);
58
58
  }
59
59
 
60
+ /* A page that is a link (\`href\`) has the box of a button: a button counts its sizes from
61
+ its border and has no line under its text. */
62
+ a[part~='button'] {
63
+ box-sizing: border-box;
64
+ text-decoration: none;
65
+ }
66
+
60
67
  [part~='ellipsis'] {
61
68
  color: var(--el-color-fg-muted, inherit);
62
69
  user-select: none;
@@ -140,7 +147,10 @@ const style = css`
140
147
  }
141
148
  }
142
149
 
143
- [part~='button'][disabled] {
150
+ /* The way back on the first page and the way on at the last one: a button that is disabled,
151
+ or a link without an address. */
152
+ [part~='button'][disabled],
153
+ [part~='button'][aria-disabled='true'] {
144
154
  background: transparent;
145
155
  opacity: 0.55;
146
156
  cursor: not-allowed;
@@ -10,11 +10,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
10
10
  Uncomment headings as needed.
11
11
  -->
12
12
 
13
- <!-- ## Unreleased -->
14
- <!-- ### Added -->
15
- <!-- ### Changed -->
16
- <!-- ### Removed -->
17
- <!-- ### Fixed -->
13
+ ## Unreleased
14
+
15
+ ## [0.4.0] - 2026-11-27
16
+
17
+ ### Changed
18
+
19
+ - It scrolls the element around it that scrolls to the top, the content of an `el-app-frame` for example, and the window where there is none. Before, it scrolled the window whatever it was in. `duration` is ignored when that element has `scroll-behavior: smooth`. ([#176](https://github.com/webtides/element-library/issues/176))
18
20
 
19
21
  ## [0.1.0] - 2026-06-03
20
22