@ngu-no/ngu-designsystem 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -2
- package/dist/components/anchor-nav/anchor-nav.css +56 -0
- package/dist/components/anchor-nav/anchor-nav.d.ts +14 -0
- package/dist/components/anchor-nav/anchor-nav.js +91 -0
- package/dist/components/anchor-nav/arrow.svg +3 -0
- package/dist/components/employee-card/employee-card.css +164 -0
- package/dist/components/hero/hero.css +186 -0
- package/dist/components/map-card/default-image.png +0 -0
- package/dist/components/map-card/map-card.css +107 -0
- package/dist/components/map-card/map-card.d.ts +9 -0
- package/dist/components/map-card/map-card.js +55 -0
- package/dist/components/map-details/map-details.css +38 -0
- package/dist/components/map-details/map-details.d.ts +8 -0
- package/dist/components/map-details/map-details.js +14 -0
- package/dist/components/menu-card/icons/area-chart.svg +3 -0
- package/dist/components/menu-card/icons/earth.svg +3 -0
- package/dist/components/menu-card/icons/location-pin.svg +3 -0
- package/dist/components/menu-card/icons/plant.svg +3 -0
- package/dist/components/menu-card/icons/raindrop.svg +3 -0
- package/dist/components/menu-card/menu-card.css +98 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/styles/index.css +12 -0
- package/dist/tokens/extensions.css +11 -0
- package/dist/tokens/index.css +2 -0
- package/dist/tokens/theme/colors.d.ts +20 -0
- package/dist/tokens/theme/theme.css +1193 -0
- package/dist/tokens/theme/types.d.ts +19 -0
- package/package.json +61 -4
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ngu-no/ngu-designsystem
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The design system for [Norges geologiske undersøkelse (NGU)](https://www.ngu.no), built on [Designsystemet](https://designsystemet.no) from Digdir.
|
|
4
|
+
|
|
5
|
+
The package contains:
|
|
6
|
+
|
|
7
|
+
- **The NGU theme**: Designsystemet tokens (`--ds-*`) with NGU's colours and typography, plus NGU-only tokens (`--ngu-*`).
|
|
8
|
+
- **NGU components**: components Designsystemet doesn't have, as CSS classes (`.ngu-*`) and, where they need behaviour, light DOM custom elements (`<ngu-*>`).
|
|
9
|
+
|
|
10
|
+
Designsystemet's own components (buttons, tabs, forms and so on) are not copied into this package. You use them directly from `@digdir/designsystemet-css` and `@digdir/designsystemet-web`, and they get the NGU look from the theme.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @ngu-no/ngu-designsystem @digdir/designsystemet-css @digdir/designsystemet-web
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`@digdir/designsystemet-css` and `@digdir/designsystemet-web` are peer dependencies. npm installs them automatically, but list them in your own `package.json` so that you control the version.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Load the files in this order, for example from your bundler's entry file:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import '@digdir/designsystemet-css';
|
|
26
|
+
import '@ngu-no/ngu-designsystem/tokens.css'; // NGU theme (--ds-*) + NGU tokens (--ngu-*)
|
|
27
|
+
import '@ngu-no/ngu-designsystem/styles.css'; // NGU component styles
|
|
28
|
+
import '@digdir/designsystemet-web'; // behaviour for Designsystemet components
|
|
29
|
+
import '@ngu-no/ngu-designsystem'; // registers the <ngu-*> elements
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then write plain HTML. No framework is needed:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<button class="ds-button" data-variant="primary" type="button">Søk</button>
|
|
36
|
+
|
|
37
|
+
<a class="ds-card ngu-menu-card" href="/kart" data-variant="default" data-size="md">
|
|
38
|
+
<span class="ngu-menu-card__icon" aria-hidden="true"></span>
|
|
39
|
+
<span class="ds-paragraph ngu-menu-card__title" data-size="md" data-variant="short">Geologiske kart</span>
|
|
40
|
+
</a>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
NGU styles are in the CSS layer `ngu`, which comes after Designsystemet's `ds` layer, so NGU overrides win without `!important`.
|
|
44
|
+
|
|
45
|
+
### Font
|
|
46
|
+
|
|
47
|
+
Like Designsystemet, the package does not include a font. The theme uses [Inter](https://rsms.me/inter/), which you load yourself. The simplest option is the Altinn CDN, as recommended on [designsystemet.no](https://designsystemet.no/no/fundamentals/theme/typography#font-family):
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<link
|
|
51
|
+
rel="stylesheet"
|
|
52
|
+
href="https://altinncdn.no/fonts/inter/v4.1/inter.css"
|
|
53
|
+
integrity="sha384-OcHzc/By/OPw9uJREawUCjP2inbOGKtKb4A/I2iXxmknUfog2H8Adx71tWVZRscD"
|
|
54
|
+
crossorigin="anonymous"
|
|
55
|
+
/>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If you can't use an external CDN, host Inter yourself, for example with [`@fontsource-variable/inter`](https://www.npmjs.com/package/@fontsource-variable/inter).
|
|
59
|
+
|
|
60
|
+
### Light and dark mode
|
|
61
|
+
|
|
62
|
+
The theme supports both. Set `data-color-scheme="light"`, `"dark"` or `"auto"` on `<html>` or on any element.
|
|
63
|
+
|
|
64
|
+
## Package contents
|
|
65
|
+
|
|
66
|
+
| Import path | Contents |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `@ngu-no/ngu-designsystem` | JavaScript that registers the `<ngu-*>` custom elements |
|
|
69
|
+
| `@ngu-no/ngu-designsystem/tokens.css` | `theme.css` + `extensions.css` |
|
|
70
|
+
| `@ngu-no/ngu-designsystem/theme.css` | NGU theme for Designsystemet (`--ds-*`) |
|
|
71
|
+
| `@ngu-no/ngu-designsystem/extensions.css` | NGU-only tokens (`--ngu-*`) |
|
|
72
|
+
| `@ngu-no/ngu-designsystem/styles.css` | Styles for all NGU components |
|
|
73
|
+
|
|
74
|
+
## NGU components
|
|
75
|
+
|
|
76
|
+
| Component | Markup | Needs JavaScript |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| Hero | `.ngu-hero` on `.ds-card` | No |
|
|
79
|
+
| MenuCard | `.ngu-menu-card` on `<a class="ds-card">` | No |
|
|
80
|
+
| EmployeeCard | `.ngu-employee-card` on `.ds-card` | No |
|
|
81
|
+
| MapCard | `<ngu-map-card class="ds-card">` | Yes |
|
|
82
|
+
| MapDetails | `<ngu-map-details>` around `.ds-details` | Yes |
|
|
83
|
+
| AnchorNav | `<ngu-anchor-nav>` | Yes |
|
|
84
|
+
|
|
85
|
+
The full markup, variants and usage guidelines for each component are in the project's Storybook (Components → NGU). Documentation for Designsystemet's components is on [designsystemet.no](https://designsystemet.no/no/components).
|
|
86
|
+
|
|
87
|
+
## Versioning
|
|
88
|
+
|
|
89
|
+
The package follows [Semantic Versioning](https://semver.org/). Changes are listed in [CHANGELOG.md](https://github.com/ngu/ngu-designsystem/blob/main/CHANGELOG.md).
|
|
@@ -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
|
+
}
|
|
Binary file
|