Skip to content

Commit

Permalink
Composant Alert (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
slafayIGN authored Jan 26, 2024
1 parent 31fda34 commit a66c19c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _includes/components/alert.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if not alert %}{% set alert = params %}{% endif %}
<div class="fr-alert {% if alert.type %}fr-alert--{{ alert.type }}{% else %}fr-alert--info{% endif %} {% if not alert.title %}fr-alert--sm{% endif %}">
{% if alert.title %}
<h3 class="fr-alert__title">{{ alert.title | safe }}</h3>
{% endif %}
{% if alert.description %}{{ alert.description | safe }} {% endif %}
</div>
63 changes: 63 additions & 0 deletions content/fr/blog/posts/alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: Alert
description: Comment intégrer une alerte
date: git Last Modified
tags:
- DSFR
- composant
---

Ce composant peut être inclus dans un fichier Nunjucks `.njk` ou Markdown `.md`.

## Exemple d'utilisation

```njk
{% raw %}
{% from "components/component.njk" import component with context %}
{{ component("alert", {
type: "info", {# info (par défaut), warning, error, success #}
title: "Test d'alerte",
description: "<p>Le contenu de l'alerte</p>"
}) }}
{% endraw %}
```

Référence : [https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/alerte](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/alerte)

## Rendu

{% from "components/component.njk" import component with context %}
{{ component("alert", {
type: "info",
title: "Titre de l'info",
description: "<p>Le contenu de l'alerte</p>"
}) }}

{% from "components/component.njk" import component with context %}
{{ component("alert", {
type: "warning",
title: "Titre de l'avertissement",
description: "<p>Le contenu de l'alerte</p>"
}) }}

{% from "components/component.njk" import component with context %}
{{ component("alert", {
type: "success",
description: "<p>Contenu de l'alerte seul</p>"
}) }}

{% from "components/component.njk" import component with context %}
{{ component("alert", {
type: "error",
title: "Titre de l'erreur seul"
}) }}

----

Alerte sans type précisé (défaut info) :

{% from "components/component.njk" import component with context %}
{{ component("alert", {
title: "Titre de l'info",
description: "<p>Le contenu de l'alerte</p>"
}) }}

0 comments on commit a66c19c

Please sign in to comment.