Skip to content

Commit

Permalink
fixed breadcrumb not adding space between non-links
Browse files Browse the repository at this point in the history
  • Loading branch information
Pespiri committed Aug 5, 2021
1 parent fb2f90a commit a3ccaa8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
26 changes: 12 additions & 14 deletions src/components/breadcrumb/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
import { List } from '@equinor/eds-core-react';
import PropTypes from 'prop-types';
import React from 'react';
import { NavLink } from 'react-router-dom';

import './style.css';

const BreadcrumbLink = (link) => {
if (link.to) {
return (
<>
<NavLink className="breadcrumb__link" to={link.to}>
{link.label}
</NavLink>
<span className="breadcrumb__link-space">/</span>
</>
);
}

return <span className="breadcrumb__text">{link.label}</span>;
return link.to ? (
<NavLink className="breadcrumb__link" to={link.to}>
{link.label}
</NavLink>
) : (
<span className="breadcrumb__text">{link.label}</span>
);
};

export const Breadcrumb = ({ links }) => {
const linksRender = links.map((link, idx) => (
<li key={link.to || idx}>{BreadcrumbLink(link)}</li>
<List.Item className="breadcrumb__item" key={link.to || idx}>
{BreadcrumbLink(link)}
</List.Item>
));

return (
<nav className="breadcrumb" role="navigation" aria-label="Page hierarchy">
<ul>{linksRender}</ul>
<List>{linksRender}</List>
</nav>
);
};
Expand Down
13 changes: 7 additions & 6 deletions src/components/breadcrumb/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
display: inline-block;
}

:not(:last-child).breadcrumb__item::after {
content: "/";
color: var(--eds_text__static_icons__tertiary, rgba(111,111,111,1));
padding-left: var(--eds_spacing_medium);
padding-right: var(--eds_spacing_medium);
}

.breadcrumb__text {
color: var(--eds_text__static_icons__tertiary,rgba(111,111,111,1));
}

.breadcrumb__link {
color: var(--eds_interactive_primary__resting);
}

.breadcrumb__link-space {
color: var(--eds_text__static_icons__tertiary, rgba(111,111,111,1));
padding-left: var(--eds_spacing_medium);
padding-right: var(--eds_spacing_medium);
}

0 comments on commit a3ccaa8

Please sign in to comment.