diff --git a/src/analytics/example/attribute/index.ejs b/src/analytics/example/attribute/index.ejs index 1584a5f327..acdac88d01 100644 --- a/src/analytics/example/attribute/index.ejs +++ b/src/analytics/example/attribute/index.ejs @@ -14,7 +14,7 @@

lien externe

- -analytics-click="libellé envoyé à l'analytics" id="attr-external" target="_blank" >libellé du lien + -analytics-click="libellé envoyé à l'analytics" id="attr-external" <%- includeAttrs(targetBlankData()) %>>libellé du lien
diff --git a/src/analytics/example/component/quote/index.ejs b/src/analytics/example/component/quote/index.ejs index 09aa5fae26..b9f60e90f7 100644 --- a/src/analytics/example/component/quote/index.ejs +++ b/src/analytics/example/component/quote/index.ejs @@ -1,5 +1,5 @@ <% const sample = getSample(include); %>
- <%- sample('Exemple de citation', '../../../../component/quote/example/sample/quote-default', {quote: {id: uniqueId('quote'), sources: ['Ouvrage', 'Détail 1', 'Détail 2', 'Détail 3', 'Détail 4']}}); %> + <%- sample('Exemple de citation', '../../../../component/quote/example/sample/quote-default', {quote: {id: uniqueId('quote'), sources: ['Ouvrage', 'Détail 1', 'Détail 2', 'Détail 3', `Détail 4`]}}); %>
diff --git a/src/component/button/template/ejs/button.ejs b/src/component/button/template/ejs/button.ejs index 70d4a3bfd7..d1e5f00450 100644 --- a/src/component/button/template/ejs/button.ejs +++ b/src/component/button/template/ejs/button.ejs @@ -104,7 +104,7 @@ if (button.disabled === true) { btnAttrs.href = button.href || '#[url - à modifier]'; switch (true) { case button.blank: - btnAttrs.target = '_blank'; + btnAttrs = {...targetBlankData(), ...btnAttrs}; break; case button.self: diff --git a/src/component/card/example/sample/card-default.ejs b/src/component/card/example/sample/card-default.ejs index 3416a0cfdc..540d608fcf 100755 --- a/src/component/card/example/sample/card-default.ejs +++ b/src/component/card/example/sample/card-default.ejs @@ -51,10 +51,7 @@ if (card.content) { data.content.attributes = card.content.attributes ?? {}; if (card.content.assess) data.content.assess = card.content.assess; if (card.content.disabled) data.content.disabled = card.content.disabled; - if (card.content.blank === true) { - data.content.blank = card.content.blank; - data.content.attributes.title = card.content.attributes?.title ? card.content.attributes.title : `${contentPlaceholder('Intitulé')} - ${getText('blank')}`; - } + if (card.content.blank === true) data.content.blank = card.content.blank; if (card.content.lang) data.content.lang = card.content.lang; if (card.content.description !== false) data.content.description = card.content.description || lorem('', 160); diff --git a/src/component/card/template/ejs/content.ejs b/src/component/card/template/ejs/content.ejs index fbc5a01da4..d42836a870 100644 --- a/src/component/card/template/ejs/content.ejs +++ b/src/component/card/template/ejs/content.ejs @@ -37,7 +37,7 @@ const startDetails = content.details ? content.details.filter(detail => !detail. const markup = content.markup || 'h3'; const hasLink = !content.noLink; const href = content.href || '#'; -const attributes = content.attributes || {}; +let attributes = content.attributes || {}; if (content.assess === true) { attributes[`data-${prefix}-assess-file`] = ''; } else if (typeof(content.assess) === 'string') { @@ -52,7 +52,7 @@ if (content.disabled !== true) { if (content.lang) attributes.hreflang = content.lang; if (content.downloadable === true) attributes.download = ''; if (typeof(content.downloadable) === 'string') attributes.download = content.downloadable; -if (content.blank === true) attributes.target = '_blank'; +if (content.blank === true) attributes = { ...targetBlankData(), ...attributes}; switch (true) { case content.badgesGroup !== undefined : diff --git a/src/component/display/deprecated/example/index.ejs b/src/component/display/deprecated/example/index.ejs index 2c62b9bf71..c047bbc27a 100644 --- a/src/component/display/deprecated/example/index.ejs +++ b/src/component/display/deprecated/example/index.ejs @@ -57,7 +57,7 @@ let dataFooter = { } } ], - copyright: 'Sauf mention contraire, tous les contenus de ce site sont sous licence etalab-2.0' + copyright: `Sauf mention contraire, tous les contenus de ce site sont sous licence etalab-2.0` } } %> diff --git a/src/component/display/example/index.ejs b/src/component/display/example/index.ejs index eb0c4889d2..62672f02f1 100644 --- a/src/component/display/example/index.ejs +++ b/src/component/display/example/index.ejs @@ -53,7 +53,7 @@ let dataFooter = { attributes: attrModal } ], - copyright: 'Sauf mention contraire, tous les contenus de ce site sont sous licence etalab-2.0' + copyright: `Sauf mention contraire, tous les contenus de ce site sont sous licence etalab-2.0` } } %> diff --git a/src/component/footer/example/sample/footer.ejs b/src/component/footer/example/sample/footer.ejs index fde7bc9228..c3f33e7e87 100644 --- a/src/component/footer/example/sample/footer.ejs +++ b/src/component/footer/example/sample/footer.ejs @@ -40,7 +40,7 @@ if (footer.bottom === true) data.bottom = { {label: 'Données personnelles', url: footer.href}, {label: 'Gestion des cookies', url: footer.href} ], - copyright: 'Sauf mention explicite de propriété intellectuelle détenue par des tiers, les contenus de ce site sont proposés sous licence etalab-2.0' + copyright: `Sauf mention explicite de propriété intellectuelle détenue par des tiers, les contenus de ce site sont proposés sous licence etalab-2.0` }; %> diff --git a/src/component/footer/template/ejs/content.ejs b/src/component/footer/template/ejs/content.ejs index fe9795c3cf..15cf0bda15 100644 --- a/src/component/footer/template/ejs/content.ejs +++ b/src/component/footer/template/ejs/content.ejs @@ -19,7 +19,7 @@ attributes.id = uniqueId('footer__content-link'); %> <% } %> diff --git a/src/component/link/deprecated/template/ejs/link.ejs b/src/component/link/deprecated/template/ejs/link.ejs index f7c8d36a89..0384d31db9 100644 --- a/src/component/link/deprecated/template/ejs/link.ejs +++ b/src/component/link/deprecated/template/ejs/link.ejs @@ -81,7 +81,7 @@ if (link.disabled === true) { linkAttrs.href = link.href || '[url - à modifier]'; switch (true) { case link.blank: - linkAttrs.target = '_blank'; + linkAttrs = {...targetBlankData(), ...linkAttrs}; break; case link.self: diff --git a/src/component/link/template/ejs/link.ejs b/src/component/link/template/ejs/link.ejs index e4b368ef28..e8280046f6 100644 --- a/src/component/link/template/ejs/link.ejs +++ b/src/component/link/template/ejs/link.ejs @@ -104,7 +104,7 @@ if (link.disabled === true) { break; case link.blank: - linkAttrs.target = '_blank'; + linkAttrs = {...targetBlankData(), ...linkAttrs}; break; case link.self: diff --git a/src/component/navigation/template/ejs/link.ejs b/src/component/navigation/template/ejs/link.ejs index bc657b7f22..4220206bdb 100644 --- a/src/component/navigation/template/ejs/link.ejs +++ b/src/component/navigation/template/ejs/link.ejs @@ -1,25 +1,27 @@ <%# # paramètres navigation menu link -* menu.label (string, required) : label du lien +* link.label (string, required) : label du lien -* menu.href (string, required) : url du lien +* link.id (string, required) : id du lien -* menu.target (string, optional) [default: '_self'] : tableau d'éléments de navigation ('_blank' ou '_self') +* link.href (string, required) : url du lien -* menu.active (boolean, optional) : si true l'élément est actif +* link.blank (boolean, optional) [default: false] : si true, target '_blank' -* menu.isPage (boolean, optional) : si true aria-current: 'page', sinon aria-current: 'true' +* link.active (boolean, optional) : si true l'élément est actif + +* link.isPage (boolean, optional) : si true aria-current: 'page', sinon aria-current: 'true' %> <% let link = locals.link || {}; -const attrs = { +let attrs = { href: link.href, - target: link.target || '_self', id: link.id } +if (link.blank) attrs = {...targetBlankData(), ...attrs}; if (link.active) attrs['aria-current'] = link.isPage ? 'page' : 'true'; diff --git a/src/component/notice/example/index.ejs b/src/component/notice/example/index.ejs index 3bb9b353b9..b0154c3b62 100755 --- a/src/component/notice/example/index.ejs +++ b/src/component/notice/example/index.ejs @@ -8,6 +8,6 @@ const sample = getSample(include); <%- sample('Bandeau d\'information importante avec bouton fermer', './sample/notice-dismissable', {notice: {type: "info", title: "Titre du bandeau"}}, true, './layout.ejs'); %> -<%- sample('Bandeau d\'information importante avec lien', './sample/notice-dismissable', {notice: {type: "info", title: "Titre du bandeau, lien au fil du texte"}}, true, './layout.ejs'); %> +<%- sample('Bandeau d\'information importante avec lien', './sample/notice-dismissable', {notice: {type: "info", title: `Titre du bandeau, lien au fil du texte`}}, true, './layout.ejs'); %> -<%- 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 lien au fil du texte lorem ipsum dolor sit lorem ipsum dolor sit."}}, true, './layout.ejs'); %> +<%- 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 lien au fil du texte lorem ipsum dolor sit lorem ipsum dolor sit.`}}, true, './layout.ejs'); %> diff --git a/src/component/quote/example/sample/quote-default.ejs b/src/component/quote/example/sample/quote-default.ejs index f742ec7037..62d276d666 100755 --- a/src/component/quote/example/sample/quote-default.ejs +++ b/src/component/quote/example/sample/quote-default.ejs @@ -6,7 +6,7 @@ let data = { size: quote.size || undefined, author: quote.author || 'Auteur', href: quote.href || contentPlaceholder('https://lien-vers-la-source.fr'), - sources: quote.sources || ['Ouvrage', 'Détail 1', 'Détail 2', 'Détail 3', 'Détail 4'], + sources: quote.sources || ['Ouvrage', 'Détail 1', 'Détail 2', 'Détail 3', `Détail 4`], }; %> diff --git a/src/component/tag/template/ejs/tag.ejs b/src/component/tag/template/ejs/tag.ejs index c144a456d3..3a571e7f11 100644 --- a/src/component/tag/template/ejs/tag.ejs +++ b/src/component/tag/template/ejs/tag.ejs @@ -46,33 +46,33 @@ if (tag.accent !== undefined) tagClasses.push(prefix + '-tag--' + tag.accent); switch(tag.size) { case 'sm': - tagClasses.push(prefix + '-tag--sm'); + tagClasses.push(prefix + '-tag--sm'); break; } switch(tag.type) { case 'clickable': - if (tag.markup === undefined) tag.markup = 'a'; - if (tag.disabled !== true) { - tagAttrs.href = tag.href || contentPlaceholder('url'); - switch (true) { - case tag.blank: - tagAttrs.target = '_blank'; - break; - case tag.self: - tagAttrs.target = '_self'; - break; - } + if (tag.markup === undefined) tag.markup = 'a'; + if (tag.disabled !== true) { + tagAttrs.href = tag.href || contentPlaceholder('url'); + switch (true) { + case tag.blank: + tagAttrs = {...targetBlankData(), ...tagAttrs}; + break; + case tag.self: + tagAttrs.target = '_self'; + break; } + } break; case 'pressable': - if (tag.markup === undefined) tag.markup = 'button'; - tagAttrs["aria-pressed"] = tag.pressed === true ? 'true' : 'false'; + if (tag.markup === undefined) tag.markup = 'button'; + tagAttrs["aria-pressed"] = tag.pressed === true ? 'true' : 'false'; break; case 'dismissible': - if (tag.markup === undefined) tag.markup = 'button'; - tagClasses.push(prefix + '-tag--dismiss'); - tagAttrs["aria-label"] = 'Retirer ' + contentPlaceholder('le filtre ' + tag.label); + if (tag.markup === undefined) tag.markup = 'button'; + tagClasses.push(prefix + '-tag--dismiss'); + tagAttrs["aria-label"] = 'Retirer ' + contentPlaceholder('le filtre ' + tag.label); break; default: if (tag.markup === undefined) tag.markup = 'p'; @@ -83,12 +83,12 @@ if (tag.icon !== undefined) tagClasses.push(prefix + '-icon-' + tag.icon); if (tag.iconPlace !== undefined) switch(tag.iconPlace) { case 'left': - tagClasses.push(prefix + '-tag--icon-left'); - break; + tagClasses.push(prefix + '-tag--icon-left'); + break; case 'right': - tagClasses.push(prefix + '-tag--icon-right'); - break; + tagClasses.push(prefix + '-tag--icon-right'); + break; } if (tag.disabled === true) { diff --git a/src/component/tile/example/sample/tile-default.ejs b/src/component/tile/example/sample/tile-default.ejs index abfe4bf411..5ce66d0260 100755 --- a/src/component/tile/example/sample/tile-default.ejs +++ b/src/component/tile/example/sample/tile-default.ejs @@ -46,10 +46,7 @@ if (tile.content) { data.content.attributes = tile.content.attributes ?? {}; if (tile.content.assess) data.content.assess = tile.content.assess; if (tile.content.lang) data.content.lang = tile.content.lang; - if (tile.content.blank === true) { - data.content.blank = tile.content.blank; - data.content.attributes.title = tile.content.attributes?.title ? tile.content.attributes.title : `${contentPlaceholder('Intitulé')} - ${getText('blank')}`; - } + if (tile.content.blank === true) data.content.blank = tile.content.blank; if (tile.content.disabled) data.content.disabled = tile.content.disabled; diff --git a/src/component/tile/style/module/_default.scss b/src/component/tile/style/module/_default.scss index 8567b150e6..a97a18af91 100644 --- a/src/component/tile/style/module/_default.scss +++ b/src/component/tile/style/module/_default.scss @@ -53,7 +53,7 @@ &#{ns(enlarge-link)} { #{ns(tile)}__title { a { - @include icon(arrow-right-line, md, after) { + @include icon-size(md) { @include absolute(null, 8v, 9v); } } @@ -86,10 +86,12 @@ background-size: 100% spacing.space(1v); background-repeat: no-repeat; } + + @include icon(arrow-right-line, md, after); } @include target-blank { - @include icon(external-link-line, sm, after); + @include icon(external-link-line, null, after); } } diff --git a/src/component/tile/template/ejs/content.ejs b/src/component/tile/template/ejs/content.ejs index 2681c8bbb6..8f6f7445fb 100644 --- a/src/component/tile/template/ejs/content.ejs +++ b/src/component/tile/template/ejs/content.ejs @@ -32,7 +32,7 @@ let start = {}; const markup = content.markup || 'h3'; const href = content.href || '#'; -const attributes = content.attributes || {}; +let attributes = content.attributes || {}; const hasLink = !content.noLink; if (content.assess === true) { attributes[`data-${prefix}-assess-file`] = ''; @@ -48,7 +48,7 @@ if (content.disabled !== true) { if (content.lang) attributes.hreflang = content.lang; if (content.downloadable === true) attributes.download = ''; if (typeof(content.downloadable) === 'string') attributes.download = content.downloadable; -if (content.blank === true) attributes.target = '_blank'; +if (content.blank === true) attributes = {...targetBlankData(), ...attributes}; if (content.badgesGroup) start.badgesGroup = content.badgesGroup; if (content.tagsGroup) start.tagsGroup = content.tagsGroup; diff --git a/src/core/example/link/link-raw/index.ejs b/src/core/example/link/link-raw/index.ejs index b04618cdb8..cbcfdf95be 100644 --- a/src/core/example/link/link-raw/index.ejs +++ b/src/core/example/link/link-raw/index.ejs @@ -7,9 +7,9 @@ <%- sample({ title: 'Lien brut', subtitle: rawSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien interne`} }, true); %> - <%- sample({ title: 'Lien externe brut', subtitle: rawSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien externe - nouvelle fenêtre`} }, true); %> + <%- sample({ title: 'Lien externe brut', subtitle: rawSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien externe - nouvelle fenêtre`} }, true); %> - <%- sample( { title: 'Exemple sur plusieurs blocs de texte', subtitle: rawWrapperSubtitle}, '../sample/blocks', { classes: [`${prefix}-raw-link`], paragraphes: [ {insert: `lien interne`}, {insert: `lien externe - nouvelle fenêtre`}] }, true); %> + <%- sample({ title: 'Exemple sur plusieurs blocs de texte', subtitle: rawWrapperSubtitle}, '../sample/blocks', { classes: [`${prefix}-raw-link`], paragraphes: [ {insert: `lien interne`}, {insert: `lien externe - nouvelle fenêtre`}] }, true); %> <%- sample({ title: 'Exemple d\'utilisation avec une librairie externe', subtitle: rawWrapperSubtitle }, '../sample/library', { classes: [`${prefix}-raw-link`] }, true); %>
diff --git a/src/core/example/link/link-reset/index.ejs b/src/core/example/link/link-reset/index.ejs index 10cc8613cb..2a8c458ed1 100644 --- a/src/core/example/link/link-reset/index.ejs +++ b/src/core/example/link/link-reset/index.ejs @@ -7,9 +7,9 @@ <%- sample({ title: 'Lien réinitialisé', subtitle: resetSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien interne`} }, true); %> - <%- sample({ title: 'Lien externe réinitialisé', subtitle: resetSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien externe - nouvelle fenêtre`} }, true); %> + <%- sample({ title: 'Lien externe réinitialisé', subtitle: resetSubtitle }, '../../reset/sample/paragraph', { paragraph: {insert: `lien externe - nouvelle fenêtre`} }, true); %> - <%- sample( { title: 'Exemple sur plusieurs blocs de texte', subtitle: `Utilisation de la classe ${prefix}-reset-link sur un wrapper pour réinitialiser le style des liens.`}, '../sample/blocks', { classes: [`${prefix}-reset-link`], paragraphes: [ {insert: `lien interne`}, {insert: `lien externe - nouvelle fenêtre`}] }, true); %> + <%- sample({ title: 'Exemple sur plusieurs blocs de texte', subtitle: `Utilisation de la classe ${prefix}-reset-link sur un wrapper pour réinitialiser le style des liens.`}, '../sample/blocks', { classes: [`${prefix}-reset-link`], paragraphes: [ {insert: `lien interne`}, {insert: `lien externe - nouvelle fenêtre`}] }, true); %> <%- sample({ title: 'Exemple d\'utilisation avec une librairie externe', subtitle: resetWrapperSubtitle }, '../sample/library', { classes: [`${prefix}-reset-link`] }, true); %> diff --git a/src/core/example/reset/index.ejs b/src/core/example/reset/index.ejs index 9e3b8c24e9..5b128a3aba 100644 --- a/src/core/example/reset/index.ejs +++ b/src/core/example/reset/index.ejs @@ -24,7 +24,7 @@ let ol = { <%- sample('Test de paragraphe et de lien interne :', './sample/paragraph', { paragraph: {insert: 'lien interne'} }, true); %> -<%- sample('Test de paragraphe et de lien externe :', './sample/paragraph', { paragraph: {insert: 'lien externe - nouvelle fenêtre'} }, true); %> +<%- sample('Test de paragraphe et de lien externe :', './sample/paragraph', { paragraph: {insert: `lien externe - nouvelle fenêtre`} }, true); %> <%- sample('Test de liste non-ordonnée:', './sample/ul', {list:ul}, true); %> diff --git a/tool/example/decorator.ejs b/tool/example/decorator.ejs index b6ef90dd3b..ab7de08042 100644 --- a/tool/example/decorator.ejs +++ b/tool/example/decorator.ejs @@ -263,6 +263,17 @@ const errorData = (error) => { locals.errorData = errorData; +const targetBlankData = () => { + const attr = {}; + attr.target = '_blank'; + attr.rel = 'noopener'; + attr.title = `${contentPlaceholder('Intitulé')} - ${getText('blank')}`; + return attr; +} + +locals.targetBlankData = targetBlankData; + + const randomContent = (types = ['title', 'img', 'text', 'list'], id) => { let content = ''; if (sampling) return content; diff --git a/tool/example/heading.ejs b/tool/example/heading.ejs index 111bd8989e..bef2888356 100644 --- a/tool/example/heading.ejs +++ b/tool/example/heading.ejs @@ -17,7 +17,7 @@ <% for (const d of doc) { %> -
  • <%= d.title %>
  • +
  • <%= d.title %>
  • <% } %> @@ -27,7 +27,7 @@ case typeof doc === 'string': %> - Documentation + Documentation <% break; }