-
Notifications
You must be signed in to change notification settings - Fork 1
feat(nve-layout): layoutkomponenter #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
malingranlynve
wants to merge
18
commits into
main
Choose a base branch
from
feature/layout-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
900fb21
feature(nve-layout): layoutkomponenter
malingranly b69efe9
lagt til box, stack og grid layout samt dokumentasjon og eksempler
malingranly 513d6eb
la til cluster layout og forenklet ekseplene litt
malingranly d8da1da
endret litt på beskrivelser
malingranly 8353ce3
Merge branch 'main' of https://github.com/NVE/Designsystem into featu…
malingranly 1d223a9
removed unused colorlist component
malingranly 63f5c36
fjernet tekst som ikke trengtes
malingranly 47bb92b
lagt til tydeligere eksmpel på kombinering av bruk. fjerne size og by…
malingranly a85c13f
fikset mappestruktur og navngivning
malingranly aae4c2f
fikset litt kommentarer
malingranly a6a0076
laget union types for justify og gap
malingranly d839bdb
lagt til bedre visualisering av hvordan komponenten jobber sammen
malingranly 85da30c
endret grid styles til 100% i stedet for 250px
malingranly 71f2bc3
la til begrunnelse for valg i beslutninger-filen
malingranly 8da9853
oppdatert egenskaper til alle docs
malingranly c9819ac
oppdaterte filsti for bilde
malingranly 7354536
Merge remote-tracking branch 'origin/main' into feature/layout-compon…
malingranly f52224e
fikset kommentarer, lagt til mer dokumentasjon
malingranly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <PageHeader title="Layout-komponenter" imagePath="developer" pageLevel=1></PageHeader> | ||
|
|
||
| Layout-komponentene er strukturelle byggeklosser basert på prinsippene fra [Every Layout](https://every-layout.dev/). | ||
| De håndterer plassering og fordeling av innhold uten å binde seg til visuell stil og kan kombineres fritt for å bygge opp sider og seksjoner. | ||
|
|
||
| ## Hvorfor bruke dem? | ||
|
|
||
| Du slipper å skrive egen CSS for vanlige oppsett, og avstander hentes fra designsystemets tokens. Det gir konsistente sider, raskere utvikling og mindre vedlikehold når designet endres. | ||
|
|
||
| ## Når skal du bruke layout-komponenter? | ||
|
|
||
| Bruk layout-komponentene når du vil: | ||
|
|
||
| - Stable elementer vertikalt med konsistent mellomrom (`nve-stack`) | ||
| - Gruppere elementer horisontalt med automatisk linjebryting (`nve-cluster`) | ||
| - Lage et responsivt rutenett (`nve-grid`) | ||
| - Gi et element definert padding og bakgrunn (`nve-box`) | ||
|
|
||
| ## Prinsipper | ||
|
|
||
| Layout-komponentene har ingen farger, fonter eller annen visuell stil, de styrer kun struktur og plassering. De er ment å kombineres, og bryr seg ikke om hva som ligger inni dem. | ||
|
|
||
| ## Eksempel på bruk | ||
|
|
||
| Layout-komponentene er laget for å kombineres. Et kontaktskjema er et typisk eksempel som bruker alle fire: `nve-box` gir kortet ramme og padding, `nve-stack` stabler feltene vertikalt, `nve-grid` legger fornavn og etternavn ved siden av hverandre og bryter til en kolonne på smale skjermer. `nve-cluster` plasserer knappene nederst. | ||
|
|
||
| <CodeExamplePreview> | ||
|
|
||
| ```html | ||
| <nve-box padding="large" background="--color-neutrals-background-canvas"> | ||
| <nve-stack> | ||
| <nve-heading level="3">Kontakt oss</nve-heading> | ||
| <p>Fyll ut skjemaet, så tar vi kontakt så raskt vi kan.</p> | ||
| <nve-grid gap="small" min="220px"> | ||
| <nve-input label="Fornavn"></nve-input> | ||
| <nve-input label="Etternavn"></nve-input> | ||
| </nve-grid> | ||
| <nve-input label="E-post" type="email"></nve-input> | ||
| <nve-textarea label="Melding"></nve-textarea> | ||
| <nve-cluster gap="small" justify="flex-end"> | ||
| <nve-button variant="ghost">Avbryt</nve-button> | ||
| <nve-button variant="primary">Send</nve-button> | ||
| </nve-cluster> | ||
| </nve-stack> | ||
| </nve-box> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| <img src="../assets/images/layout-visualisering.png" width="690" alt="Visualisering av layoutkomponentene (Grid, Stack, Cluster og Box) i Designsystemet."> | ||
|
|
||
| ## Felles spacing-props | ||
|
|
||
| Alle layout-komponenter arver `padding`, `margin`, `padding-block`, `padding-inline`, `margin-block` og `margin-inline` fra en basis layoutklasse. Verdiene er låst til spacing-tokenene i designsystemet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # nve-box | ||
|
malingranlynve marked this conversation as resolved.
|
||
|
|
||
| `nve-box` pakker innhold i en boks med konsistent padding. | ||
|
|
||
| `padding` er knyttet direkte til spacing-tokenene i designsystemet og sikrer at paddingen er konsistent på tvers av sider og komponenter. | ||
|
|
||
| ## Import | ||
|
|
||
| Layout-komponentene ligger et nivå under de andre komponentene. For å bruke disse kan du følge stien med `/layout` etterfulgt av komponentet du vil bruke. Eksempel: | ||
|
|
||
| ```javascript | ||
| import 'nve-designsystem/components/layouts/nve-box/nve-box.component.js'; | ||
| ``` | ||
|
|
||
| ## Padding | ||
|
|
||
| `padding` setter padding rundt innholdet ved bruk av et spacing-token. Hvis `padding` ikke er satt, brukes `medium` som standard. | ||
|
malingranlynve marked this conversation as resolved.
|
||
|
|
||
| ### Gyldige spacing-verdier | ||
|
|
||
| Følgende verdier er gyldige for `padding`: | ||
| `none`, `2x-small`, `x-small`, `small`, `medium` (default), `large`, `x-large`, `2x-large`, `3x-large`, `4x-large` og `5x-large`. | ||
|
|
||
| <CodeExamplePreview containerGridTemplateColumns="repeat(3, 1fr)" containerItemsAlign="start"> | ||
|
|
||
| ```html | ||
| <nve-box padding="small" background="--color-neutrals-background-canvas"> | ||
| <div style="padding: 0.75rem; background: var(--color-neutrals-background-secondary)"></div> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-canvas"> | ||
| <div style="padding: 0.75rem; background: var(--color-neutrals-background-secondary)"></div> | ||
| </nve-box> | ||
| <nve-box padding="large" background="--color-neutrals-background-canvas"> | ||
| <div style="padding: 0.75rem; background: var(--color-neutrals-background-secondary)"></div> | ||
| </nve-box> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| ## Bakgrunn | ||
|
|
||
| `background` setter en tokenbasert bakgrunnsfarge på boksen. Gyldige verdier kommer fra neutrals background-tokensene. | ||
|
|
||
| ### Gyldige bakgrunnsverdier | ||
|
|
||
| Følgende verdier er gyldige for `background`: `--color-neutrals-background-canvas`, `--color-neutrals-background-primary`, `--color-neutrals-background-primary-contrast`, `--color-neutrals-background-secondary`, `--color-neutrals-background-secondary-dim` og `--color-neutrals-background-tertiary-dim`. | ||
|
|
||
| <CodeExamplePreview containerGridTemplateColumns="repeat(3, 1fr)" containerItemsAlign="start"> | ||
|
|
||
| ```html | ||
| <nve-box background="--color-neutrals-background-canvas"> | ||
| <nve-paragraph>canvas</nve-paragraph> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-primary"> | ||
| <nve-paragraph>primary</nve-paragraph> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-primary-contrast"> | ||
| <nve-paragraph>primary-contrast</nve-paragraph> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-secondary"> | ||
| <nve-paragraph>secondary</nve-paragraph> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-secondary-dim"> | ||
| <nve-paragraph style="color: var(--color-neutrals-foreground-inverted)">secondary-dim</nve-paragraph> | ||
| </nve-box> | ||
| <nve-box background="--color-neutrals-background-tertiary-dim"> | ||
| <nve-paragraph style="color: var(--color-neutrals-foreground-inverted)">tertiary-dim</nve-paragraph> | ||
| </nve-box> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| ## Nøsting | ||
|
|
||
| Bokser kan nøstes for å bygge opp et hierarki av padding. | ||
|
|
||
| <CodeExamplePreview> | ||
|
|
||
| ```html | ||
| <nve-box padding="large" background="--color-neutrals-background-canvas"> | ||
| <nve-box padding="small" background="--color-neutrals-background-secondary"> | ||
| <div style="padding: 0.75rem; background: var(--color-neutrals-background-canvas)"></div> | ||
| </nve-box> | ||
| </nve-box> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| ## Eksempel på bruk | ||
|
|
||
| En boks med konsistent padding rundt en tekst. | ||
|
|
||
| <CodeExamplePreview> | ||
|
|
||
| ```html | ||
| <nve-box background="--color-neutrals-background-secondary"> | ||
| <nve-paragraph>Innhold med jevn padding rundt.</nve-paragraph> | ||
| </nve-box> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| Samme innhold uten `nve-box` hvor teksten ligger helt inntil kanten. | ||
|
|
||
| <CodeExamplePreview> | ||
|
|
||
| ```html | ||
| <div style="background: var(--color-neutrals-background-secondary)"> | ||
| <nve-paragraph>Innhold med null padding rundt.</nve-paragraph> | ||
| </div> | ||
| ``` | ||
|
|
||
| </CodeExamplePreview> | ||
|
|
||
| ## Egenskaper | ||
|
|
||
| | Egenskap | Type | Standard | Beskrivelse | | ||
| | ---------------- | --------------- | -------- | ---------------------------------------------------------------------------------------- | | ||
| | `background` | `BoxBackground` | — | Tokenbasert bakgrunnsfarge. Gyldige verdier er `--color-neutrals-background-*`-tokenene. | | ||
| | `padding` | `SpacingToken` | `medium` | Tokenbasert padding på alle sider. Visuell standard er `medium` via CSS. | | ||
| | `padding-block` | `SpacingToken` | — | Overstyrer `padding` i blokk-retning (topp/bunn). | | ||
| | `padding-inline` | `SpacingToken` | — | Overstyrer `padding` i inline-retning (venstre/høyre). | | ||
| | `margin` | `SpacingToken` | — | Tokenbasert margin på alle sider. | | ||
| | `margin-block` | `SpacingToken` | — | Overstyrer `margin` i blokk-retning (topp/bunn). | | ||
| | `margin-inline` | `SpacingToken` | — | Overstyrer `margin` i inline-retning (venstre/høyre). | | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.