generated from codegouvfr/eleventy-dsfr
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
composant download et usage dans un tutoriel (refs #36)
- Loading branch information
Showing
3 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,50 @@ | ||
{% if not download %}{% set download = params %}{% endif %} | ||
{% if download.type == "card" %} | ||
<div class="fr-card fr-enlarge-link fr-card--download"> | ||
<div class="fr-card__body"> | ||
<div class="fr-card__content"> | ||
<h3 class="fr-card__title"> | ||
<a download href="{{ download.href }}"> | ||
{{ download.title }} | ||
</a> | ||
</h3> | ||
{% if download.description %} | ||
<p class="fr-card__desc">{{ download.description }}</p> | ||
{% endif %} | ||
<div class="fr-card__end"> | ||
<p class="fr-card__detail">{{ download.detail }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% elif download.type == "tile" %} | ||
<div class="fr-tile fr-tile--download fr-enlarge-link" id="tile-6735"> | ||
<div class="fr-tile__body"> | ||
<div class="fr-tile__content"> | ||
<h4 class="fr-tile__title"> | ||
<a href="{{ download.href }}" download>{{ download.title }}</a> | ||
</h4> | ||
<p class="fr-tile__desc">{{ download.description }}</p> | ||
<p class="fr-tile__detail">{{ download.detail }}</p> | ||
</div> | ||
</div> | ||
{% if download.pictogram %} | ||
<div class="fr-tile__header"> | ||
<div class="fr-tile__pictogram"> | ||
{% set pictogramUrl = "/artwork/pictograms/" + download.pictogram %} | ||
<svg aria-hidden="true" class="fr-artwork" viewBox="0 0 80 80" width="80px" height="80px"> | ||
<use class="fr-artwork-decorative" href="{{ pictogramUrl | htmlBaseUrl }}#artwork-decorative"></use> | ||
<use class="fr-artwork-minor" href="{{ pictogramUrl | htmlBaseUrl }}#artwork-minor"></use> | ||
<use class="fr-artwork-major" href="{{ pictogramUrl | htmlBaseUrl }}#artwork-major"></use> | ||
</svg> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% else %} | ||
<p> | ||
<a class="fr-link fr-link--download" download href="{{ download.href }}"> | ||
{{ download.title }} <span class="fr-link__detail">{{ download.detail }}</span> | ||
</a> | ||
</p> | ||
{% endif %} |
This file contains 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,98 @@ | ||
--- | ||
title: Téléchargement de fichier | ||
description: Comment intégrer un lien de téléchargement de fichier dans une page du site ? | ||
date: git Last Modified | ||
tags: | ||
- DSFR | ||
- composant | ||
--- | ||
Chaque composant peut être inclus dans un fichier Nunjucks `.njk` ou Markdown `.md`. | ||
|
||
## Exemples d'utilisation | ||
|
||
### Lien | ||
|
||
```njk | ||
{% raw %} | ||
{% from "components/component.njk" import component with context %} | ||
{{ component("download", { | ||
title: "Nom du fichier", | ||
href: "/data/dossier/fichier.ext", | ||
detail: "Format ou extension - 850Ko" | ||
}) }} | ||
{% endraw %} | ||
``` | ||
|
||
### Carte | ||
|
||
```njk | ||
{% raw %} | ||
{% from "components/component.njk" import component with context %} | ||
{{ component("download", { | ||
type: "card", | ||
title: "Nom du fichier", | ||
description: "Description du fichier" | ||
href: "/data/dossier/fichier.ext", | ||
detail: "Format ou extension - 850Ko" | ||
}) }} | ||
{% endraw %} | ||
``` | ||
|
||
### Tuile | ||
|
||
```njk | ||
{% raw %} | ||
{% from "components/component.njk" import component with context %} | ||
{{ component("download", { | ||
type: "tile", | ||
title: "Nom du fichier", | ||
href: "/data/dossier/fichier.ext", | ||
detail: "Format ou extension - 850Ko", | ||
pictogram: "buildings/city-hall.svg" | ||
}) }} | ||
{% endraw %} | ||
``` | ||
|
||
## Rendu | ||
|
||
### Lien | ||
|
||
{% from "components/component.njk" import component with context %} | ||
{{ component("download", { | ||
title: "monde.gpkg", | ||
href: "/data/tutoriels/alimentation-diffusion-simple/monde.gpkg", | ||
detail: "Geopackage - 11,4Mo" | ||
}) }} | ||
|
||
### Carte | ||
|
||
{% from "components/component.njk" import component with context %} | ||
<div> | ||
{{ component("download", { | ||
type: "card", | ||
title: "monde.gpkg", | ||
description: "Pays et régions écologiques mondiales", | ||
href: "/data/tutoriels/alimentation-diffusion-simple/monde.gpkg", | ||
detail: "Geopackage - 11,4Mo" | ||
}) }} | ||
</div> | ||
|
||
<br> | ||
|
||
### Tuile | ||
|
||
{% from "components/component.njk" import component with context %} | ||
<div> | ||
{{ component("download", { | ||
type: "tile", | ||
title: "monde.gpkg", | ||
description: "Pays et régions écologiques mondiales", | ||
href: "/data/tutoriels/alimentation-diffusion-simple/monde.gpkg", | ||
detail: "Geopackage - 11,4Mo", | ||
pictogram: "map/map.svg" | ||
}) }} | ||
</div> | ||
|
||
<br> | ||
|
||
[Voir aussi la page du composant sur le site du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/telechargement-de-fichier){.fr-link .fr-fi-arrow-right-line .fr-link--icon-right} |
This file contains 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