Skip to content

Commit

Permalink
fix(breadcrumb): add example with span tag instead of link without href
Browse files Browse the repository at this point in the history
  • Loading branch information
zellerbaptiste committed May 3, 2023
1 parent c5a447a commit 34d6791
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/component/breadcrumb/example/index.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% const sample = getSample(include); %>

<%- sample('Fil d’Ariane', './sample/breadcrumb', { }, true); %>
<%- sample('Fil d’Ariane avec liens', './sample/sample-a', { }, true); %>

<%- sample('Fil d’Ariane avec <span> en dernier element', './sample/sample-span', { }, true); %>
14 changes: 14 additions & 0 deletions src/component/breadcrumb/example/sample/sample-span.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% const data = {
id: uniqueId('breadcrumb'),
segments: [
{ path: '', label: 'Accueil' },
{ path: 'segment-1', label: 'Segment 1 : lorem ipsum' },
{ path: 'segment-2', label: 'Segment 2 : lorem ipsum' },
{ path: 'segment-4', label: 'Segment 3 : lorem ipsum dolor sit amet' },
{ markup: 'span', label: 'Page Actuelle' }
],
...locals.breadcrumb
}
%>

<%- include('../../template/ejs/breadcrumb.ejs', {breadcrumb: data}); %>
7 changes: 5 additions & 2 deletions src/component/breadcrumb/style/_module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ un padding de 4px et une marge négative en compensation sont mis en place afin
&__link {
vertical-align: top;
position: relative;
@include link-underline;
@include disable-tint;
@include text-style(xs);
@include padding(0);
@include hover-underline;


&:not(:last-child) {
@include link-underline;
}

&[aria-current] {
&:not(button):not([href]) {
pointer-events: none;
Expand Down
8 changes: 5 additions & 3 deletions src/component/breadcrumb/template/ejs/breadcrumb.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<%
let breadcrumb = locals.breadcrumb || {segments : []};
if (breadcrumb.button === undefined) breadcrumb.button = 'Voir le fil d’Ariane';
const markup = breadcrumb.markup || 'a';
%>
<nav role="navigation" class="<%= prefix %>-breadcrumb" aria-label="vous êtes ici :">
Expand All @@ -29,13 +28,16 @@ const markup = breadcrumb.markup || 'a';
const attrs = {};
for (let i = 0; i < breadcrumb.segments.length; i++) {
const segment = breadcrumb.segments[i];
const markup = segment.markup || 'a';
if (segment.path != undefined) path += segment.path + '/';
if (segment.id) attrs.id = segment.id;
if (segment.href) {
attrs['href'] = segment.href;
} else {
if (i === breadcrumb.segments.length - 1) attrs['aria-current'] = 'page';
else if (path !== '') attrs['href'] = path;
if (i === breadcrumb.segments.length - 1) {
attrs['aria-current'] = 'page';
delete attrs['href'];
} else if (path !== '') attrs['href'] = path;
}
%>
<li>
Expand Down

0 comments on commit 34d6791

Please sign in to comment.