Skip to content

Commit

Permalink
✨ feat(notice): ajout de bandeaux d'information importante [DS-3783, …
Browse files Browse the repository at this point in the history
…DS-3357] (#917)

- ajout des bandeaux d'alertes, des bandeaux vigilance météo, et de 2 niveaux génériques (warning et alert)
- mise en situation dans une page
- BC : changement de la structure html pour accueillir une description et un lien en plus du titre
  • Loading branch information
keryanS committed May 31, 2024
1 parent 9d2f642 commit f2745f3
Show file tree
Hide file tree
Showing 27 changed files with 601 additions and 147 deletions.
4 changes: 3 additions & 1 deletion module/color/variable/_box-shadows.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ $values: (
bottom-2-out: 0 2px 0 0 $COLOR,
all-4-in: inset 0 0 0 4px $COLOR,
all-6-in: inset 0 0 0 6px $COLOR,
left-6-in: inset 6px 0 0 0 $COLOR,
top-6-in: inset 0 6px 0 0 $COLOR,
right-6-in: inset -6px 0 0 0 $COLOR,
bottom-6-in: inset 0 -6px 0 0 $COLOR,
left-6-in: inset 6px 0 0 0 $COLOR,
all-8-in: inset 0 0 0 8px $COLOR,
left-10-in: inset 10px 0 0 0 $COLOR,
right-10-in: inset -10px 0 0 0 $COLOR,
Expand Down
1 change: 1 addition & 0 deletions module/color/variable/_decisions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $values: (
system: strong,
),
action-high: (
neutral: strongest (hover: true),
primary: strong (hover: true),
accent: strong (hover: true),
system: strong (hover: true)
Expand Down
11 changes: 11 additions & 0 deletions src/analytics/example/component/notice/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% const sample = getSample(include); %>

<%
let title = 'Vigilance météo rouge';
let desc = 'lorem ispum dolor sit amet, consectetur adipiscing elit. Nullam nec purus nec elit ultricies ultricies.';
let link = {label: 'En savoir plus', blank: true};
%>

<%- sample('Vigilance météo orange', '../../../../component/notice/example/sample/notice-default', {notice: {type: "weather-orange", title: 'Vigilance météo orange', desc:desc, link: {...link, href: 'https://www.meteofrance.fr/', id: uniqueId('link')}}}); %>

<%- sample('Alerte attentat', '../../../../component/notice/example/sample/notice-default', {notice: {type: "attack", title: 'Attentat en cours', desc:desc, link: {...link, href: 'https://interieur.gouv.fr', id: uniqueId('link')}}}); %>
4 changes: 2 additions & 2 deletions src/analytics/script/integration/component/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import integrateLink from './link/integrate';
import integrateInput from './input/integrate';
import integrateModal from './modal/integrate';
import integrateNavigation from './navigation/integrate';
// import integrateNotice from './notice/integrate';
import integrateNotice from './notice/integrate';
import integratePagination from './pagination/integrate';
import integrateQuote from './quote/integrate';
import integrateRadio from './radio/integrate';
Expand Down Expand Up @@ -59,7 +59,7 @@ const integrateComponents = () => {
integrateLink();
integrateModal();
integrateNavigation();
// integrateNotice();
integrateNotice();
integratePagination();
integrateQuote();
integrateRadio();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import api from '../../../../api';
import { NoticeSelector } from './notice-selector';
import { NoticeActionee } from './notice-actionee';
import { NoticeLinkActionee } from './notice-link-actionee';

const integrateNotice = () => {
api.internals.register(NoticeSelector.NOTICE, NoticeActionee);
api.internals.register(NoticeSelector.LINK, NoticeLinkActionee);
};

export default integrateNotice;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ComponentActionee } from '../component-actionee';
import ID from './id';

class NoticeLinkActionee extends ComponentActionee {
constructor () {
super(2);
}

static get instanceClassName () {
return 'NoticeLinkActionee';
}

init () {
this.detectInteractionType();
this.listenActionClick();
}

get label () {
const firstText = this.getFirstText();
if (firstText) return firstText;

return 'lien de bandeau d\'information importante';
}

get component () {
return ID;
}
}

export { NoticeLinkActionee };
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import api from '../../../../api';

export const NoticeSelector = {
NOTICE: api.internals.ns.selector('notice'),
TITLE: api.internals.ns.selector('notice__title')
TITLE: api.internals.ns.selector('notice__title'),
LINK: api.internals.ns.selector('notice a')
};
50 changes: 13 additions & 37 deletions src/component/button/template/ejs/button.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ const button = locals.button || {};
let btnClasses = button.classes || [];
let btnAttrs = button.attributes || {};
btnAttrs.id = button.id || uniqueId('button');
const markup = button.markup || 'button';
btnClasses.push(prefix + '-btn');
let action;
const markup = button.markup || 'button';
switch (markup) {
case 'a':
action = 'link';
break;
default:
action = markup;
break;
}
switch(button.size) {
case 'sm':
Expand Down Expand Up @@ -84,48 +91,17 @@ switch (button.kind) {
break;
}
if (button.disabled === true) {
switch(markup) {
case 'input':
case 'button':
btnAttrs['disabled'] = '';
break;
case 'a':
btnAttrs['aria-disabled'] = 'true';
btnAttrs.role = 'link';
break;
}
} else {
if (button.disabled !== true) {
if (button.onclick) btnAttrs.onclick = button.onclick;
switch (markup) {
case 'a':
btnAttrs.href = button.href || '#[url - à modifier]';
switch (true) {
case button.blank:
btnAttrs = {...targetBlankData(), ...btnAttrs};
break;
case button.self:
btnAttrs.target = '_self';
break;
}
if (button.rel) btnAttrs.rel = button.rel;
break;
}
}
if (button.title) btnAttrs['title'] = button.title;
if (button.type !== undefined) btnAttrs['type'] = button.type;
if (button.tooltip && button.tooltip.id) btnAttrs['aria-describedby'] = button.tooltip.id;
%>
<% if (button.comments) { %><!-- <%= button.comments %> --><% } %>
<<%= markup %> <%- includeClasses(btnClasses) %> <%- includeAttrs(btnAttrs); %> >
<%- button.label %>
</<%= markup %>>
<%- include('../../../../core/template/ejs/action/action', {action: {...button, classes: btnClasses, attributes: btnAttrs, kind: action}}) %>
<% if (button.tooltip) { %>
<%- include('../../../tooltip/template/ejs/tooltip', {tooltip: button.tooltip}); %>
Expand Down
2 changes: 1 addition & 1 deletion src/component/form/example/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<%- sample('Bouton type submit', '../../button/example/sample/button-default', { button: { type:'submit', label: 'Envoyer', title: 'Envoyer le formulaire' }}, true); %>

<%- sample('Input type submit', '../../button/example/sample/button-default', { button: { markup: 'input', label: ' ', title: 'Envoyer le formulaire', type:'submit', attributes: { value: 'Envoyer', title: 'Envoyer le formulaire' }}}, true); %>
<%- sample('Input type submit', '../../button/example/sample/button-default', { button: { markup: 'input', label: 'Envoyer', title: 'Envoyer le formulaire', type:'submit', attributes: { title: 'Envoyer le formulaire' }}}, true); %>



Expand Down
118 changes: 50 additions & 68 deletions src/component/link/template/ejs/link.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -26,99 +26,81 @@
* left : icone à gauche du libellé
* right : icone à droite du libellé
* link.id (string, optional) : id du lien
* link.attributes (object, optional) : attributs spécifiques à rajouter sur le composant
* link.classes (array, optional) : classes spécifiques à rajouter sur le composant
* link.assess (bool | string, optional) : si true, ajoute l'attribut permettant le remplissage automatique des informations du fichier à télécharger. Si string, ajoute l'attribut avec la valeur de la string (ex: "bytes" pour les poids en bytes)
* link.hreflang (string, optional) : code langue du fichier à télécharger
%>
<% eval(include('../../../../core/index.ejs')); %>
<%
const link = locals.link || {};
let linkClasses = link.classes || [];
let linkAttrs = link.attributes || {};
const linkClasses = link.classes || [];
const linkAttrs = link.attributes || {};
let label = link.label || 'lorem ipsum';
const disabled = link.disabled === true;
linkAttrs.id = link.id || uniqueId('link');
linkClasses.push(prefix + '-link');
let action;
const markup = link.markup || 'a';
if (link.assess === true) {
linkAttrs[`data-${prefix}-assess-file`] = ''
} else if (typeof(link.assess) === 'string') {
linkAttrs[`data-${prefix}-assess-file`] = link.assess
switch (markup) {
case 'a':
action = 'link';
break;
default:
action = markup;
break;
}
if (link.hreflang) linkAttrs.hreflang = link.hreflang;
if (link.download === true) {
linkClasses.push(prefix + '-link--download');
switch (action) {
case 'link':
if (link.rel) linkAttrs.rel = link.rel;
if (link.hreflang) linkAttrs.hreflang = link.hreflang;
if (link.download) {
linkAttrs.download = link.download;
linkClasses.push(prefix + '-link--download');
}
if (link.assess === true) {
linkAttrs[`data-${prefix}-assess-file`] = ''
} else if (typeof(link.assess) === 'string') {
linkAttrs[`data-${prefix}-assess-file`] = link.assess
}
break;
}
linkClasses.push(prefix + '-link');
linkAttrs.id = link.id || uniqueId('link');
switch (link.size) {
case 'sm':
linkClasses.push(prefix + '-link--sm');
break;
case 'sm':
linkClasses.push(prefix + '-link--sm');
break;
case 'lg':
linkClasses.push(prefix + '-link--lg');
break;
case 'lg':
linkClasses.push(prefix + '-link--lg');
break;
}
if (link.icon !== undefined) linkClasses.push(`${prefix}-icon-${link.icon}`);
if (link.iconPlace !== undefined) {
switch (link.iconPlace) {
case 'left':
linkClasses.push(`${prefix}-link--icon-left`);
break;
case 'right':
linkClasses.push(`${prefix}-link--icon-right`);
break;
}
}
if (link.disabled === true) {
switch (markup) {
case 'input':
case 'button':
linkAttrs['disabled'] = '';
break;
case 'a':
linkAttrs['aria-disabled'] = 'true';
linkAttrs.role = 'link';
linkAttrs.href = undefined;
break;
}
} else {
switch (markup) {
case 'a':
linkAttrs.href = link.href || '[url - à modifier]';
switch (true) {
case link.download:
linkAttrs.download = '';
break;
case link.blank:
linkAttrs = {...targetBlankData(), ...linkAttrs};
break;
case link.self:
linkAttrs.target = '_self';
break;
}
if (link.rel) linkAttrs.rel = link.rel;
break;
}
switch (link.iconPlace) {
case 'left':
linkClasses.push(`${prefix}-link--icon-left`);
break;
case 'right':
linkClasses.push(`${prefix}-link--icon-right`);
break;
}
}
if (link.detail) {
label += ` <span class="${prefix}-link__detail">${link.detail}</span>`;
label += ` <span class="${prefix}-link__detail">${link.detail}</span>`;
}
%>

<<%= markup %> <%- includeClasses(linkClasses); %> <%- includeAttrs(linkAttrs); %> ><%- label %></<%= markup %>>
<%- include('../../../../core/template/ejs/action/action', {action: {...link, classes: linkClasses, attributes: linkAttrs, kind: action, label: label, disabled: disabled}}) %>
7 changes: 7 additions & 0 deletions src/component/notice/.package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ doc: https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bande
style:
- core
- button
example:
style:
- header
- navigation
- breadcrumb
- search
- skiplink
40 changes: 30 additions & 10 deletions src/component/notice/example/index.ejs
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
<%
const sample = getSample(include);
%>

<%- section('Bandeau d\'information importante', 'Seul le bandeau de type information est disponible pour le moment. <br> Le titre est défini par la classe "fr-notice__title", la balise &#60;p&#62; peut être remplacée par un niveau de titre hx suivant le contexte.<br>Le bandeau doit être placé au début du contenu de la page, pour être le premier élément au clique sur le lien d\'évitement "aller au contenu".', 0, true); %>
<% const sample = getSample(include); %>

<%- sample('Bandeau d\'information importante simple', './sample/notice-default', {notice: {type: "info", title: "Titre du bandeau d'information"}}, true, './layout.ejs'); %>

<%- sample('Bandeau d\'information importante avec bouton fermer', './sample/notice-dismissable', {notice: {type: "info", title: "Titre du bandeau"}}, true, './layout.ejs'); %>
<%
const elements = [
{
title: 'Contenu',
path: 'sample-content'
},
{
title: 'Bandeaux génériques',
path: 'sample-generic'
},
{
title: 'Bandeaux météo',
path: 'sample-meteo'
},
{
title: 'Bandeaux d\'alertes',
path: 'sample-alert'
},
{
title: 'Mise en situation',
path: 'sample-header'
},
];
<%- sample('Bandeau d\'information importante avec lien', './sample/notice-dismissable', {notice: {type: "info", title: `Titre du bandeau, <a href='#' ${includeAttrs(targetBlankData())}>lien au fil du texte</a>`}}, true, './layout.ejs'); %>
const accordions = [];
<%- sample('Bandeau d\'information importante avec titre long', './sample/notice-dismissable', {notice: {type: "info", title: `Titre de bandeau très long, pour tester le comportement du composant avec un texte très long, et un <a href='#' ${includeAttrs(targetBlankData())}>lien au fil du texte</a> lorem ipsum dolor sit lorem ipsum dolor sit.`}}, true, './layout.ejs'); %>
for (let element of elements) { %>
<%- include(`./sample/${element.path}`); %>
<br><br><br><br>
<% }
%>
Loading

0 comments on commit f2745f3

Please sign in to comment.