@ngu-no/ngu-designsystem 0.0.0-stage → 0.0.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.
@@ -0,0 +1,56 @@
1
+ /* Imported with layer(ngu) from styles/index.css. Based on .ds-link and .ds-heading. */
2
+ ngu-anchor-nav {
3
+ display: block;
4
+ --ngu-anchor-nav-link-size: var(--ds-font-size-3);
5
+ --ngu-anchor-nav-title-size: var(--ds-font-size-4);
6
+ --ngu-anchor-nav-active-color: var(--ds-color-green-text-default);
7
+ }
8
+
9
+ .ngu-anchor-nav__title {
10
+ margin: 0 0 var(--ds-size-2);
11
+ font-size: var(--ngu-anchor-nav-title-size);
12
+ font-weight: var(--ds-font-weight-regular);
13
+ }
14
+
15
+ .ngu-anchor-nav__list {
16
+ display: flex;
17
+ flex-direction: column;
18
+ align-items: flex-start;
19
+ gap: var(--ds-size-2);
20
+ margin: 0;
21
+ padding: 0;
22
+ list-style: none;
23
+ }
24
+
25
+ .ngu-anchor-nav__link {
26
+ color: var(--ds-color-green-text-subtle);
27
+ font-size: var(--ngu-anchor-nav-link-size);
28
+ text-decoration: underline;
29
+ text-decoration-thickness: var(--ds-border-width-default);
30
+ text-underline-offset: var(--ds-size-1);
31
+ }
32
+
33
+ .ngu-anchor-nav__link:hover {
34
+ text-decoration-thickness: calc(var(--ds-border-width-default) * 2);
35
+ }
36
+
37
+ .ngu-anchor-nav__link:focus-visible {
38
+ outline: var(--ds-border-width-focus) solid var(--ds-color-focus-outer);
39
+ outline-offset: var(--ds-border-width-focus);
40
+ }
41
+
42
+ .ngu-anchor-nav__link[aria-current] {
43
+ color: var(--ngu-anchor-nav-active-color);
44
+ text-decoration-thickness: calc(var(--ds-border-width-default) * 2);
45
+ }
46
+
47
+ /* Arrow from Figma (arrow.svg), used as a mask so it follows the active text colour in light and dark mode. */
48
+ .ngu-anchor-nav__link[aria-current]::before {
49
+ content: '';
50
+ display: inline-block;
51
+ width: 1.2em;
52
+ aspect-ratio: 19 / 13;
53
+ margin-inline-end: var(--ds-size-3);
54
+ background-color: currentColor;
55
+ mask: url('./arrow.svg') center / contain no-repeat;
56
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * <ngu-anchor-nav> — in-page navigation ("Innhold") with an active section marker.
3
+ * Light DOM; expected markup is documented in the stories.
4
+ * The active link gets aria-current="location". It follows clicks, hash changes and,
5
+ * unless `no-scroll-spy` is set, the section currently at the top of the viewport.
6
+ */
7
+ export declare class NguAnchorNav extends HTMLElement {
8
+ #private;
9
+ connectedCallback(): void;
10
+ disconnectedCallback(): void;
11
+ /** Href (e.g. "#geologi") of the active link, or null. */
12
+ get active(): string | null;
13
+ set active(href: string | null);
14
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * <ngu-anchor-nav> — in-page navigation ("Innhold") with an active section marker.
3
+ * Light DOM; expected markup is documented in the stories.
4
+ * The active link gets aria-current="location". It follows clicks, hash changes and,
5
+ * unless `no-scroll-spy` is set, the section currently at the top of the viewport.
6
+ */
7
+ export class NguAnchorNav extends HTMLElement {
8
+ #links = [];
9
+ #observer = null;
10
+ #visible = new Set();
11
+ connectedCallback() {
12
+ this.#links = [...this.querySelectorAll('a[href^="#"]')];
13
+ this.addEventListener('click', this.#onClick);
14
+ window.addEventListener('hashchange', this.#onHashChange);
15
+ this.#onHashChange();
16
+ if (!this.hasAttribute('no-scroll-spy'))
17
+ this.#observe();
18
+ }
19
+ disconnectedCallback() {
20
+ this.removeEventListener('click', this.#onClick);
21
+ window.removeEventListener('hashchange', this.#onHashChange);
22
+ this.#observer?.disconnect();
23
+ this.#observer = null;
24
+ this.#visible.clear();
25
+ }
26
+ /** Href (e.g. "#geologi") of the active link, or null. */
27
+ get active() {
28
+ return this.#links.find((link) => link.hasAttribute('aria-current'))?.getAttribute('href') ?? null;
29
+ }
30
+ set active(href) {
31
+ for (const link of this.#links) {
32
+ if (href !== null && link.getAttribute('href') === href)
33
+ link.setAttribute('aria-current', 'location');
34
+ else
35
+ link.removeAttribute('aria-current');
36
+ }
37
+ }
38
+ #target(link) {
39
+ const id = decodeURIComponent(link.hash.slice(1));
40
+ return id ? document.getElementById(id) : null;
41
+ }
42
+ #setActive(href) {
43
+ if (href === this.active)
44
+ return;
45
+ this.active = href;
46
+ this.dispatchEvent(new CustomEvent('ngu-anchor-nav-change', { detail: { href }, bubbles: true }));
47
+ }
48
+ #onClick = (event) => {
49
+ const link = event.target.closest('a[href^="#"]');
50
+ if (link && this.#links.includes(link))
51
+ this.#setActive(link.getAttribute('href'));
52
+ };
53
+ #onHashChange = () => {
54
+ const link = this.#links.find((l) => l.hash.length > 1 && l.hash === window.location.hash);
55
+ if (link)
56
+ this.#setActive(link.getAttribute('href'));
57
+ };
58
+ #observe() {
59
+ if (typeof IntersectionObserver === 'undefined')
60
+ return;
61
+ const targets = new Map();
62
+ for (const link of this.#links) {
63
+ const target = this.#target(link);
64
+ if (target)
65
+ targets.set(target, link);
66
+ }
67
+ if (!targets.size)
68
+ return;
69
+ // A section counts as current while it is in the top part of the viewport.
70
+ this.#observer = new IntersectionObserver((entries) => {
71
+ for (const entry of entries) {
72
+ if (entry.isIntersecting)
73
+ this.#visible.add(entry.target);
74
+ else
75
+ this.#visible.delete(entry.target);
76
+ }
77
+ // Document order: the first visible section wins.
78
+ for (const [target, link] of targets) {
79
+ if (this.#visible.has(target)) {
80
+ this.#setActive(link.getAttribute('href'));
81
+ return;
82
+ }
83
+ }
84
+ }, { rootMargin: '0px 0px -60% 0px' });
85
+ for (const target of targets.keys())
86
+ this.#observer.observe(target);
87
+ }
88
+ }
89
+ if (!customElements.get('ngu-anchor-nav')) {
90
+ customElements.define('ngu-anchor-nav', NguAnchorNav);
91
+ }
@@ -0,0 +1,3 @@
1
+ <svg width="19" height="13" viewBox="0 0 19 13" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M11.4775 0.144531C11.817 -0.0796242 12.2781 -0.0427982 12.5771 0.255859L17.8271 5.50586C17.9912 5.66995 18.084 5.89293 18.084 6.125C18.084 6.35706 17.9912 6.58005 17.8271 6.74414L12.5771 11.9941C12.2781 12.2928 11.817 12.3296 11.4775 12.1055C11.4291 12.0735 11.3825 12.0368 11.3398 11.9941C11.0409 11.6952 11.0034 11.2332 11.2275 10.8936C11.2596 10.845 11.2971 10.7986 11.3398 10.7559L15.0967 7H0.875C0.395873 6.99976 0.00725166 6.61441 0.000976562 6.13672C0.000928898 6.13296 1.34886e-08 6.12877 0 6.125C0 5.6419 0.391958 5.25024 0.875 5.25H15.0967L11.3398 1.49414C11.0409 1.1952 11.0034 0.733172 11.2275 0.393555C11.2596 0.345036 11.2971 0.298573 11.3398 0.255859C11.3825 0.213195 11.4291 0.176537 11.4775 0.144531Z" fill="#163025"/>
3
+ </svg>
@@ -0,0 +1,164 @@
1
+ /*
2
+ * EmployeeCard NGU: .ds-card composed with .ds-avatar, .ds-heading and .ds-paragraph.
3
+ * Ladder step 4 (new NGU component built from .ds-* primitives). Tokens only, no raw values.
4
+ * Layout: avatar left, text column right.
5
+ * Whole card is a link without JavaScript: the name link is stretched over the card (::after).
6
+ * The email link sits above that layer so it stays separately clickable.
7
+ * Figma Dev Mode: padding --ds-size-6, radius-lg, border-subtle, size mode medium. Sizes follow Designsystemet's data-size mode (md = desktop, sm = mobile): every --ds-size-*
8
+ * token scales with it, so the component only picks which token and typography step to use.
9
+ * States (Figma): default = subtle border, surface-default; hover = surface-hover + underlined email;
10
+ * active/visited = surface-active + email underline in visited colour.
11
+ */
12
+ .ngu-employee-card {
13
+ --dsc-card-padding: var(--ds-size-6);
14
+ --dsc-card-border-color: var(--ds-color-border-subtle);
15
+ --dsc-card-background--hover: var(--ds-color-surface-hover);
16
+ --dsc-card-background--active: var(--ds-color-surface-active);
17
+ --ngu-employee-card-gap: var(--ds-size-5);
18
+ /* Figma Dev Mode border-box (Medium): content 372x128, padding 24, border 1 -> card 422x178.
19
+ 128px and 372px have no --ds-size token, so they are kept as component custom properties. */
20
+ --ngu-employee-card-avatar-size: 128px;
21
+ --ngu-employee-card-content-inline-size: 372px;
22
+ position: relative;
23
+ display: flex;
24
+ box-sizing: border-box;
25
+ inline-size: calc(var(--ngu-employee-card-content-inline-size) + 2 * var(--dsc-card-padding) + 2 * var(--dsc-card-border-width));
26
+ max-inline-size: 100%;
27
+ flex-direction: row;
28
+ align-items: center;
29
+ gap: var(--ngu-employee-card-gap);
30
+ cursor: pointer;
31
+ }
32
+
33
+ .ngu-employee-card[data-size='sm'] {
34
+ /* Figma Dev Mode border-box (Small): content 343x112, padding 16, border 1 -> card 377x146. */
35
+ --dsc-card-padding: 16px;
36
+ --ngu-employee-card-gap: var(--ds-size-3);
37
+ --ngu-employee-card-avatar-size: 112px;
38
+ --ngu-employee-card-content-inline-size: 343px;
39
+ }
40
+
41
+ /* [data-state] forces a state (Storybook controls, docs, visual tests). Real use: :hover/:active. */
42
+ @media (hover: hover) and (pointer: fine) {
43
+ .ngu-employee-card:hover {
44
+ background: var(--dsc-card-background--hover);
45
+ }
46
+
47
+ .ngu-employee-card:hover .ngu-employee-card__link {
48
+ text-decoration: underline;
49
+ }
50
+ }
51
+
52
+ .ngu-employee-card[data-state='hover'] {
53
+ background: var(--dsc-card-background--hover);
54
+ }
55
+
56
+ .ngu-employee-card[data-state='hover'] .ngu-employee-card__link {
57
+ text-decoration: underline;
58
+ }
59
+
60
+ .ngu-employee-card:active,
61
+ .ngu-employee-card[data-state='active'] {
62
+ background: var(--dsc-card-background--active);
63
+ }
64
+
65
+ .ngu-employee-card:active .ngu-employee-card__link,
66
+ .ngu-employee-card[data-state='active'] .ngu-employee-card__link {
67
+ text-decoration: underline;
68
+ color: var(--ds-link-color-visited);
69
+ }
70
+
71
+ /* subtle text is too faint on the active surface (contrast < 4.5:1) */
72
+ .ngu-employee-card:active .ngu-employee-card__role,
73
+ .ngu-employee-card[data-state='active'] .ngu-employee-card__role {
74
+ color: var(--ds-color-text-default);
75
+ }
76
+
77
+ .ngu-employee-card:has(.ngu-employee-card__name a:focus-visible) {
78
+ box-shadow: var(--dsc-focus-boxShadow);
79
+ outline: var(--dsc-focus-outline);
80
+ outline-offset: var(--ds-border-width-focus);
81
+ }
82
+
83
+ /*
84
+ * Not clickable (--static): name is plain text, no link in the heading. Use when the profile page
85
+ * would only repeat what the card already shows. No pointer, no hover/active surface. The email
86
+ * stays a normal mailto link.
87
+ */
88
+ .ngu-employee-card--static {
89
+ cursor: default;
90
+ }
91
+
92
+ .ngu-employee-card--static:is(:hover, :active, [data-state]) {
93
+ background: var(--dsc-card-background);
94
+ }
95
+
96
+ .ngu-employee-card--static:is(:hover, :active, [data-state]) .ngu-employee-card__link:not(:hover, :focus-visible) {
97
+ text-decoration: none;
98
+ color: inherit;
99
+ }
100
+
101
+ /* Figma shows a neutral grey placeholder (no initials colour); avatar tokens only. */
102
+ .ngu-employee-card .ds-avatar {
103
+ --dsc-avatar-size: var(--ngu-employee-card-avatar-size);
104
+ --dsc-avatar-background: var(--ngu-color-avatar-placeholder);
105
+ --dsc-avatar-color: var(--ngu-color-avatar-placeholder-text);
106
+ border: var(--ds-border-width-default) solid var(--ds-color-border-subtle);
107
+ }
108
+
109
+ .ngu-employee-card__content {
110
+ display: flex;
111
+ flex-direction: column;
112
+ min-width: 0;
113
+ }
114
+
115
+ .ngu-employee-card__name {
116
+ margin: 0;
117
+ }
118
+
119
+ /* Stretched link: the whole card is the click target. */
120
+ .ngu-employee-card__name a {
121
+ color: inherit;
122
+ text-decoration: none;
123
+ }
124
+
125
+ .ngu-employee-card__name a::after {
126
+ content: '';
127
+ position: absolute;
128
+ inset: 0;
129
+ }
130
+
131
+ .ngu-employee-card__name a:focus-visible {
132
+ outline: none;
133
+ box-shadow: none;
134
+ }
135
+
136
+ .ngu-employee-card__role {
137
+ margin: 0;
138
+ color: var(--ds-color-neutral-text-subtle); /* Figma: grey, not the green accent */
139
+ }
140
+
141
+ .ngu-employee-card__contact {
142
+ margin: 0;
143
+ font-weight: var(--ds-font-weight-medium);
144
+ }
145
+
146
+ .ngu-employee-card__contact:first-of-type {
147
+ margin-block-start: var(--ds-size-2);
148
+ }
149
+
150
+ .ngu-employee-card__link {
151
+ position: relative; /* above the stretched name link */
152
+ color: inherit;
153
+ text-decoration: none;
154
+ text-underline-offset: var(--ds-size-1);
155
+ }
156
+
157
+ .ngu-employee-card__link:visited {
158
+ color: var(--ds-link-color-visited);
159
+ }
160
+
161
+ .ngu-employee-card__link:hover,
162
+ .ngu-employee-card__link:focus-visible {
163
+ text-decoration: underline;
164
+ }
@@ -0,0 +1,186 @@
1
+ /*
2
+ * Hero NGU: .ds-card composed with .ds-heading and .ds-paragraph, image on the right.
3
+ * Ladder step 4 (new NGU component built from .ds-* primitives). CSS only, no <ngu-*> element:
4
+ * the hero is NOT clickable, so there is no behaviour to script. Tokens only, no raw values.
5
+ * Layout responds to the hero's own width (container query), so heroes can share a row or wrap.
6
+ * Typography (Figma): title heading xl, lead heading lg, text paragraph lg long / medium.
7
+ * Colours: data-color="green" (default; data-variant default | tinted) or data-color="dark-green"
8
+ * (filled with the base colour, white text). Hover and active are visual states from Figma only;
9
+ * the hero has no action, so they must never be the only way to reveal information.
10
+ * Figma values sampled: green default/tinted -> surface-default/tinted, hover and active ->
11
+ * surface-hover; dark-green -> base-default / base-hover / base-active.
12
+ */
13
+ .ngu-hero {
14
+ --dsc-card-padding: 0;
15
+ --ngu-hero-background: var(--ds-color-surface-default);
16
+ --ngu-hero-background--hover: var(--ds-color-surface-hover);
17
+ --ngu-hero-background--active: var(--ds-color-surface-hover);
18
+ --ngu-hero-color: var(--ds-color-text-default);
19
+ /* Inline padding scales with the hero width (percentage) and is capped by a size token: Figma
20
+ text starts ~120px from the left = --ds-size-30. Block padding is only a floor: the text is
21
+ centred inside the fixed minimum height, so padding must not push the hero above 445px. */
22
+ --ngu-hero-content-padding-block: var(--ds-size-6);
23
+ --ngu-hero-content-padding-inline: clamp(var(--ds-size-6), 9%, var(--ds-size-30));
24
+ --ngu-hero-media-inline-size: 32%;
25
+ /* Figma 1448x445 expressed in size tokens, so it scales with data-size: max width (border-box) 12 x size-30 + size-2 = 1448px,
26
+ min height 3.7 x size-30. Fluid in between; text may grow the height. */
27
+ --ngu-hero-max-inline-size: calc(var(--ds-size-30) * 12 + var(--ds-size-2));
28
+ /* Text block min height 443px (3.7 x size-30 = 444px, minus 1px) + 2 x 1px hero border = 445px outer. */
29
+ --ngu-hero-min-block-size: calc(var(--ds-size-30) * 3.7 - var(--ds-border-width-default));
30
+ /*
31
+ * Mobile (Figma 466x585 outer, image 278px high), all from size / border tokens (no hero tokens
32
+ * exist in the Figma export). Inner box = outer minus the 2 borders.
33
+ * 585 = 4 x size-30 + size-26 + border-width; image 278 = 2 x size-30 + size-10 - 2 x border-width.
34
+ */
35
+ --ngu-hero-mobile-inner-block-size: calc(var(--ds-size-30) * 4 + var(--ds-size-26) - var(--ds-border-width-default));
36
+ --ngu-hero-mobile-media-block-size: calc(var(--ds-size-30) * 2 + var(--ds-size-10) - 2 * var(--ds-border-width-default));
37
+ /* Smallest width at which a hero is still useful when it sits in a flex row with others. */
38
+ --ngu-hero-min-inline-size: calc(var(--ds-size-30) * 3);
39
+ /*
40
+ * Layout reacts to the hero's own width (container query), not the viewport, so it also works
41
+ * in grids, columns and several heroes per row. Wide: text left, image right. Narrow: image on
42
+ * top, text below.
43
+ */
44
+ container-type: inline-size;
45
+ display: flex;
46
+ flex-direction: row;
47
+ flex-wrap: wrap;
48
+ /* Figma: justify-content flex-end, align-items flex-start; children are fixed-height there, so they stretch here. */
49
+ align-items: stretch;
50
+ box-sizing: border-box;
51
+ /* Block parent: full width. Flex parent: grows to share the row, wraps to a new row below the minimum. */
52
+ inline-size: 100%;
53
+ flex: 1 1 var(--ngu-hero-min-inline-size);
54
+ max-inline-size: var(--ngu-hero-max-inline-size);
55
+ background: var(--ngu-hero-background);
56
+ color: var(--ngu-hero-color);
57
+ cursor: default;
58
+ }
59
+
60
+ .ngu-hero[data-variant='tinted'] {
61
+ --ngu-hero-background: var(--ds-color-surface-tinted);
62
+ }
63
+
64
+ /* Dark green: filled with the base colour, contrast text. Variant has no effect here. */
65
+ .ngu-hero[data-color='dark-green'] {
66
+ --ngu-hero-background: var(--ds-color-base-default);
67
+ --ngu-hero-background--hover: var(--ds-color-base-hover);
68
+ --ngu-hero-background--active: var(--ds-color-base-active);
69
+ --ngu-hero-color: var(--ds-color-base-contrast-default);
70
+ }
71
+
72
+ /* [data-state] forces a state (Storybook controls, docs, visual tests). Real use: :hover/:active. */
73
+ @media (hover: hover) and (pointer: fine) {
74
+ .ngu-hero:hover {
75
+ background: var(--ngu-hero-background--hover);
76
+ }
77
+ }
78
+
79
+ .ngu-hero[data-state='hover'] {
80
+ background: var(--ngu-hero-background--hover);
81
+ }
82
+
83
+ .ngu-hero:active,
84
+ .ngu-hero[data-state='active'] {
85
+ background: var(--ngu-hero-background--active);
86
+ }
87
+
88
+ .ngu-hero__content {
89
+ display: flex;
90
+ flex: 1 1 0;
91
+ flex-direction: column;
92
+ justify-content: center;
93
+ min-inline-size: 0;
94
+ box-sizing: border-box;
95
+ min-block-size: var(--ngu-hero-min-block-size);
96
+ padding-block: var(--ngu-hero-content-padding-block);
97
+ padding-inline: var(--ngu-hero-content-padding-inline);
98
+ }
99
+
100
+ .ngu-hero__content > * {
101
+ margin: 0;
102
+ color: var(--ngu-hero-color);
103
+ }
104
+
105
+ .ngu-hero__content > * + * {
106
+ margin-block-start: var(--ds-size-3);
107
+ }
108
+
109
+ /* Gap between subtitle (lead) and text. */
110
+ .ngu-hero__lead + .ngu-hero__text {
111
+ margin-block-start: var(--ds-size-4);
112
+ }
113
+
114
+ /*
115
+ * Typography per Figma (Dev Mode), all from Designsystemet tokens:
116
+ * title .ds-heading xl (48px / 500 / 1.3 / -0.01em); lead .ds-heading lg (36px / 500 / 1.3 / -0.005em);
117
+ * text .ds-paragraph lg long (21px / 1.7 / 0.005em) in medium weight (500).
118
+ */
119
+ .ngu-hero__text {
120
+ font-weight: var(--ds-font-weight-medium);
121
+ }
122
+
123
+ .ngu-hero__media {
124
+ flex: 0 0 var(--ngu-hero-media-inline-size);
125
+ position: relative;
126
+ margin: 0;
127
+ min-inline-size: 0;
128
+ }
129
+
130
+ /* Out of flow so the image's own aspect ratio never sets the hero height (a tall image would). */
131
+ .ngu-hero__media img {
132
+ position: absolute;
133
+ inset: 0;
134
+ display: block;
135
+ inline-size: 100%;
136
+ block-size: 100%;
137
+ object-fit: cover;
138
+ }
139
+
140
+ /*
141
+ * Narrow hero (Figma mobile 466x585): image on top, text below, padding 24 = --ds-size-6.
142
+ * The container query cannot resize the hero itself, so width stays fluid (466px outer =
143
+ * 3 x size-30 + size-26 + 2 x border-width when the parent is that wide); the height is built from
144
+ * the image (278px) plus a text block that fills the rest of the 585px.
145
+ * object-fit: cover fills the full width of the 278px box (the image is cropped, not letterboxed).
146
+ */
147
+ @container (max-width: 40rem) {
148
+ .ngu-hero__media {
149
+ flex: 0 0 100%;
150
+ order: -1;
151
+ }
152
+
153
+ .ngu-hero__media img {
154
+ position: static;
155
+ inline-size: 100%;
156
+ block-size: var(--ngu-hero-mobile-media-block-size);
157
+ object-fit: cover;
158
+ }
159
+
160
+ /* Mobile typography (Figma Dev Mode), Designsystemet tokens: title heading md (30px / 500 / 1.3 / -0.0025em),
161
+ lead heading sm (24px / 500 / 1.3), text paragraph sm long (16px / 1.7 / 0.0025em) in medium weight. */
162
+ .ngu-hero__title {
163
+ font-size: var(--ds-heading-md-font-size);
164
+ line-height: var(--ds-heading-md-line-height);
165
+ letter-spacing: var(--ds-heading-md-letter-spacing);
166
+ }
167
+
168
+ .ngu-hero__lead {
169
+ font-size: var(--ds-heading-sm-font-size);
170
+ line-height: var(--ds-heading-sm-line-height);
171
+ letter-spacing: var(--ds-heading-sm-letter-spacing);
172
+ }
173
+
174
+ .ngu-hero__text {
175
+ font-size: var(--ds-body-long-sm-font-size);
176
+ line-height: var(--ds-body-long-sm-line-height);
177
+ letter-spacing: var(--ds-body-long-sm-letter-spacing);
178
+ }
179
+
180
+ .ngu-hero__content {
181
+ flex-basis: 100%;
182
+ min-block-size: calc(var(--ngu-hero-mobile-inner-block-size) - var(--ngu-hero-mobile-media-block-size));
183
+ padding-block: var(--ds-size-6);
184
+ padding-inline: var(--ds-size-6);
185
+ }
186
+ }
@@ -0,0 +1,107 @@
1
+ /* Imported with layer(ngu) from styles/index.css. Based on .ds-card. */
2
+ ngu-map-card {
3
+ display: block;
4
+ --ngu-map-card-heading-size: var(--ds-font-size-4);
5
+ --dsc-card-padding: var(--ds-size-4);
6
+ --dsc-card-block-border-width: 0;
7
+ --dsc-card-content-margin-block: var(--ds-size-2) 0;
8
+ cursor: pointer;
9
+ }
10
+
11
+ /* Same hover as a clickable ds-card; applies to both default and tinted variants. */
12
+ @media (hover: hover) and (pointer: fine) {
13
+ ngu-map-card:hover {
14
+ background: var(--ds-color-surface-hover);
15
+ }
16
+
17
+ ngu-map-card:hover:active {
18
+ background: var(--ds-color-surface-active);
19
+ }
20
+ }
21
+
22
+ ngu-map-card a {
23
+ cursor: pointer;
24
+ }
25
+
26
+ ngu-map-card[data-size='sm'] {
27
+ --ngu-map-card-heading-size: var(--ds-font-size-3);
28
+ }
29
+
30
+ .ngu-map-card__media {
31
+ padding: 0;
32
+ }
33
+
34
+ .ngu-map-card__media img {
35
+ display: block;
36
+ width: 100%;
37
+ aspect-ratio: 16 / 9;
38
+ object-fit: cover;
39
+ }
40
+
41
+ .ngu-map-card__header {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: space-between;
45
+ gap: var(--ds-size-2);
46
+ padding-block: var(--ds-size-3);
47
+ /* ds-card adds margin to sibling children via this variable; flex alignment needs none. */
48
+ --dsc-card-content-margin-block: 0;
49
+ }
50
+
51
+ .ngu-map-card__content {
52
+ padding-block-start: 0;
53
+ }
54
+
55
+ .ngu-map-card__content > * + * {
56
+ margin-block-start: var(--ds-size-3);
57
+ }
58
+
59
+ .ngu-map-card__title {
60
+ margin: 0;
61
+ font-size: var(--ngu-map-card-heading-size);
62
+ }
63
+
64
+ /* ds-link defaults to the subtle text colour; Figma uses text-default. */
65
+ .ngu-map-card__title .ds-link {
66
+ --dsc-link-color: var(--ds-color-text-default);
67
+ }
68
+
69
+ .ngu-map-card__toggle {
70
+ display: inline-flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ flex-shrink: 0;
74
+ min-width: var(--ds-size-8);
75
+ min-height: var(--ds-size-8);
76
+ padding: 0;
77
+ border: 0;
78
+ border-radius: var(--ds-border-radius-md);
79
+ background: transparent;
80
+ color: inherit;
81
+ cursor: pointer;
82
+ }
83
+
84
+ .ngu-map-card__toggle svg {
85
+ pointer-events: none;
86
+ }
87
+
88
+ .ngu-map-card__toggle:focus-visible {
89
+ outline: var(--ds-border-width-focus) solid var(--ds-color-focus-outer);
90
+ outline-offset: var(--ds-border-width-focus);
91
+ }
92
+
93
+ .ngu-map-card__toggle svg {
94
+ width: var(--ds-size-6);
95
+ height: var(--ds-size-6);
96
+ transition: transform 150ms ease;
97
+ }
98
+
99
+ ngu-map-card[open] .ngu-map-card__toggle svg {
100
+ transform: rotate(180deg);
101
+ }
102
+
103
+ @media (prefers-reduced-motion: reduce) {
104
+ .ngu-map-card__toggle svg {
105
+ transition: none;
106
+ }
107
+ }
@@ -0,0 +1,9 @@
1
+ export declare class NguMapCard extends HTMLElement {
2
+ #private;
3
+ static observedAttributes: string[];
4
+ connectedCallback(): void;
5
+ disconnectedCallback(): void;
6
+ attributeChangedCallback(): void;
7
+ get open(): boolean;
8
+ set open(value: boolean);
9
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * <ngu-map-card> — a card that behaves like a disclosure.
3
+ * The heading link navigates; clicking anywhere else on the card toggles the description.
4
+ * Light DOM; expected markup is documented in the docs page and stories.
5
+ */
6
+ let uid = 0;
7
+ export class NguMapCard extends HTMLElement {
8
+ static observedAttributes = ['open'];
9
+ #toggle = null;
10
+ #content = null;
11
+ connectedCallback() {
12
+ this.#toggle = this.querySelector('.ngu-map-card__toggle');
13
+ this.#content = this.querySelector('.ngu-map-card__content');
14
+ if (!this.hasAttribute('data-color'))
15
+ this.setAttribute('data-color', 'dark-blue');
16
+ if (!this.#toggle || !this.#content)
17
+ return;
18
+ if (!this.#content.id)
19
+ this.#content.id = `ngu-map-card-${++uid}`;
20
+ this.#toggle.setAttribute('aria-controls', this.#content.id);
21
+ this.addEventListener('click', this.#onClick);
22
+ this.#sync();
23
+ }
24
+ disconnectedCallback() {
25
+ this.removeEventListener('click', this.#onClick);
26
+ }
27
+ attributeChangedCallback() {
28
+ this.#sync();
29
+ }
30
+ get open() {
31
+ return this.hasAttribute('open');
32
+ }
33
+ set open(value) {
34
+ this.toggleAttribute('open', value);
35
+ }
36
+ #onClick = (event) => {
37
+ const target = event.target;
38
+ if (target.closest('a'))
39
+ return;
40
+ // Don't collapse the card when the user is selecting text in the description.
41
+ if (window.getSelection()?.toString())
42
+ return;
43
+ this.open = !this.open;
44
+ this.dispatchEvent(new CustomEvent('ngu-map-card-toggle', { detail: { open: this.open }, bubbles: true }));
45
+ };
46
+ #sync() {
47
+ if (!this.#toggle || !this.#content)
48
+ return;
49
+ this.#toggle.setAttribute('aria-expanded', String(this.open));
50
+ this.#content.hidden = !this.open;
51
+ }
52
+ }
53
+ if (!customElements.get('ngu-map-card')) {
54
+ customElements.define('ngu-map-card', NguMapCard);
55
+ }