Skip to content
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

docs(Alert): add documentation for new Alert component #1008

Merged
merged 3 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions content/app/development/ux/components/alertComponent/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: Alert
description: This component displays an important message to the user. The component can be used to display a message with different levels of severity.
hidden: false
---

## Usage

Alerts are commonly used to display important information to users that should be highlighted.

* [Page layout JSON schema](https://altinncdn.no/schemas/json/layout/layout.schema.v1.json)

## Component properties

| **Property** | **Title** | **Type** | **Description** |
|--------------|--------------|------------------------------------------------|------------------------------------------------------------------------------------------------|
| `severity` | Severity | `"success" \| "info" \| "danger" \| "warning"` | String value indicating the severity level of the alert. This affect the styling of the alert. |

### Properties Description

The component has these properties:

#### severity

The severity of the alert. This affects the styling of the alert.


#### textResourceBindings

`title` and `description` can be configured with `textResourceBindings` to display text from the resource file.

## Accessibility

The component does not have `role="alert"` by default. This means that screen readers will not treat this as an alert.
An `Alert` should only have `role="alert"` if it appears in the ui as a result of an action the user has taken. Therefore,
`role="alert"` will be added if you use an expression in the hidden property.

## Examples

### Info

An alert with `severity` `"info"`

![Info card](info.png)

`FormLayout.json` example:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "info"
}

```

### Success

An alert with `severity` `"success"`

![Info card](success.png)

`FormLayout.json` example:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "success"
}

```
### Warning

An alert with `severity` `"warning"`

![Info card](warning.png)

`FormLayout.json` example:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "warning"
}

```
### Danger

An alert with `severity` `"danger"`

![Info card](danger.png)

`FormLayout.json` example:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "danger"
}

```

120 changes: 120 additions & 0 deletions content/app/development/ux/components/alertComponent/_index.nb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
title: Alert
description: Denne komponenten viser en viktig melding til brukeren. Komponenten kan brukes til å vise en melding med ulike alvorlighetsgrader.
skjult: false
---

## Bruk

Alert brukes ofte til å vise viktig informasjon som skal fremheves for brukerne.

* [Sideoppsett JSON-skjema](https://altinncdn.no/schemas/json/layout/layout.schema.v1.json)

## Komponentegenskaper

| **Egenskap** | **Tittel** | **Type** | **Beskrivelse** |
|--------------|------------------|------------------------------------------------|-----------------------------------------------------------------------------------------------|
| `severity` | Alvorlighetsgrad | `"success" \| "info" \| "danger" \| "warning"` | Strengverdi som angir alvorlighetsgraden til varselet. Dette påvirker utseendet til varselet. |

### Beskrivelse av egenskaper

Komponenten har følgende egenskaper:

#### severity

Alvorlighetsgraden til varselet. Dette påvirker utseendet til varselet.


#### textResourceBindings

`title` og `description` kan konfigureres med `textResourceBindings` for å vise tekst fra ressursfilen.

## Tilgjengelighet

Komponenten får ikke automatisk `role="alert"`. Dette betyr at skjermlesere ikke vil behandle den som en varsel.
En Alert bør bare ha `role="alert"` hvis den vises i brukergrensesnittet som et resultat av en handling brukeren har tatt.
Vi legger automatisk til `role="alert"` hvis `Alert` har en `hidden`-egenskap satt til false. Dette betyr at `Alert`-en
ble synlig for brukeren basert på en handling brukeren tok.

## Eksempel

### Info

En alert med `severity` `"info"`

![Info card](info.png)

`FormLayout.json` eksempel:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "info"
}

```

### Success

En alert med `severity` `"success"`

![Info card](success.png)

`FormLayout.json` eksempel:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "success"
}
```

### Warning

En alert med `severity` `"warning"`

![Info card](warning.png)

`FormLayout.json` eksempel:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "warning"
}
```

### Danger

En alert med `severity` `"danger"`

![Info card](danger.png)

`FormLayout.json` eksempel:

```json
{
"id": "alert-id",
"type": "Alert",
"textResourceBindings": {
"title": "Vedrørende navneendring",
"description": "Ved å bekrefte navneendring bekrefter du at du ønsker å endre navnet ditt."
},
"severity": "danger"
}
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.