@lilydesignsystem/nunjucks-picker-bar 0.3.0 → 0.5.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/LICENSE.md +64 -0
- package/README.md +166 -0
- package/dist/index.d.ts +20 -3
- package/dist/index.js +21 -1
- package/dist/picker-bar.njk +35 -10
- package/index.md +2 -0
- package/package.json +16 -5
package/LICENSE.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!-- Synced from the canonical repository by bin/sync-special-files.
|
|
2
|
+
Do not edit here; edit the root copy and re-run the script.
|
|
3
|
+
Canonical: https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSE.md -->
|
|
4
|
+
|
|
5
|
+
# License
|
|
6
|
+
|
|
7
|
+
Lily Design System™ is free open source software.
|
|
8
|
+
|
|
9
|
+
License is any of these, at your option, or contact us for custom license options.
|
|
10
|
+
|
|
11
|
+
* [MIT](https://opensource.org/license/mit) ([SPDX: MIT](https://spdx.org/licenses/MIT.html))
|
|
12
|
+
|
|
13
|
+
* [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([SPDX: Apache-2.0](https://spdx.org/licenses/Apache-2.0.html))
|
|
14
|
+
|
|
15
|
+
* [GNU General Public License v2.0](https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html) ([SPDX: GPL-2.0-only](https://spdx.org/licenses/GPL-2.0-only.html))
|
|
16
|
+
|
|
17
|
+
* [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) ([SPDX: GPL-3.0-only](https://spdx.org/licenses/GPL-3.0-only.html))
|
|
18
|
+
|
|
19
|
+
* [BSD 3-Clause License](https://opensource.org/license/bsd-3-clause) ([SPDX: BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html))
|
|
20
|
+
|
|
21
|
+
## SPDX
|
|
22
|
+
|
|
23
|
+
The machine-readable expression for the choice above is:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
SPDX-License-Identifier: MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Every package manifest in this repository should carry that expression, or a
|
|
30
|
+
single identifier from the list where the packaging format does not accept a
|
|
31
|
+
disjunction. You do not need permission to pick one: choose whichever member of
|
|
32
|
+
the list suits your project and comply with that one.
|
|
33
|
+
|
|
34
|
+
This applies to the whole repository — the component catalog, the seven headless
|
|
35
|
+
libraries, the seven example applications, the seven helper catalogs, the
|
|
36
|
+
`themes/` stylesheets, the `bin/` tooling, and the documentation.
|
|
37
|
+
|
|
38
|
+
## Scope note
|
|
39
|
+
|
|
40
|
+
This file supersedes an earlier `CC BY-NC-SA` notice. That notice was a content
|
|
41
|
+
license with a non-commercial clause, it was not an open-source license, and it
|
|
42
|
+
contradicted both the specification and the published packages. It should not be
|
|
43
|
+
relied on. If you obtained Lily under it and that raises a question for you,
|
|
44
|
+
contact <joel@joelparkerhenderson.com>.
|
|
45
|
+
|
|
46
|
+
## Trademarks
|
|
47
|
+
|
|
48
|
+
Lily™ and Lily Design System™ are trademarks. The trademarks are distinct from
|
|
49
|
+
the software license: a trademark claim (™) asserts use of the marks and is
|
|
50
|
+
independent of the licenses above. A license to the software is not a license to
|
|
51
|
+
the marks.
|
|
52
|
+
|
|
53
|
+
You may say your project uses Lily, is built with Lily, or is compatible with
|
|
54
|
+
Lily. Please do not use the marks as the name of your fork or product, or in a
|
|
55
|
+
way that suggests affiliation or endorsement. For any use beyond that, contact
|
|
56
|
+
<joel@joelparkerhenderson.com>.
|
|
57
|
+
|
|
58
|
+
## Third-party references
|
|
59
|
+
|
|
60
|
+
Lily's example applications and `themes/` stylesheets take visual reference from
|
|
61
|
+
public-sector design systems including NHS UK, GOV.UK, and USWDS. Lily is not
|
|
62
|
+
affiliated with, endorsed by, or connected to any of those organisations. Their
|
|
63
|
+
names and marks belong to them, and this license grants nothing in respect of
|
|
64
|
+
them.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Lily Design System™ — Nunjucks PickerBar
|
|
2
|
+
|
|
3
|
+
> **Link picker (0.3.0).** Pass `links` (and `labels.link`) to add a `link-picker` — a home icon opening the page links your app defines — as the leftmost icon. It renders only when both are given.
|
|
4
|
+
|
|
5
|
+
> **Time zone picker (0.5.0).** Pass `labels.timeZone` and `timeZoneProps: { locale, options }`, where `options = timeZoneOptions({ locale })` from `@lilydesignsystem/nunjucks-time-zone-picker` is built where the page is built (and `names` there for CLDR names) to add a `time-zone-picker` — time zones by UTC offset with their full names — right after the locale picker. It renders only when both the label and the locale are given. To name the text sizes in the reader's language pass `sizeLabels` through the text-size props (`textSizeLabels(pack)` / `LocaleTranslations.TextSizeLabels(locale)` from the locale-translations package).
|
|
6
|
+
|
|
7
|
+
A single page-header macro that composes five of the Lily
|
|
8
|
+
[`*-picker` helpers](../index.md) in this catalog — search, theme,
|
|
9
|
+
locale, text size, and share, in that order — with two catalog-wide
|
|
10
|
+
defaults pre-wired, so you can call one macro instead of assembling
|
|
11
|
+
and configuring five.
|
|
12
|
+
|
|
13
|
+
`motion-picker` and `date-time-picker` are not part of the bar: motion
|
|
14
|
+
has no natural spot next to the other three header preferences, and
|
|
15
|
+
`date-time-picker` is a form control, not a header control.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @lilydesignsystem/nunjucks-picker-bar
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`@lilydesignsystem/nunjucks-search-picker`, `-theme-picker`,
|
|
24
|
+
`-locale-picker`, `-text-size-picker`, and `-share-picker` install
|
|
25
|
+
automatically as
|
|
26
|
+
regular dependencies — `pickerBar` is a thin wrapper around them, not
|
|
27
|
+
a reimplementation.
|
|
28
|
+
|
|
29
|
+
Point your Nunjucks `Environment` at `node_modules` so the macro's
|
|
30
|
+
cross-package imports resolve:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import nunjucks from "nunjucks";
|
|
34
|
+
const env = nunjucks.configure(["views", "node_modules"], { autoescape: true });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```njk
|
|
40
|
+
{% from "lily-design-system-nunjucks-picker-bar/dist/picker-bar.njk" import pickerBar %}
|
|
41
|
+
|
|
42
|
+
{{ pickerBar({
|
|
43
|
+
labels: {
|
|
44
|
+
search: "Search this site",
|
|
45
|
+
searchInput: "Search terms",
|
|
46
|
+
searchSubmit: "Search",
|
|
47
|
+
theme: "Theme",
|
|
48
|
+
locale: "Language",
|
|
49
|
+
textSize: "Text size",
|
|
50
|
+
share: "Share"
|
|
51
|
+
},
|
|
52
|
+
themesUrl: "/assets/themes/",
|
|
53
|
+
locales: ["en", "cy", "gd", "ga"],
|
|
54
|
+
shareTargets: [
|
|
55
|
+
{ id: "email", label: "Email", href: "mailto:?subject=Check this out&body=https://example.com" }
|
|
56
|
+
]
|
|
57
|
+
}) }}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then load `picker-bar.client.js` once and call `autoInit()`:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<script type="module">
|
|
64
|
+
import { autoInit } from "/path/to/picker-bar.client.js";
|
|
65
|
+
autoInit();
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
That's a complete, working header row: a site search (a search for
|
|
70
|
+
`foo` goes to `/?foo`), 45 themes, four locales, the
|
|
71
|
+
seven-step text-size scale, and one share destination plus copy-to-URL
|
|
72
|
+
if you add `shareProps: { copyLabel: "Copy link" }`.
|
|
73
|
+
|
|
74
|
+
Note the [`share-picker` deviation](../lily-design-system-nunjucks-share-picker/index.md):
|
|
75
|
+
`href` in `shareTargets` is an already-resolved string, not a
|
|
76
|
+
function — a Nunjucks macro cannot call an arbitrary JS function.
|
|
77
|
+
|
|
78
|
+
## Defaults
|
|
79
|
+
|
|
80
|
+
- **`themes`** defaults to `DEFAULT_THEMES` — all 45 Lily reference
|
|
81
|
+
theme slugs, alphabetical, with the 8 United Kingdom / United States
|
|
82
|
+
government themes moved to their own alphabetical group at the
|
|
83
|
+
bottom. Pass your own `themes` array to override.
|
|
84
|
+
- **`sizes`** defaults to `DEFAULT_SIZES` — the seven-step scale
|
|
85
|
+
`largest`, `larger`, `large`, `normal`, `small`, `smaller`,
|
|
86
|
+
`smallest` — and the text-size picker starts on `normal`. Pass your
|
|
87
|
+
own `sizes` array (and `textSizeProps: { defaultValue: "…" }` if
|
|
88
|
+
you want a different starting point) to override.
|
|
89
|
+
|
|
90
|
+
Both are exported from the client.js module too:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { DEFAULT_THEMES, DEFAULT_SIZES } from "@lilydesignsystem/nunjucks-picker-bar";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Passing extra params to one picker
|
|
97
|
+
|
|
98
|
+
Each wrapped picker takes a `*Props` object for anything beyond what
|
|
99
|
+
`pickerBar` lifts to the top level — persistence, initial value,
|
|
100
|
+
detection, a `*Labels` override map, an `id`:
|
|
101
|
+
|
|
102
|
+
```njk
|
|
103
|
+
{{ pickerBar({
|
|
104
|
+
labels: {
|
|
105
|
+
search: "Search this site", searchInput: "Search terms", searchSubmit: "Search",
|
|
106
|
+
theme: "Theme", locale: "Language", textSize: "Text size", share: "Share"
|
|
107
|
+
},
|
|
108
|
+
themesUrl: "/assets/themes/",
|
|
109
|
+
locales: ["en", "cy"],
|
|
110
|
+
searchProps: { action: "/search", placeholder: "Search…" },
|
|
111
|
+
themeProps: { storageKey: "lily-theme", detectFromSystem: true },
|
|
112
|
+
localeProps: { storageKey: "lily-locale", detectFromNavigator: true },
|
|
113
|
+
textSizeProps: { storageKey: "lily-text-size" },
|
|
114
|
+
shareProps: { copyLabel: "Copy link", copiedLabel: "Copied" }
|
|
115
|
+
}) }}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`search-picker`'s function-valued options — `navigate` (default
|
|
119
|
+
`location.assign`) and `onSearch` — cannot pass through a macro, so
|
|
120
|
+
hand them to the client instead:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
autoInit({ searchProps: { navigate: (href) => router.go(href) } });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Unlike the Svelte canonical, `pickerBar` cannot route a custom glyph to
|
|
127
|
+
one specific picker (a Nunjucks macro call accepts only one
|
|
128
|
+
`{% call %}` block) — compose the five macros directly if you need
|
|
129
|
+
that.
|
|
130
|
+
|
|
131
|
+
## Styling
|
|
132
|
+
|
|
133
|
+
`pickerBar` renders no CSS of its own beyond the `picker-bar` root
|
|
134
|
+
wrapper — style each child through its own package's class hooks
|
|
135
|
+
(`search-picker`, `theme-picker`, `locale-picker`, `text-size-picker`,
|
|
136
|
+
`share-picker`;
|
|
137
|
+
see each package's own `index.md`). A typical header layout:
|
|
138
|
+
|
|
139
|
+
```css
|
|
140
|
+
.picker-bar {
|
|
141
|
+
display: flex;
|
|
142
|
+
gap: var(--theme-space-sm, 0.5rem);
|
|
143
|
+
align-items: center;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Accessibility
|
|
148
|
+
|
|
149
|
+
Every accessible name comes from `labels` — `search`, `searchInput`,
|
|
150
|
+
and `searchSubmit` name the search picker's button and landmark, field,
|
|
151
|
+
and `⏎` button; `theme`, `locale`, `textSize`, `share` the others —
|
|
152
|
+
and there is no English
|
|
153
|
+
default, because a set of names this catalog invented is exactly the
|
|
154
|
+
case the rest of Lily's i18n rule exists for. Each wrapped picker keeps
|
|
155
|
+
its own WAI-ARIA APG contract unchanged; see that picker's own
|
|
156
|
+
`index.md`. As with every helper in this catalog, none of the five is
|
|
157
|
+
operable until its client.js has run — see each package's own
|
|
158
|
+
`docs/ssr.md`.
|
|
159
|
+
|
|
160
|
+
## Full contract
|
|
161
|
+
|
|
162
|
+
See [`spec/index.md`](./spec/index.md).
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
Lily™ and Lily Design System™ are trademarks.
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { initLocalePicker } from '@lilydesignsystem/nunjucks-locale-picker';
|
|
|
8
8
|
export { autoInit as autoInitLocalePicker } from '@lilydesignsystem/nunjucks-locale-picker';
|
|
9
9
|
import { initTextSizePicker } from '@lilydesignsystem/nunjucks-text-size-picker';
|
|
10
10
|
export { autoInit as autoInitTextSizePicker } from '@lilydesignsystem/nunjucks-text-size-picker';
|
|
11
|
+
import { initTimeZonePicker } from '@lilydesignsystem/nunjucks-time-zone-picker';
|
|
11
12
|
import { initSharePicker } from '@lilydesignsystem/nunjucks-share-picker';
|
|
12
13
|
export { autoInit as autoInitSharePicker } from '@lilydesignsystem/nunjucks-share-picker';
|
|
13
14
|
|
|
@@ -27,7 +28,7 @@ export { autoInit as autoInitSharePicker } from '@lilydesignsystem/nunjucks-shar
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
* All
|
|
31
|
+
* All 57 Lily reference theme slugs, in the same order as
|
|
31
32
|
* `DEFAULT_THEMES` in picker-bar.njk. A Nunjucks macro cannot import a
|
|
32
33
|
* JS constant, so the two copies are held in agreement by a test
|
|
33
34
|
* rather than by delegation — the same pattern this catalog already
|
|
@@ -38,11 +39,14 @@ const DEFAULT_THEMES = [
|
|
|
38
39
|
"abyss",
|
|
39
40
|
"acid",
|
|
40
41
|
"adobe-spectrum",
|
|
42
|
+
"ant-design",
|
|
41
43
|
"aqua",
|
|
44
|
+
"atlassian",
|
|
42
45
|
"autumn",
|
|
43
46
|
"black",
|
|
44
47
|
"bumblebee",
|
|
45
48
|
"business",
|
|
49
|
+
"cappuccino",
|
|
46
50
|
"caramellatte",
|
|
47
51
|
"cmyk",
|
|
48
52
|
"coffee",
|
|
@@ -53,23 +57,32 @@ const DEFAULT_THEMES = [
|
|
|
53
57
|
"dim",
|
|
54
58
|
"dracula",
|
|
55
59
|
"emerald",
|
|
60
|
+
"excel",
|
|
56
61
|
"fantasy",
|
|
62
|
+
"fluent",
|
|
57
63
|
"forest",
|
|
58
64
|
"garden",
|
|
65
|
+
"github-primer",
|
|
59
66
|
"halloween",
|
|
67
|
+
"ibm-carbon",
|
|
60
68
|
"lemonade",
|
|
61
69
|
"light",
|
|
70
|
+
"linear",
|
|
62
71
|
"lofi",
|
|
63
72
|
"luxury",
|
|
64
73
|
"mozilla-protocol",
|
|
65
74
|
"night",
|
|
66
75
|
"nord",
|
|
76
|
+
"notion",
|
|
67
77
|
"pastel",
|
|
68
78
|
"retro",
|
|
79
|
+
"salesforce",
|
|
80
|
+
"sap-fiori",
|
|
69
81
|
"silk",
|
|
70
82
|
"sunset",
|
|
71
83
|
"synthwave",
|
|
72
84
|
"valentine",
|
|
85
|
+
"vercel",
|
|
73
86
|
"winter",
|
|
74
87
|
"wireframe",
|
|
75
88
|
"united-kingdom-government-digital-service",
|
|
@@ -103,7 +116,7 @@ const DEFAULT_SIZES = [
|
|
|
103
116
|
* rendered one.
|
|
104
117
|
*
|
|
105
118
|
* @param {HTMLElement} root
|
|
106
|
-
* @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
|
|
119
|
+
* @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, timeZoneProps?: object, textSizeProps?: object, shareProps?: object}=} opts
|
|
107
120
|
*/
|
|
108
121
|
function initPickerBar(root, opts = {}) {
|
|
109
122
|
if (!root) {
|
|
@@ -112,6 +125,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
112
125
|
search: null,
|
|
113
126
|
theme: null,
|
|
114
127
|
locale: null,
|
|
128
|
+
timeZone: null,
|
|
115
129
|
textSize: null,
|
|
116
130
|
share: null,
|
|
117
131
|
};
|
|
@@ -121,6 +135,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
121
135
|
searchProps = {},
|
|
122
136
|
themeProps = {},
|
|
123
137
|
localeProps = {},
|
|
138
|
+
timeZoneProps = {},
|
|
124
139
|
textSizeProps = {},
|
|
125
140
|
shareProps = {},
|
|
126
141
|
} = opts;
|
|
@@ -129,6 +144,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
129
144
|
const searchRoot = root.querySelector("[data-lily-search-picker-root]");
|
|
130
145
|
const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
|
|
131
146
|
const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
|
|
147
|
+
const timeZoneRoot = root.querySelector("[data-lily-time-zone-picker-root]");
|
|
132
148
|
const textSizeRoot = root.querySelector(
|
|
133
149
|
"[data-lily-text-size-picker-root]",
|
|
134
150
|
);
|
|
@@ -139,6 +155,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
139
155
|
search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
|
|
140
156
|
theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
|
|
141
157
|
locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
|
|
158
|
+
timeZone: timeZoneRoot ? initTimeZonePicker(timeZoneRoot, timeZoneProps) : null,
|
|
142
159
|
textSize: textSizeRoot
|
|
143
160
|
? initTextSizePicker(textSizeRoot, textSizeProps)
|
|
144
161
|
: null,
|
|
@@ -149,7 +166,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
149
166
|
/**
|
|
150
167
|
* Find every `[data-lily-picker-bar-root]` and wire it.
|
|
151
168
|
*
|
|
152
|
-
* @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
|
|
169
|
+
* @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, timeZoneProps?: object, textSizeProps?: object, shareProps?: object}=} opts
|
|
153
170
|
* @returns {Array<ReturnType<typeof initPickerBar>>}
|
|
154
171
|
*/
|
|
155
172
|
function autoInit(opts = {}) {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// picker-bar.client.js
|
|
2
2
|
import {
|
|
3
3
|
initLinkPicker,
|
|
4
4
|
autoInit as autoInitLinkPicker
|
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
initTextSizePicker,
|
|
20
20
|
autoInit as autoInitTextSizePicker
|
|
21
21
|
} from "@lilydesignsystem/nunjucks-text-size-picker";
|
|
22
|
+
import {
|
|
23
|
+
initTimeZonePicker,
|
|
24
|
+
autoInit as autoInitTimeZonePicker
|
|
25
|
+
} from "@lilydesignsystem/nunjucks-time-zone-picker";
|
|
22
26
|
import {
|
|
23
27
|
initSharePicker,
|
|
24
28
|
autoInit as autoInitSharePicker
|
|
@@ -27,11 +31,14 @@ var DEFAULT_THEMES = [
|
|
|
27
31
|
"abyss",
|
|
28
32
|
"acid",
|
|
29
33
|
"adobe-spectrum",
|
|
34
|
+
"ant-design",
|
|
30
35
|
"aqua",
|
|
36
|
+
"atlassian",
|
|
31
37
|
"autumn",
|
|
32
38
|
"black",
|
|
33
39
|
"bumblebee",
|
|
34
40
|
"business",
|
|
41
|
+
"cappuccino",
|
|
35
42
|
"caramellatte",
|
|
36
43
|
"cmyk",
|
|
37
44
|
"coffee",
|
|
@@ -42,23 +49,32 @@ var DEFAULT_THEMES = [
|
|
|
42
49
|
"dim",
|
|
43
50
|
"dracula",
|
|
44
51
|
"emerald",
|
|
52
|
+
"excel",
|
|
45
53
|
"fantasy",
|
|
54
|
+
"fluent",
|
|
46
55
|
"forest",
|
|
47
56
|
"garden",
|
|
57
|
+
"github-primer",
|
|
48
58
|
"halloween",
|
|
59
|
+
"ibm-carbon",
|
|
49
60
|
"lemonade",
|
|
50
61
|
"light",
|
|
62
|
+
"linear",
|
|
51
63
|
"lofi",
|
|
52
64
|
"luxury",
|
|
53
65
|
"mozilla-protocol",
|
|
54
66
|
"night",
|
|
55
67
|
"nord",
|
|
68
|
+
"notion",
|
|
56
69
|
"pastel",
|
|
57
70
|
"retro",
|
|
71
|
+
"salesforce",
|
|
72
|
+
"sap-fiori",
|
|
58
73
|
"silk",
|
|
59
74
|
"sunset",
|
|
60
75
|
"synthwave",
|
|
61
76
|
"valentine",
|
|
77
|
+
"vercel",
|
|
62
78
|
"winter",
|
|
63
79
|
"wireframe",
|
|
64
80
|
"united-kingdom-government-digital-service",
|
|
@@ -86,6 +102,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
86
102
|
search: null,
|
|
87
103
|
theme: null,
|
|
88
104
|
locale: null,
|
|
105
|
+
timeZone: null,
|
|
89
106
|
textSize: null,
|
|
90
107
|
share: null
|
|
91
108
|
};
|
|
@@ -95,6 +112,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
95
112
|
searchProps = {},
|
|
96
113
|
themeProps = {},
|
|
97
114
|
localeProps = {},
|
|
115
|
+
timeZoneProps = {},
|
|
98
116
|
textSizeProps = {},
|
|
99
117
|
shareProps = {}
|
|
100
118
|
} = opts;
|
|
@@ -102,6 +120,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
102
120
|
const searchRoot = root.querySelector("[data-lily-search-picker-root]");
|
|
103
121
|
const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
|
|
104
122
|
const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
|
|
123
|
+
const timeZoneRoot = root.querySelector("[data-lily-time-zone-picker-root]");
|
|
105
124
|
const textSizeRoot = root.querySelector(
|
|
106
125
|
"[data-lily-text-size-picker-root]"
|
|
107
126
|
);
|
|
@@ -111,6 +130,7 @@ function initPickerBar(root, opts = {}) {
|
|
|
111
130
|
search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
|
|
112
131
|
theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
|
|
113
132
|
locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
|
|
133
|
+
timeZone: timeZoneRoot ? initTimeZonePicker(timeZoneRoot, timeZoneProps) : null,
|
|
114
134
|
textSize: textSizeRoot ? initTextSizePicker(textSizeRoot, textSizeProps) : null,
|
|
115
135
|
share: shareRoot ? initSharePicker(shareRoot, shareProps) : null
|
|
116
136
|
};
|
package/dist/picker-bar.njk
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
one-line Environment setup. In this monorepo's own dev/test tree the
|
|
23
23
|
same relative shape already holds: each sibling package sits at
|
|
24
24
|
`../lily-design-system-nunjucks-{name}-picker/dist/{name}-picker.njk`
|
|
25
|
-
relative to the
|
|
25
|
+
relative to the repository root, exactly where `node_modules` would
|
|
26
26
|
place it after a real install.
|
|
27
27
|
#}
|
|
28
28
|
{% from "lily-design-system-nunjucks-link-picker/dist/link-picker.njk" import linkPicker %}
|
|
@@ -30,9 +30,10 @@
|
|
|
30
30
|
{% from "lily-design-system-nunjucks-theme-picker/dist/theme-picker.njk" import themePicker %}
|
|
31
31
|
{% from "lily-design-system-nunjucks-locale-picker/dist/locale-picker.njk" import localePicker %}
|
|
32
32
|
{% from "lily-design-system-nunjucks-text-size-picker/dist/text-size-picker.njk" import textSizePicker %}
|
|
33
|
+
{% from "lily-design-system-nunjucks-time-zone-picker/dist/time-zone-picker.njk" import timeZonePicker %}
|
|
33
34
|
{% from "lily-design-system-nunjucks-share-picker/dist/share-picker.njk" import sharePicker %}
|
|
34
35
|
{#
|
|
35
|
-
All
|
|
36
|
+
All 57 Lily reference theme slugs (see `themes/` at the repo root),
|
|
36
37
|
sorted alphabetically except the United Kingdom and United States
|
|
37
38
|
government/public-sector themes, which sort last as one alphabetical
|
|
38
39
|
group of their own. Mirrors `theme-picker`'s own title-casing of each
|
|
@@ -43,13 +44,16 @@
|
|
|
43
44
|
held in sync by assertion rather than by delegation.
|
|
44
45
|
#}
|
|
45
46
|
{%- set DEFAULT_THEMES = [
|
|
46
|
-
"abyss", "acid", "adobe-spectrum", "
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
47
|
+
"abyss", "acid", "adobe-spectrum", "ant-design", "aqua",
|
|
48
|
+
"atlassian", "autumn", "black", "bumblebee", "business",
|
|
49
|
+
"cappuccino", "caramellatte", "cmyk", "coffee", "corporate",
|
|
50
|
+
"cupcake", "cyberpunk", "dark", "dim", "dracula", "emerald",
|
|
51
|
+
"excel", "fantasy", "fluent", "forest", "garden",
|
|
52
|
+
"github-primer", "halloween", "ibm-carbon", "lemonade", "light",
|
|
53
|
+
"linear", "lofi", "luxury", "mozilla-protocol", "night", "nord",
|
|
54
|
+
"notion", "pastel", "retro", "salesforce", "sap-fiori", "silk",
|
|
55
|
+
"sunset", "synthwave", "valentine", "vercel", "winter",
|
|
56
|
+
"wireframe",
|
|
53
57
|
"united-kingdom-government-digital-service",
|
|
54
58
|
"united-kingdom-national-health-service-england-for-patients",
|
|
55
59
|
"united-kingdom-national-health-service-england-for-practitioners",
|
|
@@ -70,7 +74,7 @@
|
|
|
70
74
|
{#
|
|
71
75
|
Params (single `opts` object):
|
|
72
76
|
labels — object, required: { link?, search, searchInput,
|
|
73
|
-
searchSubmit, theme, locale, textSize, share }.
|
|
77
|
+
searchSubmit, theme, locale, timeZone?, textSize, share }.
|
|
74
78
|
`link` names the link picker's button and list and is
|
|
75
79
|
needed only when `links` is supplied.
|
|
76
80
|
The seven accessible names: `search` names the
|
|
@@ -92,6 +96,11 @@
|
|
|
92
96
|
no catalog default exists.
|
|
93
97
|
themes — array<string>. Defaults to DEFAULT_THEMES (above).
|
|
94
98
|
sizes — array<string>. Defaults to DEFAULT_SIZES (above).
|
|
99
|
+
timeZoneProps — object. The time-zone picker, rendered after the locale picker only when this has `locale`
|
|
100
|
+
and `options` AND `labels.timeZone` is set. `options` is built where the page is built with
|
|
101
|
+
`timeZoneOptions({ locale, zones?, date?, labelFor?, names? })` from
|
|
102
|
+
@lilydesignsystem/nunjucks-time-zone-picker (a macro cannot call `Intl`); the rest are
|
|
103
|
+
time-zone-picker opts (date, value, defaultValue, storageKey, name, id, classes, attributes).
|
|
95
104
|
shareTargets — array<object>. Forwarded to share-picker's `targets`
|
|
96
105
|
(default []). See share-picker.njk for the object
|
|
97
106
|
shape — `href` is an already-resolved string, not a
|
|
@@ -145,6 +154,7 @@
|
|
|
145
154
|
{%- set searchProps = opts.searchProps | default({}) -%}
|
|
146
155
|
{%- set themeProps = opts.themeProps | default({}) -%}
|
|
147
156
|
{%- set localeProps = opts.localeProps | default({}) -%}
|
|
157
|
+
{%- set timeZoneProps = opts.timeZoneProps | default({}) -%}
|
|
148
158
|
{%- set textSizeProps = opts.textSizeProps | default({}) -%}
|
|
149
159
|
{%- set shareProps = opts.shareProps | default({}) -%}
|
|
150
160
|
<div
|
|
@@ -203,6 +213,21 @@
|
|
|
203
213
|
classes: localeProps.classes,
|
|
204
214
|
attributes: localeProps.attributes
|
|
205
215
|
}) }}
|
|
216
|
+
{%- if opts.labels.timeZone and timeZoneProps.locale and timeZoneProps.options %}
|
|
217
|
+
{{ timeZonePicker({
|
|
218
|
+
label: opts.labels.timeZone,
|
|
219
|
+
locale: timeZoneProps.locale,
|
|
220
|
+
options: timeZoneProps.options,
|
|
221
|
+
date: timeZoneProps.date,
|
|
222
|
+
value: timeZoneProps.value,
|
|
223
|
+
defaultValue: timeZoneProps.defaultValue,
|
|
224
|
+
storageKey: timeZoneProps.storageKey,
|
|
225
|
+
name: timeZoneProps.name,
|
|
226
|
+
id: timeZoneProps.id,
|
|
227
|
+
classes: timeZoneProps.classes,
|
|
228
|
+
attributes: timeZoneProps.attributes
|
|
229
|
+
}) }}
|
|
230
|
+
{%- endif %}
|
|
206
231
|
{{ textSizePicker({
|
|
207
232
|
label: opts.labels.textSize,
|
|
208
233
|
sizes: sizes,
|
package/index.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> **Link picker (0.3.0).** Pass `links` (and `labels.link`) to add a `link-picker` — a home icon opening the page links your app defines — as the leftmost icon. It renders only when both are given.
|
|
4
4
|
|
|
5
|
+
> **Time zone picker (0.5.0).** Pass `labels.timeZone` and `timeZoneProps: { locale, options }`, where `options = timeZoneOptions({ locale })` from `@lilydesignsystem/nunjucks-time-zone-picker` is built where the page is built (and `names` there for CLDR names) to add a `time-zone-picker` — time zones by UTC offset with their full names — right after the locale picker. It renders only when both the label and the locale are given. To name the text sizes in the reader's language pass `sizeLabels` through the text-size props (`textSizeLabels(pack)` / `LocaleTranslations.TextSizeLabels(locale)` from the locale-translations package).
|
|
6
|
+
|
|
5
7
|
A single page-header macro that composes five of the Lily
|
|
6
8
|
[`*-picker` helpers](../index.md) in this catalog — search, theme,
|
|
7
9
|
locale, text size, and share, in that order — with two catalog-wide
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lilydesignsystem/nunjucks-picker-bar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": "
|
|
5
|
+
"node": ">=26"
|
|
6
6
|
},
|
|
7
|
-
"description": "Lily Design System Nunjucks picker bar: composes link-picker (optional), search-picker, theme-picker, locale-picker, text-size-picker, and share-picker into one page-header row. Headless, SSR-safe, no CSS.",
|
|
7
|
+
"description": "Lily Design System Nunjucks picker bar: composes link-picker (optional), search-picker, theme-picker, locale-picker, time-zone-picker (optional), text-size-picker, and share-picker into one page-header row. Headless, SSR-safe, no CSS.",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.js",
|
|
@@ -22,7 +22,10 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"
|
|
25
|
+
"build": "bash build.sh",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"prepublishOnly": "npm run build"
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
31
|
"@lilydesignsystem/nunjucks-link-picker": "^0.1.0",
|
|
@@ -30,8 +33,16 @@
|
|
|
30
33
|
"@lilydesignsystem/nunjucks-theme-picker": "^0.2.0",
|
|
31
34
|
"@lilydesignsystem/nunjucks-locale-picker": "^0.2.0",
|
|
32
35
|
"@lilydesignsystem/nunjucks-text-size-picker": "^0.2.0",
|
|
36
|
+
"@lilydesignsystem/nunjucks-time-zone-picker": "^0.1.0",
|
|
33
37
|
"@lilydesignsystem/nunjucks-share-picker": "^0.2.0"
|
|
34
38
|
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"jsdom": "^30.1.1",
|
|
41
|
+
"nunjucks": "^3.2.4",
|
|
42
|
+
"tsup": "^9.0.0",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vitest": "^5.0.4"
|
|
45
|
+
},
|
|
35
46
|
"keywords": [
|
|
36
47
|
"lily",
|
|
37
48
|
"design",
|
|
@@ -49,7 +60,7 @@
|
|
|
49
60
|
"license": "MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause",
|
|
50
61
|
"repository": {
|
|
51
62
|
"type": "git",
|
|
52
|
-
"url": "git+https://github.com/LilyDesignSystem/lily-design-system
|
|
63
|
+
"url": "git+https://github.com/LilyDesignSystem/lily-design-system.git",
|
|
53
64
|
"directory": "lily-design-system-nunjucks-picker-bar"
|
|
54
65
|
},
|
|
55
66
|
"homepage": "https://lilydesignsystem.com/",
|