@atomic-ui/ui 0.1.4 → 0.1.5
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/README.md +18 -6
- package/dist/base/FieldElement.d.ts +7 -0
- package/dist/{chunk-A4CJ2F3J.js → chunk-4AJPS5AU.js} +8 -4
- package/dist/chunk-4AJPS5AU.js.map +1 -0
- package/dist/{chunk-QYHWR6C5.js → chunk-4JKUAA6K.js} +8 -4
- package/dist/chunk-4JKUAA6K.js.map +1 -0
- package/dist/{chunk-TIKX5POO.js → chunk-57P4WO4Y.js} +32 -12
- package/dist/chunk-57P4WO4Y.js.map +1 -0
- package/dist/{chunk-OBCSDZHP.js → chunk-5RVMMKMO.js} +2 -2
- package/dist/{chunk-DIZCGSJA.js → chunk-6GKI67P7.js} +14 -2
- package/dist/chunk-6GKI67P7.js.map +1 -0
- package/dist/chunk-AXQ5YBN2.js +236 -0
- package/dist/chunk-AXQ5YBN2.js.map +1 -0
- package/dist/chunk-CFGLOYWW.js +85 -0
- package/dist/chunk-CFGLOYWW.js.map +1 -0
- package/dist/{chunk-ZXCSQ6MK.js → chunk-DI2CJ3MZ.js} +9 -1
- package/dist/chunk-DI2CJ3MZ.js.map +1 -0
- package/dist/{chunk-LFOWTFMR.js → chunk-DR3SJ7ZV.js} +2 -2
- package/dist/chunk-G6UVYMA6.js +56 -0
- package/dist/chunk-G6UVYMA6.js.map +1 -0
- package/dist/{chunk-CGMDIZPO.js → chunk-H6L3FSQY.js} +2 -2
- package/dist/{chunk-4KFHQBH2.js → chunk-JPEWRJSQ.js} +16 -3
- package/dist/chunk-JPEWRJSQ.js.map +1 -0
- package/dist/{chunk-PDXOPY22.js → chunk-KWURASAB.js} +2 -2
- package/dist/chunk-LLRJU7XE.js +195 -0
- package/dist/chunk-LLRJU7XE.js.map +1 -0
- package/dist/{chunk-4Y3HJBJY.js → chunk-OFAVRPRK.js} +2 -1
- package/dist/chunk-OFAVRPRK.js.map +1 -0
- package/dist/{chunk-GGODB3GY.js → chunk-QELX47AP.js} +70 -8
- package/dist/chunk-QELX47AP.js.map +1 -0
- package/dist/chunk-QH46SOPJ.js +134 -0
- package/dist/chunk-QH46SOPJ.js.map +1 -0
- package/dist/chunk-U2S7OESF.js +135 -0
- package/dist/chunk-U2S7OESF.js.map +1 -0
- package/dist/{chunk-MAMBT7BZ.js → chunk-ZDYTNFQI.js} +8 -4
- package/dist/chunk-ZDYTNFQI.js.map +1 -0
- package/dist/components/blocks.d.ts +174 -0
- package/dist/components/blocks.js +17 -0
- package/dist/components/blocks.js.map +1 -0
- package/dist/components/button.d.ts +26 -0
- package/dist/components/button.js +2 -1
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.js +2 -2
- package/dist/components/date-input.js +2 -2
- package/dist/components/fieldset.d.ts +49 -0
- package/dist/components/fieldset.js +8 -0
- package/dist/components/fieldset.js.map +1 -0
- package/dist/components/grid.d.ts +1 -1
- package/dist/components/grid.js +1 -1
- package/dist/components/icon.d.ts +89 -0
- package/dist/components/icon.js +14 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/layout.d.ts +65 -2
- package/dist/components/layout.js +1 -1
- package/dist/components/link.d.ts +11 -0
- package/dist/components/link.js +2 -1
- package/dist/components/marketing.d.ts +257 -0
- package/dist/components/marketing.js +17 -0
- package/dist/components/marketing.js.map +1 -0
- package/dist/components/media.d.ts +12 -0
- package/dist/components/media.js +1 -1
- package/dist/components/navigation.d.ts +91 -0
- package/dist/components/navigation.js +11 -0
- package/dist/components/navigation.js.map +1 -0
- package/dist/components/page.d.ts +119 -0
- package/dist/components/page.js +10 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/radio-group.js +2 -2
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +2 -2
- package/dist/components/text-input.d.ts +6 -0
- package/dist/components/text-input.js +2 -2
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.js +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +82 -32
- package/package.json +2 -2
- package/dist/chunk-4KFHQBH2.js.map +0 -1
- package/dist/chunk-4Y3HJBJY.js.map +0 -1
- package/dist/chunk-A4CJ2F3J.js.map +0 -1
- package/dist/chunk-DIZCGSJA.js.map +0 -1
- package/dist/chunk-GGODB3GY.js.map +0 -1
- package/dist/chunk-MAMBT7BZ.js.map +0 -1
- package/dist/chunk-QYHWR6C5.js.map +0 -1
- package/dist/chunk-TIKX5POO.js.map +0 -1
- package/dist/chunk-ZXCSQ6MK.js.map +0 -1
- /package/dist/{chunk-OBCSDZHP.js.map → chunk-5RVMMKMO.js.map} +0 -0
- /package/dist/{chunk-LFOWTFMR.js.map → chunk-DR3SJ7ZV.js.map} +0 -0
- /package/dist/{chunk-CGMDIZPO.js.map → chunk-H6L3FSQY.js.map} +0 -0
- /package/dist/{chunk-PDXOPY22.js.map → chunk-KWURASAB.js.map} +0 -0
|
@@ -44,6 +44,7 @@ var ImpktGrid = class extends ImpktElement {
|
|
|
44
44
|
:host([gap='none']) .columns { gap: 0; }
|
|
45
45
|
:host([gap='sm']) .columns { gap: ${token("layout.gutter.sm", "8px")}; }
|
|
46
46
|
:host([gap='lg']) .columns { gap: ${token("layout.gutter.lg", "32px")}; }
|
|
47
|
+
:host([gap='xl']) .columns { gap: ${token("layout.gutter.xl", "48px")}; }
|
|
47
48
|
:host([align='start']) .columns { align-items: start; }
|
|
48
49
|
:host([align='center']) .columns { align-items: center; }
|
|
49
50
|
:host([align='end']) .columns { align-items: end; }
|
|
@@ -70,4 +71,4 @@ customElements.define("impkt-grid", ImpktGrid);
|
|
|
70
71
|
export {
|
|
71
72
|
ImpktGrid
|
|
72
73
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-OFAVRPRK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/grid.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { spaceAround, token } from '../base/tokens';\n\n/** Column widths as fractions, for each choice of `widths`. */\nconst WIDTHS: Record<string, string> = {\n '2:1': '2fr 1fr', '1:2': '1fr 2fr', '3:1': '3fr 1fr', '1:3': '1fr 3fr',\n '1:2:1': '1fr 2fr 1fr', '2:1:1': '2fr 1fr 1fr', '1:1:2': '1fr 1fr 2fr',\n};\n\n/**\n * A responsive row with named column slots. Child order stays inside each\n * column; changing a page's visual grid never reorders its reading sequence.\n *\n * Gutters come from the brand's layout, so every grid for a partner keeps the\n * same rhythm. Where the columns stack is a choice, because a three-column\n * row of cards may work on a tablet where two columns of long text do not.\n *\n * @category layout\n * @icon columns\n * @slot column-1 - First column.\n * @slot column-2 - Second column.\n * @slot column-3 - Third column.\n * @slot column-4 - Fourth column.\n */\nexport class ImpktGrid extends ImpktElement {\n static properties = {\n columns: { type: String, reflect: true },\n widths: { type: String, reflect: true },\n gap: { type: String, reflect: true },\n stackOn: { type: String, reflect: true, attribute: 'stack-on' },\n align: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare columns: 'one' | 'two' | 'three' | 'four' | 'sidebar-left' | 'sidebar-right';\n /** How wide each column is against the others. Applies when it has as many parts as there are columns. */\n declare widths: 'equal' | '2:1' | '1:2' | '3:1' | '1:3' | '1:2:1' | '2:1:1' | '1:1:2';\n /** The space between columns, from the brand's gutters. */\n declare gap: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n /** The screens on which the columns stack, one above another, in column order. */\n declare stackOn: 'phone' | 'tablet' | 'never';\n /** How columns of different heights line up. */\n declare align: 'stretch' | 'start' | 'center' | 'end';\n /** Space before the grid, from the spacing scale. */\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n /** Space after the grid, from the spacing scale. */\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n constructor() {\n super();\n this.columns = 'two';\n this.widths = 'equal';\n this.gap = 'md';\n this.stackOn = 'phone';\n this.align = 'stretch';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n static styles = [...ImpktElement.styles, spaceAround, css`\n :host { display: block; min-inline-size: 0; container-type: inline-size; }\n .columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${token('layout.gutter.md', '16px')}; align-items: stretch; }\n :host([gap='none']) .columns { gap: 0; }\n :host([gap='sm']) .columns { gap: ${token('layout.gutter.sm', '8px')}; }\n :host([gap='lg']) .columns { gap: ${token('layout.gutter.lg', '32px')}; }\n :host([gap='xl']) .columns { gap: ${token('layout.gutter.xl', '48px')}; }\n :host([align='start']) .columns { align-items: start; }\n :host([align='center']) .columns { align-items: center; }\n :host([align='end']) .columns { align-items: end; }\n :host([columns='one']) .columns { grid-template-columns: minmax(0, 1fr); }\n :host([columns='three']) .columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n :host([columns='four']) .columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }\n :host([columns='sidebar-left']) .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }\n :host([columns='sidebar-right']) .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }\n .column { min-inline-size: 0; overflow-wrap: anywhere; }\n ::slotted(*) { max-inline-size: 100%; }\n @container (max-width: 40rem) { :host(:not([stack-on='never'])) .columns { grid-template-columns: minmax(0, 1fr) !important; } }\n @container (max-width: 64rem) { :host([stack-on='tablet']) .columns { grid-template-columns: minmax(0, 1fr) !important; } }\n `];\n render() {\n const count = this.columns === 'one' ? 1 : this.columns === 'three' ? 3 : this.columns === 'four' ? 4 : 2;\n const fractions = WIDTHS[this.widths]?.split(' ');\n // A width split for a different number of columns would leave a column out, so it is ignored.\n const template = fractions && fractions.length === count ? fractions.map((f) => `minmax(0, ${f})`).join(' ') : '';\n return html`<div class=\"columns\" part=\"row\" style=${template ? `grid-template-columns: ${template}` : ''}>${Array.from({ length: count }, (_, i) => html`<div class=\"column\" part=\"column\"><slot name=${`column-${i + 1}`}></slot></div>`)}</div>`;\n }\n}\ncustomElements.define('impkt-grid', ImpktGrid);\ndeclare global { interface HTMLElementTagNameMap { 'impkt-grid': ImpktGrid } }\n"],"mappings":";;;;;;;AAAA,SAAS,KAAK,YAAY;AAK1B,IAAM,SAAiC;AAAA,EACrC,OAAO;AAAA,EAAW,OAAO;AAAA,EAAW,OAAO;AAAA,EAAW,OAAO;AAAA,EAC7D,SAAS;AAAA,EAAe,SAAS;AAAA,EAAe,SAAS;AAC3D;AAiBO,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,aAAa;AAAA,MAClB,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACvC,QAAQ,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACtC,KAAK,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACnC,SAAS,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,WAAW;AAAA,MAC9D,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,MACpE,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,IACtE;AAAA;AAAA,EAcA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AACf,SAAK,SAAS;AACd,SAAK,MAAM;AACX,SAAK,UAAU;AACf,SAAK,QAAQ;AACb,SAAK,aAAa;AAClB,SAAK,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,SAAO,SAAS,CAAC,GAAG,aAAa,QAAQ,aAAa;AAAA;AAAA,uFAE+B,MAAM,oBAAoB,MAAM,CAAC;AAAA;AAAA,wCAEhF,MAAM,oBAAoB,KAAK,CAAC;AAAA,wCAChC,MAAM,oBAAoB,MAAM,CAAC;AAAA,wCACjC,MAAM,oBAAoB,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAatE;AAAA;AAAA,EACD,SAAS;AACP,UAAM,QAAQ,KAAK,YAAY,QAAQ,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,SAAS,IAAI;AACxG,UAAM,YAAY,OAAO,KAAK,MAAM,GAAG,MAAM,GAAG;AAEhD,UAAM,WAAW,aAAa,UAAU,WAAW,QAAQ,UAAU,IAAI,CAAC,MAAM,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI;AAC/G,WAAO,6CAA6C,WAAW,0BAA0B,QAAQ,KAAK,EAAE,IAAI,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,oDAAoD,UAAU,IAAI,CAAC,EAAE,gBAAgB,CAAC;AAAA,EAC5O;AACF;AACA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
} from "./chunk-5NUF7ZQA.js";
|
|
10
10
|
|
|
11
11
|
// packages/ui/src/components/layout.ts
|
|
12
|
-
import { html, css } from "lit";
|
|
12
|
+
import { html, css, nothing } from "lit";
|
|
13
13
|
var ImpktStack = class extends ImpktElement {
|
|
14
14
|
static {
|
|
15
15
|
this.properties = {
|
|
16
16
|
gap: { type: String, reflect: true },
|
|
17
|
+
align: { type: String, reflect: true },
|
|
18
|
+
direction: { type: String, reflect: true },
|
|
19
|
+
justify: { type: String, reflect: true },
|
|
17
20
|
spaceAbove: { type: String, reflect: true, attribute: "space-above" },
|
|
18
21
|
spaceBelow: { type: String, reflect: true, attribute: "space-below" }
|
|
19
22
|
};
|
|
@@ -21,6 +24,9 @@ var ImpktStack = class extends ImpktElement {
|
|
|
21
24
|
constructor() {
|
|
22
25
|
super();
|
|
23
26
|
this.gap = "md";
|
|
27
|
+
this.align = "stretch";
|
|
28
|
+
this.direction = "vertical";
|
|
29
|
+
this.justify = "start";
|
|
24
30
|
this.spaceAbove = "none";
|
|
25
31
|
this.spaceBelow = "none";
|
|
26
32
|
}
|
|
@@ -33,7 +39,18 @@ var ImpktStack = class extends ImpktElement {
|
|
|
33
39
|
display: flex;
|
|
34
40
|
flex-direction: column;
|
|
35
41
|
}
|
|
42
|
+
:host([gap='none']) { gap: 0; }
|
|
36
43
|
:host([gap='xs']) { gap: ${space(1)}; }
|
|
44
|
+
:host([align='start']) { align-items: flex-start; }
|
|
45
|
+
:host([align='center']) { align-items: center; text-align: center; }
|
|
46
|
+
:host([align='end']) { align-items: flex-end; }
|
|
47
|
+
:host([direction='horizontal']) { flex-direction: row; flex-wrap: wrap; align-items: center; }
|
|
48
|
+
:host([direction='horizontal'][align='start']) { align-items: flex-start; }
|
|
49
|
+
:host([direction='horizontal'][align='end']) { align-items: flex-end; }
|
|
50
|
+
:host([direction='horizontal'][align='center']) { text-align: start; }
|
|
51
|
+
:host([justify='center']) { justify-content: center; }
|
|
52
|
+
:host([justify='end']) { justify-content: flex-end; }
|
|
53
|
+
:host([justify='between']) { justify-content: space-between; }
|
|
37
54
|
:host([gap='sm']) { gap: ${space(2)}; }
|
|
38
55
|
:host([gap='md']) { gap: ${space(4)}; }
|
|
39
56
|
:host([gap='lg']) { gap: ${space(6)}; }
|
|
@@ -48,12 +65,22 @@ var ImpktStack = class extends ImpktElement {
|
|
|
48
65
|
var ImpktCard = class extends ImpktElement {
|
|
49
66
|
static {
|
|
50
67
|
this.properties = {
|
|
68
|
+
tone: { type: String, reflect: true },
|
|
69
|
+
padding: { type: String, reflect: true },
|
|
70
|
+
imageSrc: { type: String, attribute: "image-src" },
|
|
71
|
+
imageAlt: { type: String, attribute: "image-alt" },
|
|
72
|
+
ratio: { type: String, reflect: true },
|
|
51
73
|
spaceAbove: { type: String, reflect: true, attribute: "space-above" },
|
|
52
74
|
spaceBelow: { type: String, reflect: true, attribute: "space-below" }
|
|
53
75
|
};
|
|
54
76
|
}
|
|
55
77
|
constructor() {
|
|
56
78
|
super();
|
|
79
|
+
this.tone = "default";
|
|
80
|
+
this.padding = "lg";
|
|
81
|
+
this.imageSrc = "";
|
|
82
|
+
this.imageAlt = "";
|
|
83
|
+
this.ratio = "16:9";
|
|
57
84
|
this.spaceAbove = "none";
|
|
58
85
|
this.spaceBelow = "none";
|
|
59
86
|
}
|
|
@@ -63,30 +90,50 @@ var ImpktCard = class extends ImpktElement {
|
|
|
63
90
|
spaceAround,
|
|
64
91
|
css`
|
|
65
92
|
:host {
|
|
66
|
-
display:
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
67
95
|
background: ${t.surfaceCard};
|
|
68
96
|
border: ${t.borderThin} solid ${t.border};
|
|
69
97
|
border-radius: ${t.radiusLg};
|
|
70
|
-
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
--ratio: 16 / 9;
|
|
71
100
|
}
|
|
101
|
+
:host([tone='subtle']) { background: ${t.surfaceSubtle}; border-color: transparent; }
|
|
102
|
+
:host([tone='brand']) { background: ${t.brand}; border-color: transparent; color: ${t.onBrand}; --impkt-color-text-heading: ${t.onBrand}; --impkt-color-text-default: ${t.onBrand}; --impkt-color-text-muted: ${t.onBrand}; --impkt-color-text-link: ${t.onBrand}; }
|
|
103
|
+
:host([tone='outline']) { background: transparent; }
|
|
104
|
+
:host([tone='plain']) { background: transparent; border-color: transparent; border-radius: 0; }
|
|
105
|
+
:host([ratio='4:3']) { --ratio: 4 / 3; }
|
|
106
|
+
:host([ratio='3:2']) { --ratio: 3 / 2; }
|
|
107
|
+
:host([ratio='1:1']) { --ratio: 1 / 1; }
|
|
108
|
+
.body { padding: ${space(6)}; flex: 1; display: flex; flex-direction: column; }
|
|
109
|
+
:host([padding='none']) .body { padding: 0; }
|
|
110
|
+
:host([padding='sm']) .body { padding: ${space(3)}; }
|
|
111
|
+
:host([padding='md']) .body { padding: ${space(4)}; }
|
|
112
|
+
:host([tone='plain']) .body { padding-inline: 0; }
|
|
113
|
+
img { display: block; inline-size: 100%; aspect-ratio: var(--ratio); object-fit: cover; }
|
|
114
|
+
@media (forced-colors: active) { :host { border-color: CanvasText; } }
|
|
72
115
|
`
|
|
73
116
|
];
|
|
74
117
|
}
|
|
75
118
|
render() {
|
|
76
|
-
return html`<slot></slot>`;
|
|
119
|
+
return html`${this.imageSrc ? html`<img src=${this.imageSrc} alt=${this.imageAlt} part="image" />` : nothing}<div class="body" part="body"><slot></slot></div>`;
|
|
77
120
|
}
|
|
78
121
|
};
|
|
79
122
|
var ImpktHeading = class extends ImpktElement {
|
|
80
123
|
static {
|
|
81
124
|
this.properties = {
|
|
82
125
|
level: { type: Number, reflect: true },
|
|
83
|
-
size: { type: String, reflect: true }
|
|
126
|
+
size: { type: String, reflect: true },
|
|
127
|
+
eyebrow: { type: String },
|
|
128
|
+
align: { type: String, reflect: true }
|
|
84
129
|
};
|
|
85
130
|
}
|
|
86
131
|
constructor() {
|
|
87
132
|
super();
|
|
88
133
|
this.level = 2;
|
|
89
134
|
this.size = "xl";
|
|
135
|
+
this.eyebrow = "";
|
|
136
|
+
this.align = "start";
|
|
90
137
|
}
|
|
91
138
|
static {
|
|
92
139
|
this.styles = [
|
|
@@ -109,12 +156,23 @@ var ImpktHeading = class extends ImpktElement {
|
|
|
109
156
|
font: inherit;
|
|
110
157
|
color: inherit;
|
|
111
158
|
}
|
|
159
|
+
:host([align='center']) { text-align: center; }
|
|
160
|
+
.eyebrow {
|
|
161
|
+
display: block;
|
|
162
|
+
margin-block-end: ${space(2)};
|
|
163
|
+
color: ${t.brand};
|
|
164
|
+
font-family: ${t.fontBody};
|
|
165
|
+
font-size: ${fontSize("sm")};
|
|
166
|
+
font-weight: ${fontWeight("semibold")};
|
|
167
|
+
letter-spacing: 0.06em;
|
|
168
|
+
text-transform: uppercase;
|
|
169
|
+
}
|
|
112
170
|
`
|
|
113
171
|
];
|
|
114
172
|
}
|
|
115
173
|
render() {
|
|
116
174
|
return html`<div class="h" role="heading" aria-level=${this.level} part="heading">
|
|
117
|
-
<slot></slot>
|
|
175
|
+
${this.eyebrow ? html`<span class="eyebrow" part="eyebrow">${this.eyebrow}<span style="position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%)">: </span></span>` : nothing}<slot></slot>
|
|
118
176
|
</div>`;
|
|
119
177
|
}
|
|
120
178
|
};
|
|
@@ -122,13 +180,15 @@ var ImpktText = class extends ImpktElement {
|
|
|
122
180
|
static {
|
|
123
181
|
this.properties = {
|
|
124
182
|
size: { type: String, reflect: true },
|
|
125
|
-
tone: { type: String, reflect: true }
|
|
183
|
+
tone: { type: String, reflect: true },
|
|
184
|
+
align: { type: String, reflect: true }
|
|
126
185
|
};
|
|
127
186
|
}
|
|
128
187
|
constructor() {
|
|
129
188
|
super();
|
|
130
189
|
this.size = "md";
|
|
131
190
|
this.tone = "default";
|
|
191
|
+
this.align = "start";
|
|
132
192
|
}
|
|
133
193
|
static {
|
|
134
194
|
this.styles = [
|
|
@@ -147,7 +207,9 @@ var ImpktText = class extends ImpktElement {
|
|
|
147
207
|
:host([size='sm']) { font-size: ${fontSize("sm")}; }
|
|
148
208
|
:host([size='md']) { font-size: ${fontSize("md")}; }
|
|
149
209
|
:host([size='lg']) { font-size: ${fontSize("lg")}; }
|
|
210
|
+
:host([size='xl']) { font-size: ${fontSize("xl")}; }
|
|
150
211
|
:host([tone='muted']) { color: ${t.textMuted}; }
|
|
212
|
+
:host([align='center']) { text-align: center; margin-inline: auto; }
|
|
151
213
|
p {
|
|
152
214
|
margin: 0;
|
|
153
215
|
}
|
|
@@ -169,4 +231,4 @@ export {
|
|
|
169
231
|
ImpktHeading,
|
|
170
232
|
ImpktText
|
|
171
233
|
};
|
|
172
|
-
//# sourceMappingURL=chunk-
|
|
234
|
+
//# sourceMappingURL=chunk-QELX47AP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/layout.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { fontSize, fontWeight, lineHeight, space, spaceAround, t } from '../base/tokens';\n\n/**\n * Layout and typography primitives.\n *\n * These are the components a composition is mostly made of, and they are\n * deliberately dull. Their one job is that spacing, type and colour come from\n * tokens, so that a page built in the CMS cannot contain a hard-coded 13px.\n */\n\n/** Vertical rhythm. Every gap is a spacing token, never a number.\n *\n * @category layout\n * @icon stack\n * @slot - The things being stacked.\n */\nexport class ImpktStack extends ImpktElement {\n static properties = {\n gap: { type: String, reflect: true },\n align: { type: String, reflect: true },\n direction: { type: String, reflect: true },\n justify: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare gap: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** How the items line up across the stack. */\n declare align: 'stretch' | 'start' | 'center' | 'end';\n /** Down the page, or along a row that wraps when it runs out of room, such as a row of buttons. */\n declare direction: 'vertical' | 'horizontal';\n /** Where the items sit along a row. */\n declare justify: 'start' | 'center' | 'end' | 'between';\n /** Space before the stack, from the spacing scale. */\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n /** Space after the stack, from the spacing scale. */\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n\n constructor() {\n super();\n this.gap = 'md';\n this.align = 'stretch';\n this.direction = 'vertical';\n this.justify = 'start';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpktElement.styles,\n spaceAround,\n css`\n :host {\n display: flex;\n flex-direction: column;\n }\n :host([gap='none']) { gap: 0; }\n :host([gap='xs']) { gap: ${space(1)}; }\n :host([align='start']) { align-items: flex-start; }\n :host([align='center']) { align-items: center; text-align: center; }\n :host([align='end']) { align-items: flex-end; }\n :host([direction='horizontal']) { flex-direction: row; flex-wrap: wrap; align-items: center; }\n :host([direction='horizontal'][align='start']) { align-items: flex-start; }\n :host([direction='horizontal'][align='end']) { align-items: flex-end; }\n :host([direction='horizontal'][align='center']) { text-align: start; }\n :host([justify='center']) { justify-content: center; }\n :host([justify='end']) { justify-content: flex-end; }\n :host([justify='between']) { justify-content: space-between; }\n :host([gap='sm']) { gap: ${space(2)}; }\n :host([gap='md']) { gap: ${space(4)}; }\n :host([gap='lg']) { gap: ${space(6)}; }\n :host([gap='xl']) { gap: ${space(8)}; }\n `,\n ];\n\n render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\n/** A surface. What text is read against, and what contrast is measured from.\n *\n * @category layout\n * @icon card\n * @slot - What sits on the card.\n */\nexport class ImpktCard extends ImpktElement {\n static properties = {\n tone: { type: String, reflect: true },\n padding: { type: String, reflect: true },\n imageSrc: { type: String, attribute: 'image-src' },\n imageAlt: { type: String, attribute: 'image-alt' },\n ratio: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n /** The card's surface. Text on a brand card takes the brand's text colour. */\n declare tone: 'default' | 'subtle' | 'brand' | 'outline' | 'plain';\n /** Space inside the card. */\n declare padding: 'none' | 'sm' | 'md' | 'lg';\n /** A picture across the top of the card. */\n declare imageSrc: string;\n /** What the picture shows. Leave empty only when it is decoration. */\n declare imageAlt: string;\n /** The picture's shape. */\n declare ratio: '16:9' | '4:3' | '3:2' | '1:1';\n /** Space before the card, from the spacing scale. */\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n /** Space after the card, from the spacing scale. */\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n\n constructor() {\n super();\n this.tone = 'default';\n this.padding = 'lg';\n this.imageSrc = '';\n this.imageAlt = '';\n this.ratio = '16:9';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpktElement.styles,\n spaceAround,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n overflow: hidden;\n --ratio: 16 / 9;\n }\n :host([tone='subtle']) { background: ${t.surfaceSubtle}; border-color: transparent; }\n :host([tone='brand']) { background: ${t.brand}; border-color: transparent; color: ${t.onBrand}; --impkt-color-text-heading: ${t.onBrand}; --impkt-color-text-default: ${t.onBrand}; --impkt-color-text-muted: ${t.onBrand}; --impkt-color-text-link: ${t.onBrand}; }\n :host([tone='outline']) { background: transparent; }\n :host([tone='plain']) { background: transparent; border-color: transparent; border-radius: 0; }\n :host([ratio='4:3']) { --ratio: 4 / 3; }\n :host([ratio='3:2']) { --ratio: 3 / 2; }\n :host([ratio='1:1']) { --ratio: 1 / 1; }\n .body { padding: ${space(6)}; flex: 1; display: flex; flex-direction: column; }\n :host([padding='none']) .body { padding: 0; }\n :host([padding='sm']) .body { padding: ${space(3)}; }\n :host([padding='md']) .body { padding: ${space(4)}; }\n :host([tone='plain']) .body { padding-inline: 0; }\n img { display: block; inline-size: 100%; aspect-ratio: var(--ratio); object-fit: cover; }\n @media (forced-colors: active) { :host { border-color: CanvasText; } }\n `,\n ];\n\n render(): TemplateResult {\n return html`${this.imageSrc ? html`<img src=${this.imageSrc} alt=${this.imageAlt} part=\"image\" />` : nothing}<div class=\"body\" part=\"body\"><slot></slot></div>`;\n }\n}\n\n/**\n * A heading.\n *\n * `level` is required and renders the matching `<h1>`–`<h6>`, because heading\n * level is document structure rather than appearance: a screen-reader user\n * navigates by it, and a page whose levels skip is a page they cannot skim.\n * Size is a separate property, so a visually small `<h2>` needs no lie about\n * its level — which is the usual reason levels end up wrong.\n\n *\n * @category typography\n * @icon heading\n * @role heading\n * @slot - The heading text.\n */\nexport class ImpktHeading extends ImpktElement {\n static properties = {\n level: { type: Number, reflect: true },\n size: { type: String, reflect: true },\n eyebrow: { type: String },\n align: { type: String, reflect: true },\n };\n\n declare level: 1 | 2 | 3 | 4 | 5 | 6;\n declare size: '3xl' | '2xl' | 'xl' | 'lg' | 'md';\n /** A short label above the heading, such as \"Why Larkfield\". Part of the heading, read before it. */\n declare eyebrow: string;\n declare align: 'start' | 'center';\n\n constructor() {\n super();\n this.level = 2;\n this.size = 'xl';\n this.eyebrow = '';\n this.align = 'start';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n color: ${t.textHeading};\n font-family: ${t.fontHeading};\n font-weight: ${fontWeight('bold')};\n line-height: ${lineHeight('tight')};\n }\n :host([size='3xl']) { font-size: ${fontSize('3xl')}; }\n :host([size='2xl']) { font-size: ${fontSize('2xl')}; }\n :host([size='xl']) { font-size: ${fontSize('xl')}; }\n :host([size='lg']) { font-size: ${fontSize('lg')}; }\n :host([size='md']) { font-size: ${fontSize('md')}; }\n .h {\n margin: 0;\n font: inherit;\n color: inherit;\n }\n :host([align='center']) { text-align: center; }\n .eyebrow {\n display: block;\n margin-block-end: ${space(2)};\n color: ${t.brand};\n font-family: ${t.fontBody};\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('semibold')};\n letter-spacing: 0.06em;\n text-transform: uppercase;\n }\n `,\n ];\n\n render(): TemplateResult {\n // A `role=\"heading\"` with `aria-level` rather than six branches of\n // template. The native element would be marginally better; this is the one\n // place where Lit's lack of a dynamic tag makes the explicit role the\n // honest trade, and the role is fully supported.\n return html`<div class=\"h\" role=\"heading\" aria-level=${this.level} part=\"heading\">\n ${this.eyebrow ? html`<span class=\"eyebrow\" part=\"eyebrow\">${this.eyebrow}<span style=\"position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%)\">: </span></span>` : nothing}<slot></slot>\n </div>`;\n }\n}\n\n/** A paragraph.\n *\n * @category typography\n * @icon text\n * @slot - The paragraph text.\n */\nexport class ImpktText extends ImpktElement {\n static properties = {\n size: { type: String, reflect: true },\n tone: { type: String, reflect: true },\n align: { type: String, reflect: true },\n };\n\n declare size: 'sm' | 'md' | 'lg' | 'xl';\n declare tone: 'default' | 'muted';\n declare align: 'start' | 'center';\n\n constructor() {\n super();\n this.size = 'md';\n this.tone = 'default';\n this.align = 'start';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n /* 1.4.8 asks for 1.5 within a paragraph, and it is the default here\n rather than an option, because body text is what it is about. */\n line-height: ${lineHeight('normal')};\n /* 1.4.12 Text Spacing: a user stylesheet must be able to widen this\n without clipping, which a max-width in ch units survives and a\n fixed pixel height does not. */\n max-inline-size: 70ch;\n }\n :host([size='sm']) { font-size: ${fontSize('sm')}; }\n :host([size='md']) { font-size: ${fontSize('md')}; }\n :host([size='lg']) { font-size: ${fontSize('lg')}; }\n :host([size='xl']) { font-size: ${fontSize('xl')}; }\n :host([tone='muted']) { color: ${t.textMuted}; }\n :host([align='center']) { text-align: center; margin-inline: auto; }\n p {\n margin: 0;\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`<p part=\"text\"><slot></slot></p>`;\n }\n}\n\ncustomElements.define('impkt-stack', ImpktStack);\ncustomElements.define('impkt-card', ImpktCard);\ncustomElements.define('impkt-heading', ImpktHeading);\ncustomElements.define('impkt-text', ImpktText);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-stack': ImpktStack;\n 'impkt-card': ImpktCard;\n 'impkt-heading': ImpktHeading;\n 'impkt-text': ImpktText;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAkBjD,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C;AAAA,SAAO,aAAa;AAAA,MAClB,KAAK,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACnC,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,WAAW,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACzC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACvC,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,MACpE,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,IACtE;AAAA;AAAA,EAaA,cAAc;AACZ,UAAM;AACN,SAAK,MAAM;AACX,SAAK,Q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names":[]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ImpktElement,
|
|
3
|
+
focusRing,
|
|
4
|
+
space,
|
|
5
|
+
spaceAround,
|
|
6
|
+
t,
|
|
7
|
+
token
|
|
8
|
+
} from "./chunk-5NUF7ZQA.js";
|
|
9
|
+
|
|
10
|
+
// packages/ui/src/components/page.ts
|
|
11
|
+
import { css, html, nothing } from "lit";
|
|
12
|
+
var widths = css`
|
|
13
|
+
:host { --impkt-page-inner: ${token("layout.page-width", "1200px")}; }
|
|
14
|
+
:host([width='narrow']) { --impkt-page-inner: 760px; }
|
|
15
|
+
:host([width='wide']) { --impkt-page-inner: 1440px; }
|
|
16
|
+
`;
|
|
17
|
+
var margins = css`
|
|
18
|
+
:host { --impkt-page-margin: ${token("layout.margin.phone", "16px")}; }
|
|
19
|
+
@container impkt-page (min-width: 40rem) { .frame { --impkt-page-margin: ${token("layout.margin.tablet", "32px")}; } }
|
|
20
|
+
@container impkt-page (min-width: 64rem) { .frame { --impkt-page-margin: ${token("layout.margin.desktop", "64px")}; } }
|
|
21
|
+
`;
|
|
22
|
+
var ImpktPage = class extends ImpktElement {
|
|
23
|
+
static {
|
|
24
|
+
this.properties = {
|
|
25
|
+
width: { type: String, reflect: true },
|
|
26
|
+
stickyHeader: { type: Boolean, reflect: true, attribute: "sticky-header" },
|
|
27
|
+
skipText: { type: String, attribute: "skip-text" }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.width = "standard";
|
|
33
|
+
this.stickyHeader = false;
|
|
34
|
+
this.skipText = "Skip to content";
|
|
35
|
+
}
|
|
36
|
+
static {
|
|
37
|
+
this.styles = [...ImpktElement.styles, focusRing, widths, margins, css`
|
|
38
|
+
:host { display: block; container: impkt-page / inline-size; }
|
|
39
|
+
.frame { display: flex; flex-direction: column; min-block-size: 100%; overflow-x: clip; }
|
|
40
|
+
.inner { box-sizing: border-box; inline-size: 100%; max-inline-size: calc(var(--impkt-page-inner) + 2 * var(--impkt-page-margin)); margin-inline: auto; padding-inline: var(--impkt-page-margin); }
|
|
41
|
+
header { background: ${token("color.surface.header", "transparent")}; color: ${token("color.text.on-header", "inherit")}; padding-block: ${space(4)}; }
|
|
42
|
+
/* What sits in the header and footer takes their text colour, so words on a dark footer stay readable. */
|
|
43
|
+
header { --impkt-color-text-default: ${token("color.text.on-header", "inherit")}; --impkt-color-text-heading: ${token("color.text.on-header", "inherit")}; }
|
|
44
|
+
footer { --impkt-color-text-default: ${token("color.text.on-footer", "inherit")}; --impkt-color-text-heading: ${token("color.text.on-footer", "inherit")}; --impkt-color-text-muted: ${token("color.text.on-footer", "inherit")}; --impkt-color-text-link: ${token("color.text.on-footer", "inherit")}; --impkt-color-text-link-hover: ${token("color.text.on-footer", "inherit")}; }
|
|
45
|
+
:host([sticky-header]) header { position: sticky; inset-block-start: 0; z-index: 10; }
|
|
46
|
+
main { flex: 1; padding-block: ${space(6)} ${space(10)}; }
|
|
47
|
+
main:focus { outline: none; }
|
|
48
|
+
footer { background: ${token("color.surface.footer", "transparent")}; color: ${token("color.text.on-footer", "inherit")}; padding-block: ${space(8)}; border-block-start: ${t.borderThin} solid ${token("color.border.subtle", "transparent")}; }
|
|
49
|
+
.skip { position: absolute; inset-inline-start: ${space(2)}; inset-block-start: ${space(2)}; z-index: 20; padding: ${space(2)} ${space(4)}; background: ${t.surfaceCard}; color: ${t.link}; border-radius: ${t.radius}; transform: translateY(-200%); }
|
|
50
|
+
.skip:focus { transform: none; }
|
|
51
|
+
.empty { display: none; }
|
|
52
|
+
`];
|
|
53
|
+
}
|
|
54
|
+
hasSlot(name) {
|
|
55
|
+
return Array.from(this.children).some((c) => c.getAttribute("slot") === name);
|
|
56
|
+
}
|
|
57
|
+
skip(event) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
const main = this.renderRoot.querySelector("main");
|
|
60
|
+
main?.focus();
|
|
61
|
+
main?.scrollIntoView();
|
|
62
|
+
}
|
|
63
|
+
render() {
|
|
64
|
+
const header = this.hasSlot("header");
|
|
65
|
+
const footer = this.hasSlot("footer");
|
|
66
|
+
return html`<div class="frame" part="frame">
|
|
67
|
+
<a class="skip" href="#content" part="skip" @click=${this.skip}>${this.skipText}</a>
|
|
68
|
+
${header ? html`<header part="header"><div class="inner"><slot name="header"></slot></div></header>` : nothing}
|
|
69
|
+
<main id="content" tabindex="-1" part="main"><div class="inner"><slot></slot></div></main>
|
|
70
|
+
${footer ? html`<footer part="footer"><div class="inner"><slot name="footer"></slot></div></footer>` : nothing}
|
|
71
|
+
</div>`;
|
|
72
|
+
}
|
|
73
|
+
// A header or footer added after the first render still gets its landmark.
|
|
74
|
+
connectedCallback() {
|
|
75
|
+
super.connectedCallback();
|
|
76
|
+
this.observer = new MutationObserver(() => this.requestUpdate());
|
|
77
|
+
this.observer.observe(this, { childList: true, attributes: true, subtree: false, attributeFilter: ["slot"] });
|
|
78
|
+
}
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
super.disconnectedCallback();
|
|
81
|
+
this.observer?.disconnect();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var ImpktSection = class extends ImpktElement {
|
|
85
|
+
static {
|
|
86
|
+
this.properties = {
|
|
87
|
+
tone: { type: String, reflect: true },
|
|
88
|
+
padding: { type: String, reflect: true },
|
|
89
|
+
width: { type: String, reflect: true },
|
|
90
|
+
bleed: { type: Boolean, reflect: true },
|
|
91
|
+
label: { type: String },
|
|
92
|
+
spaceAbove: { type: String, reflect: true, attribute: "space-above" },
|
|
93
|
+
spaceBelow: { type: String, reflect: true, attribute: "space-below" }
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
constructor() {
|
|
97
|
+
super();
|
|
98
|
+
this.tone = "none";
|
|
99
|
+
this.padding = "lg";
|
|
100
|
+
this.width = "standard";
|
|
101
|
+
this.bleed = true;
|
|
102
|
+
this.label = "";
|
|
103
|
+
this.spaceAbove = "none";
|
|
104
|
+
this.spaceBelow = "none";
|
|
105
|
+
}
|
|
106
|
+
static {
|
|
107
|
+
this.styles = [...ImpktElement.styles, spaceAround, widths, css`
|
|
108
|
+
:host { display: block; --impkt-page-margin: inherit; }
|
|
109
|
+
.band { box-sizing: border-box; border-radius: ${t.radiusLg}; }
|
|
110
|
+
:host([bleed]) .band { border-radius: 0; margin-inline: calc(50% - 50vw); padding-inline: calc(50vw - 50%); }
|
|
111
|
+
:host([tone='subtle']) .band { background: ${t.surfaceSubtle}; }
|
|
112
|
+
:host([tone='inset']) .band { background: ${t.surfaceInset}; }
|
|
113
|
+
:host([tone='card']) .band { background: ${t.surfaceCard}; }
|
|
114
|
+
:host([tone='brand']) .band { background: ${t.brand}; color: ${t.onBrand}; --impkt-color-text-heading: ${t.onBrand}; --impkt-color-text-default: ${t.onBrand}; --impkt-color-text-muted: ${t.onBrand}; --impkt-color-text-link: ${t.onBrand}; --impkt-color-text-link-hover: ${t.onBrand}; }
|
|
115
|
+
:host(:not([bleed]):not([tone='none'])) .band { padding-inline: ${space(6)}; }
|
|
116
|
+
:host([padding='sm']) .band { padding-block: ${space(4)}; }
|
|
117
|
+
:host([padding='md']) .band { padding-block: ${space(8)}; }
|
|
118
|
+
:host([padding='lg']) .band { padding-block: ${space(12)}; }
|
|
119
|
+
:host([padding='xl']) .band { padding-block: ${space(16)}; }
|
|
120
|
+
.content { max-inline-size: var(--impkt-page-inner); margin-inline: auto; }
|
|
121
|
+
`];
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
return html`<section class="band" part="band" aria-label=${this.label || nothing} role=${this.label ? nothing : "presentation"}><div class="content" part="content"><slot></slot></div></section>`;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
customElements.define("impkt-page", ImpktPage);
|
|
128
|
+
customElements.define("impkt-section", ImpktSection);
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
ImpktPage,
|
|
132
|
+
ImpktSection
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=chunk-QH46SOPJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/page.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { space, spaceAround, t, token } from '../base/tokens';\n\n/** The widest a line of content runs, for each choice of `width`. */\nconst widths = css`\n :host { --impkt-page-inner: ${token('layout.page-width', '1200px')}; }\n :host([width='narrow']) { --impkt-page-inner: 760px; }\n :host([width='wide']) { --impkt-page-inner: 1440px; }\n`;\n\n/**\n * The side margins, from the brand's layout: narrow on a phone, wider on a\n * tablet and a desktop. Measured against the page itself, so a page drawn in a\n * narrow preview gets phone margins whatever the window is.\n */\nconst margins = css`\n :host { --impkt-page-margin: ${token('layout.margin.phone', '16px')}; }\n @container impkt-page (min-width: 40rem) { .frame { --impkt-page-margin: ${token('layout.margin.tablet', '32px')}; } }\n @container impkt-page (min-width: 64rem) { .frame { --impkt-page-margin: ${token('layout.margin.desktop', '64px')}; } }\n`;\n\n/**\n * The frame every page sits in: a header, the page's own content, and a\n * footer, each kept to the brand's page width with the brand's side margins.\n *\n * A layout puts this at its root, with the site's header and footer in their\n * slots and the page content in the middle, so an app draws the same frame the\n * CMS shows. Without it, a page runs edge to edge.\n *\n * **It gives the page its landmarks.** The header, main content and footer are\n * `header`, `main` and `footer` elements, so a screen reader can jump between\n * them (1.3.1), and the first thing in the page is a \"Skip to content\" link\n * that appears when it has focus (2.4.1).\n *\n * @category layout\n * @icon layout\n * @slot header - The site's header: its logo, navigation and a call to action.\n * @slot - The page's own content.\n * @slot footer - The site's footer.\n */\nexport class ImpktPage extends ImpktElement {\n static properties = {\n width: { type: String, reflect: true },\n stickyHeader: { type: Boolean, reflect: true, attribute: 'sticky-header' },\n skipText: { type: String, attribute: 'skip-text' },\n };\n /** How wide the content runs. Standard is the brand's page width. */\n declare width: 'narrow' | 'standard' | 'wide';\n /** Keep the header at the top of the screen while the page scrolls. */\n declare stickyHeader: boolean;\n /** The words of the link that skips past the header to the content. */\n declare skipText: string;\n\n constructor() {\n super();\n this.width = 'standard';\n this.stickyHeader = false;\n this.skipText = 'Skip to content';\n }\n\n static styles = [...ImpktElement.styles, focusRing, widths, margins, css`\n :host { display: block; container: impkt-page / inline-size; }\n .frame { display: flex; flex-direction: column; min-block-size: 100%; overflow-x: clip; }\n .inner { box-sizing: border-box; inline-size: 100%; max-inline-size: calc(var(--impkt-page-inner) + 2 * var(--impkt-page-margin)); margin-inline: auto; padding-inline: var(--impkt-page-margin); }\n header { background: ${token('color.surface.header', 'transparent')}; color: ${token('color.text.on-header', 'inherit')}; padding-block: ${space(4)}; }\n /* What sits in the header and footer takes their text colour, so words on a dark footer stay readable. */\n header { --impkt-color-text-default: ${token('color.text.on-header', 'inherit')}; --impkt-color-text-heading: ${token('color.text.on-header', 'inherit')}; }\n footer { --impkt-color-text-default: ${token('color.text.on-footer', 'inherit')}; --impkt-color-text-heading: ${token('color.text.on-footer', 'inherit')}; --impkt-color-text-muted: ${token('color.text.on-footer', 'inherit')}; --impkt-color-text-link: ${token('color.text.on-footer', 'inherit')}; --impkt-color-text-link-hover: ${token('color.text.on-footer', 'inherit')}; }\n :host([sticky-header]) header { position: sticky; inset-block-start: 0; z-index: 10; }\n main { flex: 1; padding-block: ${space(6)} ${space(10)}; }\n main:focus { outline: none; }\n footer { background: ${token('color.surface.footer', 'transparent')}; color: ${token('color.text.on-footer', 'inherit')}; padding-block: ${space(8)}; border-block-start: ${t.borderThin} solid ${token('color.border.subtle', 'transparent')}; }\n .skip { position: absolute; inset-inline-start: ${space(2)}; inset-block-start: ${space(2)}; z-index: 20; padding: ${space(2)} ${space(4)}; background: ${t.surfaceCard}; color: ${t.link}; border-radius: ${t.radius}; transform: translateY(-200%); }\n .skip:focus { transform: none; }\n .empty { display: none; }\n `];\n\n private hasSlot(name: string): boolean {\n return Array.from(this.children).some((c) => c.getAttribute('slot') === name);\n }\n\n private skip(event: Event): void {\n event.preventDefault();\n const main = this.renderRoot.querySelector('main');\n main?.focus();\n main?.scrollIntoView();\n }\n\n render(): TemplateResult {\n // The header and footer are left out when nothing is in them, so a page\n // with no site header has no empty landmark for a screen reader to land on.\n const header = this.hasSlot('header');\n const footer = this.hasSlot('footer');\n return html`<div class=\"frame\" part=\"frame\">\n <a class=\"skip\" href=\"#content\" part=\"skip\" @click=${this.skip}>${this.skipText}</a>\n ${header ? html`<header part=\"header\"><div class=\"inner\"><slot name=\"header\"></slot></div></header>` : nothing}\n <main id=\"content\" tabindex=\"-1\" part=\"main\"><div class=\"inner\"><slot></slot></div></main>\n ${footer ? html`<footer part=\"footer\"><div class=\"inner\"><slot name=\"footer\"></slot></div></footer>` : nothing}\n </div>`;\n }\n\n // A header or footer added after the first render still gets its landmark.\n connectedCallback(): void {\n super.connectedCallback();\n this.observer = new MutationObserver(() => this.requestUpdate());\n this.observer.observe(this, { childList: true, attributes: true, subtree: false, attributeFilter: ['slot'] });\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n }\n\n private observer?: MutationObserver;\n}\n\n/**\n * A band across the whole width of the page, with its own background, and its\n * content kept to the page width inside it: a coloured strip of features, a\n * quote on a tinted background, a call to action at the foot of a page.\n *\n * Inside a Page it reaches the edges of the screen whatever the page width is,\n * so a page can alternate bands without any of them knowing the frame. Set\n * `bleed` off to keep the band to the page width, as a panel.\n *\n * @category layout\n * @icon section\n * @slot - The section's content.\n */\nexport class ImpktSection extends ImpktElement {\n static properties = {\n tone: { type: String, reflect: true },\n padding: { type: String, reflect: true },\n width: { type: String, reflect: true },\n bleed: { type: Boolean, reflect: true },\n label: { type: String },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n /** The band's background. Text on it takes the matching colour, so it stays readable. */\n declare tone: 'none' | 'subtle' | 'inset' | 'brand' | 'card';\n /** Space inside the band, above and below its content. */\n declare padding: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n /** How wide the content inside runs. */\n declare width: 'narrow' | 'standard' | 'wide';\n /** Run the background to the edges of the screen. */\n declare bleed: boolean;\n /** A name for the section, so a screen reader can find it in the page's regions. Leave empty for none. */\n declare label: string;\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl';\n\n constructor() {\n super();\n this.tone = 'none';\n this.padding = 'lg';\n this.width = 'standard';\n this.bleed = true;\n this.label = '';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [...ImpktElement.styles, spaceAround, widths, css`\n :host { display: block; --impkt-page-margin: inherit; }\n .band { box-sizing: border-box; border-radius: ${t.radiusLg}; }\n :host([bleed]) .band { border-radius: 0; margin-inline: calc(50% - 50vw); padding-inline: calc(50vw - 50%); }\n :host([tone='subtle']) .band { background: ${t.surfaceSubtle}; }\n :host([tone='inset']) .band { background: ${t.surfaceInset}; }\n :host([tone='card']) .band { background: ${t.surfaceCard}; }\n :host([tone='brand']) .band { background: ${t.brand}; color: ${t.onBrand}; --impkt-color-text-heading: ${t.onBrand}; --impkt-color-text-default: ${t.onBrand}; --impkt-color-text-muted: ${t.onBrand}; --impkt-color-text-link: ${t.onBrand}; --impkt-color-text-link-hover: ${t.onBrand}; }\n :host(:not([bleed]):not([tone='none'])) .band { padding-inline: ${space(6)}; }\n :host([padding='sm']) .band { padding-block: ${space(4)}; }\n :host([padding='md']) .band { padding-block: ${space(8)}; }\n :host([padding='lg']) .band { padding-block: ${space(12)}; }\n :host([padding='xl']) .band { padding-block: ${space(16)}; }\n .content { max-inline-size: var(--impkt-page-inner); margin-inline: auto; }\n `];\n\n render(): TemplateResult {\n return html`<section class=\"band\" part=\"band\" aria-label=${this.label || nothing} role=${this.label ? nothing : 'presentation'}><div class=\"content\" part=\"content\"><slot></slot></div></section>`;\n }\n}\n\ncustomElements.define('impkt-page', ImpktPage);\ncustomElements.define('imp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135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iconSvg
|
|
3
|
+
} from "./chunk-CFGLOYWW.js";
|
|
4
|
+
import {
|
|
5
|
+
ImpktElement,
|
|
6
|
+
focusRing,
|
|
7
|
+
fontSize,
|
|
8
|
+
fontWeight,
|
|
9
|
+
space,
|
|
10
|
+
t,
|
|
11
|
+
targetSize,
|
|
12
|
+
visuallyHidden
|
|
13
|
+
} from "./chunk-5NUF7ZQA.js";
|
|
14
|
+
|
|
15
|
+
// packages/ui/src/components/navigation.ts
|
|
16
|
+
import { css, html, nothing } from "lit";
|
|
17
|
+
function where(href) {
|
|
18
|
+
if (typeof location === "undefined" || !href) return null;
|
|
19
|
+
let path;
|
|
20
|
+
try {
|
|
21
|
+
path = new URL(href, location.href).pathname.replace(/\/$/, "") || "/";
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const here = location.pathname.replace(/\/$/, "") || "/";
|
|
26
|
+
if (path === here) return "page";
|
|
27
|
+
return path !== "/" && here.startsWith(`${path}/`) ? "section" : null;
|
|
28
|
+
}
|
|
29
|
+
var ImpktNav = class extends ImpktElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
/** Whether the menu is open on a narrow screen. Not a setting: it is the visitor's. */
|
|
33
|
+
this.menuOpen = false;
|
|
34
|
+
this.links = [];
|
|
35
|
+
this.label = "Main";
|
|
36
|
+
this.menuText = "Menu";
|
|
37
|
+
this.align = "end";
|
|
38
|
+
}
|
|
39
|
+
static {
|
|
40
|
+
this.properties = {
|
|
41
|
+
links: { type: Array },
|
|
42
|
+
label: { type: String },
|
|
43
|
+
menuText: { type: String, attribute: "menu-text" },
|
|
44
|
+
align: { type: String, reflect: true }
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
get open() {
|
|
48
|
+
return this.menuOpen;
|
|
49
|
+
}
|
|
50
|
+
set open(next) {
|
|
51
|
+
this.menuOpen = next;
|
|
52
|
+
this.requestUpdate();
|
|
53
|
+
}
|
|
54
|
+
static {
|
|
55
|
+
this.styles = [...ImpktElement.styles, focusRing, css`
|
|
56
|
+
/* It grows to fill a row it sits in, because it measures itself to decide when to fold. */
|
|
57
|
+
:host { display: block; container-type: inline-size; flex: 1 1 8rem; min-inline-size: 0; }
|
|
58
|
+
nav { display: flex; flex-direction: column; position: relative; }
|
|
59
|
+
ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: ${space(1)} ${space(4)}; align-items: center; justify-content: flex-end; }
|
|
60
|
+
:host([align='start']) ul { justify-content: flex-start; }
|
|
61
|
+
:host([align='center']) ul { justify-content: center; }
|
|
62
|
+
a { ${targetSize} display: inline-flex; align-items: center; padding: ${space(2)} ${space(1)}; color: inherit; font-weight: ${fontWeight("semibold")}; text-decoration: none; border-radius: ${t.radiusSm}; }
|
|
63
|
+
a:hover { text-decoration: underline; text-underline-offset: 0.25em; }
|
|
64
|
+
a[aria-current] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
|
|
65
|
+
.toggle { display: none; ${targetSize} align-items: center; gap: ${space(2)}; align-self: flex-end; padding: ${space(2)} ${space(3)}; font: inherit; font-weight: ${fontWeight("semibold")}; color: inherit; background: transparent; border: ${t.borderThin} solid currentColor; border-radius: ${t.radius}; cursor: pointer; }
|
|
66
|
+
/* On a narrow screen the links fold behind a Menu button and open as a panel under it. */
|
|
67
|
+
@container (max-width: 36rem) {
|
|
68
|
+
.toggle { display: inline-flex; }
|
|
69
|
+
ul { display: none; position: absolute; inset-block-start: calc(100% + ${space(2)}); inset-inline-end: 0; z-index: 30; flex-direction: column; align-items: stretch; gap: 0; min-inline-size: 14rem; padding: ${space(2)}; background: ${t.surfaceCard}; color: ${t.text}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; box-shadow: 0 8px 24px rgb(0 0 0 / 14%); }
|
|
70
|
+
ul.open { display: flex; }
|
|
71
|
+
li { text-align: start; }
|
|
72
|
+
a { display: flex; padding: ${space(3)} ${space(3)}; }
|
|
73
|
+
}
|
|
74
|
+
`];
|
|
75
|
+
}
|
|
76
|
+
toggle() {
|
|
77
|
+
this.open = !this.open;
|
|
78
|
+
}
|
|
79
|
+
onKey(event) {
|
|
80
|
+
if (event.key !== "Escape" || !this.open) return;
|
|
81
|
+
this.open = false;
|
|
82
|
+
this.renderRoot.querySelector(".toggle")?.focus();
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
const list = this.id_("links");
|
|
86
|
+
return html`<nav aria-label=${this.label || nothing} part="nav" @keydown=${this.onKey}>
|
|
87
|
+
<button class="toggle" type="button" aria-expanded=${this.open ? "true" : "false"} aria-controls=${list} @click=${this.toggle}>${iconSvg(this.open ? "close" : "menu")}${this.menuText}</button>
|
|
88
|
+
<ul id=${list} class=${this.open ? "open" : ""} part="list">
|
|
89
|
+
${(this.links ?? []).map((link) => {
|
|
90
|
+
const current = where(link.href);
|
|
91
|
+
return html`<li><a href=${link.href} aria-current=${current === "page" ? "page" : current === "section" ? "true" : nothing} part="link">${link.label}</a></li>`;
|
|
92
|
+
})}
|
|
93
|
+
</ul>
|
|
94
|
+
</nav>`;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var ImpktBreadcrumbs = class extends ImpktElement {
|
|
98
|
+
static {
|
|
99
|
+
this.properties = {
|
|
100
|
+
items: { type: Array },
|
|
101
|
+
label: { type: String }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
constructor() {
|
|
105
|
+
super();
|
|
106
|
+
this.items = [];
|
|
107
|
+
this.label = "Breadcrumb";
|
|
108
|
+
}
|
|
109
|
+
static {
|
|
110
|
+
this.styles = [...ImpktElement.styles, focusRing, css`
|
|
111
|
+
:host { display: block; font-size: ${fontSize("sm")}; }
|
|
112
|
+
ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: ${space(1)}; }
|
|
113
|
+
li { display: inline-flex; align-items: center; gap: ${space(1)}; }
|
|
114
|
+
li + li::before { content: ''; inline-size: 0.45em; block-size: 0.45em; border-block-start: 1.5px solid ${t.textMuted}; border-inline-end: 1.5px solid ${t.textMuted}; transform: rotate(45deg); margin-inline: ${space(1)} ${space(2)}; }
|
|
115
|
+
a { color: ${t.link}; text-decoration: underline; text-underline-offset: 0.2em; border-radius: ${t.radiusSm}; }
|
|
116
|
+
a:hover { color: ${t.linkHover}; }
|
|
117
|
+
[aria-current] { color: ${t.textMuted}; }
|
|
118
|
+
.sr-only { ${visuallyHidden} }
|
|
119
|
+
`];
|
|
120
|
+
}
|
|
121
|
+
render() {
|
|
122
|
+
const items = this.items ?? [];
|
|
123
|
+
return html`<nav aria-label=${this.label} part="nav"><ol>
|
|
124
|
+
${items.map((item, i) => html`<li>${i === items.length - 1 ? html`<span aria-current="page">${item.label}</span>` : html`<a href=${item.href} part="link">${item.label}</a>`}</li>`)}
|
|
125
|
+
</ol></nav>`;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
customElements.define("impkt-nav", ImpktNav);
|
|
129
|
+
customElements.define("impkt-breadcrumbs", ImpktBreadcrumbs);
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
ImpktNav,
|
|
133
|
+
ImpktBreadcrumbs
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=chunk-U2S7OESF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/navigation.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\nimport { iconSvg } from './icon';\n\n/** One link in a navigation or a trail. */\nexport interface NavLink {\n label: string;\n href: string;\n}\n\n/** Whether a link is the page the visitor is on, or a page above it. */\nfunction where(href: string): 'page' | 'section' | null {\n if (typeof location === 'undefined' || !href) return null;\n let path: string;\n try { path = new URL(href, location.href).pathname.replace(/\\/$/, '') || '/'; } catch { return null; }\n const here = location.pathname.replace(/\\/$/, '') || '/';\n if (path === here) return 'page';\n return path !== '/' && here.startsWith(`${path}/`) ? 'section' : null;\n}\n\n/**\n * The site's main navigation: a row of links that folds into a Menu button on\n * a narrow screen.\n *\n * **The page you are on is marked in words as well as colour.** Its link\n * carries `aria-current=\"page\"`, which a screen reader announces, and an\n * underline, so it does not rely on colour alone (1.4.1).\n *\n * **The menu is a disclosure, not a pop-up.** The Menu button says whether the\n * list is open (`aria-expanded`), the links follow it in the reading order, and\n * Escape closes it and returns focus to the button.\n *\n * @category action\n * @icon menu\n */\nexport class ImpktNav extends ImpktElement {\n static properties = {\n links: { type: Array },\n label: { type: String },\n menuText: { type: String, attribute: 'menu-text' },\n align: { type: String, reflect: true },\n };\n /** The links, in order. */\n declare links: NavLink[];\n /** What the navigation is called for a screen reader, such as \"Main\". */\n declare label: string;\n /** The words on the button that opens the links on a narrow screen. */\n declare menuText: string;\n /** Where the links sit along the row. */\n declare align: 'start' | 'center' | 'end';\n /** Whether the menu is open on a narrow screen. Not a setting: it is the visitor's. */\n private menuOpen = false;\n private get open(): boolean { return this.menuOpen; }\n private set open(next: boolean) { this.menuOpen = next; this.requestUpdate(); }\n\n constructor() {\n super();\n this.links = [];\n this.label = 'Main';\n this.menuText = 'Menu';\n this.align = 'end';\n }\n\n static styles = [...ImpktElement.styles, focusRing, css`\n /* It grows to fill a row it sits in, because it measures itself to decide when to fold. */\n :host { display: block; container-type: inline-size; flex: 1 1 8rem; min-inline-size: 0; }\n nav { display: flex; flex-direction: column; position: relative; }\n ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: ${space(1)} ${space(4)}; align-items: center; justify-content: flex-end; }\n :host([align='start']) ul { justify-content: flex-start; }\n :host([align='center']) ul { justify-content: center; }\n a { ${targetSize} display: inline-flex; align-items: center; padding: ${space(2)} ${space(1)}; color: inherit; font-weight: ${fontWeight('semibold')}; text-decoration: none; border-radius: ${t.radiusSm}; }\n a:hover { text-decoration: underline; text-underline-offset: 0.25em; }\n a[aria-current] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.35em; }\n .toggle { display: none; ${targetSize} align-items: center; gap: ${space(2)}; align-self: flex-end; padding: ${space(2)} ${space(3)}; font: inherit; font-weight: ${fontWeight('semibold')}; color: inherit; background: transparent; border: ${t.borderThin} solid currentColor; border-radius: ${t.radius}; cursor: pointer; }\n /* On a narrow screen the links fold behind a Menu button and open as a panel under it. */\n @container (max-width: 36rem) {\n .toggle { display: inline-flex; }\n ul { display: none; position: absolute; inset-block-start: calc(100% + ${space(2)}); inset-inline-end: 0; z-index: 30; flex-direction: column; align-items: stretch; gap: 0; min-inline-size: 14rem; padding: ${space(2)}; background: ${t.surfaceCard}; color: ${t.text}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; box-shadow: 0 8px 24px rgb(0 0 0 / 14%); }\n ul.open { display: flex; }\n li { text-align: start; }\n a { display: flex; padding: ${space(3)} ${space(3)}; }\n }\n `];\n\n private toggle(): void {\n this.open = !this.open;\n }\n\n private onKey(event: KeyboardEvent): void {\n if (event.key !== 'Escape' || !this.open) return;\n this.open = false;\n this.renderRoot.querySelector<HTMLButtonElement>('.toggle')?.focus();\n }\n\n render(): TemplateResult {\n const list = this.id_('links');\n return html`<nav aria-label=${this.label || nothing} part=\"nav\" @keydown=${this.onKey}>\n <button class=\"toggle\" type=\"button\" aria-expanded=${this.open ? 'true' : 'false'} aria-controls=${list} @click=${this.toggle}>${iconSvg(this.open ? 'close' : 'menu')}${this.menuText}</button>\n <ul id=${list} class=${this.open ? 'open' : ''} part=\"list\">\n ${(this.links ?? []).map((link) => {\n const current = where(link.href);\n return html`<li><a href=${link.href} aria-current=${current === 'page' ? 'page' : current === 'section' ? 'true' : nothing} part=\"link\">${link.label}</a></li>`;\n })}\n </ul>\n </nav>`;\n }\n}\n\n/**\n * Where the page sits in the site, as a trail of links back to the top: Home,\n * then Developments, then this page.\n *\n * The last item is the page itself. It is not a link, and it carries\n * `aria-current=\"page\"`. The separators are drawn, not written, so a screen\n * reader reads the trail as a list rather than a string of slashes.\n *\n * @category action\n * @icon breadcrumbs\n */\nexport class ImpktBreadcrumbs extends ImpktElement {\n static properties = {\n items: { type: Array },\n label: { type: String },\n };\n /** The trail, from the top of the site down to this page. */\n declare items: NavLink[];\n /** What the trail is called for a screen reader. */\n declare label: string;\n\n constructor() {\n super();\n this.items = [];\n this.label = 'Breadcrumb';\n }\n\n static styles = [...ImpktElement.styles, focusRing, css`\n :host { display: block; font-size: ${fontSize('sm')}; }\n ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: ${space(1)}; }\n li { display: inline-flex; align-items: center; gap: ${space(1)}; }\n li + li::before { content: ''; inline-size: 0.45em; block-size: 0.45em; border-block-start: 1.5px solid ${t.textMuted}; border-inline-end: 1.5px solid ${t.textMuted}; transform: rotate(45deg); margin-inline: ${space(1)} ${space(2)}; }\n a { color: ${t.link}; text-decoration: underline; text-underline-offset: 0.2em; border-radius: ${t.radiusSm}; }\n a:hover { color: ${t.linkHover}; }\n [aria-current] { color: ${t.textMuted}; }\n .sr-only { ${visuallyHidden} }\n `];\n\n render(): TemplateResult {\n const items = this.items ?? [];\n return html`<nav aria-label=${this.label} part=\"nav\"><ol>\n ${items.map((item, i) => html`<li>${i === items.length - 1\n ? html`<span aria-current=\"page\">${item.label}</span>`\n : html`<a href=${item.href} part=\"link\">${item.label}</a>`}</li>`)}\n </ol></nav>`;\n }\n}\n\ncustomElements.define('impkt-nav', ImpktNav);\ncustomElements.define('impkt-breadcrumbs', ImpktBreadcrumbs);\ndeclare global { interface HTMLElementTagNameMap { 'impkt-nav': ImpktNav; 'impkt-breadcrumbs': ImpktBreadcrumbs } }\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,KAAK,MAAM,eAAoC;AAaxD,SAAS,MAAM,MAAyC;AACtD,MAAI,OAAO,aAAa,eAAe,CAAC,KAAM,Q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AAAA,EAMA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ,CAAC;AACd,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,aAAa,QAAQ,WAAW;AAAA,yCACb,SAAS,IAAI,CAAC;AAAA,8GACuD,MAAM,CAAC,CAAC;AAAA,2DAC3D,MAAM,CAAC,CAAC;AAAA,8GAC2C,EAAE,SAAS,oCAAoC,EAAE,SAAS,8CAA8C,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAAA,iBACzN,EAAE,IAAI,8EAA8E,EAAE,QAAQ;AAAA,uBACxF,EAAE,SAAS;AAAA,8BACJ,EAAE,SAAS;AAAA,iBACxB,cAAc;AAAA,GAC5B;AAAA;AAAA,EAED,SAAyB;AACvB,UAAM,QAAQ,KAAK,SAAS,CAAC;AAC7B,WAAO,uBAAuB,KAAK,KAAK;AAAA,QACpC,MAAM,IAAI,CAAC,MAAM,MAAM,WAAW,MAAM,MAAM,SAAS,IACrD,iCAAiC,KAAK,KAAK,YAC3C,eAAe,KAAK,IAAI,gBAAgB,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA;AAAA,EAExE;AACF;AAEA,eAAe,OAAO,aAAa,QAAQ;AAC3C,eAAe,OAAO,qBAAqB,gBAAgB;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FieldElement
|
|
3
|
-
|
|
2
|
+
FieldElement,
|
|
3
|
+
fieldWidths
|
|
4
|
+
} from "./chunk-DI2CJ3MZ.js";
|
|
4
5
|
import {
|
|
5
6
|
fontSize,
|
|
6
7
|
space,
|
|
@@ -13,21 +14,24 @@ var ImpktSelect = class extends FieldElement {
|
|
|
13
14
|
static {
|
|
14
15
|
this.properties = {
|
|
15
16
|
...FieldElement.properties,
|
|
17
|
+
width: { type: String, reflect: true },
|
|
16
18
|
options: { type: Array },
|
|
17
19
|
placeholder: { type: String }
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
constructor() {
|
|
21
23
|
super();
|
|
24
|
+
this.width = "full";
|
|
22
25
|
this.options = [];
|
|
23
26
|
this.placeholder = "Choose an option";
|
|
24
27
|
}
|
|
25
28
|
static {
|
|
26
29
|
this.styles = [
|
|
27
30
|
...FieldElement.styles,
|
|
31
|
+
fieldWidths,
|
|
28
32
|
css`
|
|
29
33
|
select {
|
|
30
|
-
inline-size: 100
|
|
34
|
+
inline-size: min(100%, var(--impkt-field-width));
|
|
31
35
|
min-block-size: 44px;
|
|
32
36
|
padding: ${space(3)};
|
|
33
37
|
font-family: inherit;
|
|
@@ -76,4 +80,4 @@ customElements.define("impkt-select", ImpktSelect);
|
|
|
76
80
|
export {
|
|
77
81
|
ImpktSelect
|
|
78
82
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-ZDYTNFQI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/select.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\nexport interface SelectOption {\n value: string;\n label: string;\n}\n\n/**\n * A dropdown.\n *\n * A native `<select>`, because the alternative is a listbox widget that has to\n * reimplement type-ahead, keyboard selection, and the platform's own picker on\n * touch — and whose main advantage is that the arrow can be restyled. On a\n * phone, native wins outright: it opens the system control that the user\n * already knows how to drive.\n *\n * The empty first option carries a real label rather than being blank, so a\n * screen reader announces a choice to make rather than silence.\n\n *\n * @category form\n * @icon select\n */\nexport class ImpktSelect extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n options: { type: Array },\n placeholder: { type: String },\n };\n\n declare options: SelectOption[];\n declare placeholder: string;\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.options = [];\n this.placeholder = 'Choose an option';\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n select {\n inline-size: min(100%, var(--impkt-field-width));\n min-block-size: 44px;\n padding: ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n }\n select:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n :host([invalid]) select {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <select\n id=${this.controlId}\n part=\"select\"\n name=${this.name || nothing}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => this.setFormValue((e.target as HTMLSelectElement).value)}\n >\n <option value=\"\" ?selected=${!this.value}>${this.placeholder}</option>\n ${this.options.map(\n (o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`,\n )}\n </select>\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impkt-select', ImpktSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-select': ImpktSelect;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAyBjD,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,SAAS,EAAE,MAAM,MAAM;AAAA,MACvB,aAAa,EAAE,MAAM,OAAO;AAAA,IAC9B;AAAA;AAAA,EAQA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ;AACb,SAAK,UAAU,CAAC;AAChB,SAAK,cAAc;AAAA,EACrB;AAAA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