Skip to content

Commit

Permalink
refactor: clean breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Dec 17, 2018
1 parent 7289727 commit 53fa779
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
20 changes: 16 additions & 4 deletions src/BreadCrumb.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import React from 'react';
import PropTypes from 'prop-types';

import { injectStyles } from './utils';
import { injectStyles, classNames } from './utils';
import styles from './theme/components/BreadCrumb.styl';

class BreadCrumb extends React.Component {

static propTypes = {
items: PropTypes.array,
theme: PropTypes.string,
animateItem: PropTypes.func,
}

static defaultProps = {
items: [],
theme: 'default',
animateItem: item => item,
}

constructor(props) {
Expand All @@ -22,12 +26,20 @@ class BreadCrumb extends React.Component {
}

render() {
const { items } = this.props;
const { items, className, theme, animateItem, ...rest } = this.props;

return (
<div className="junipero junipero-bread-crumb">
<div
{ ...rest }
className={classNames(
'junipero',
'junipero-bread-crumb',
'theme-' + theme,
className,
)}
>
{items.map((item, index) =>
<span key={index}>{item}</span>
animateItem(<span key={index}>{item}</span>, index)
)}
</div>
);
Expand Down
18 changes: 14 additions & 4 deletions src/theme/components/BreadCrumb.styl
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@import "../utils/colors"

.junipero.junipero-bread-crumb
display: inline
cursor: default

span
color: $color-shuttle-gray

&:after
content: ">"
margin: 0 5px
Expand All @@ -16,7 +13,20 @@

&:last-child
font-weight: bold
color: $color-midnight

&:after
display: none

&.theme-none
span
color: $color-shuttle-gray

&:last-child
color: $color-midnight

&.theme-default
span
color: $color-midnight

&:last-child
color: $color-eastern-blue

0 comments on commit 53fa779

Please sign in to comment.