Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implementing Breadcrumb component. #460

Merged
merged 5 commits into from
Dec 26, 2018

Conversation

leyanessantiago
Copy link
Collaborator

fixes #430

import React from 'react';
import PropTypes from 'prop-types';
import './styles.css';

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the description to the component

@coveralls
Copy link

coveralls commented Dec 22, 2018

Pull Request Test Coverage Report for Build 883

  • 9 of 9 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.09%) to 77.918%

Totals Coverage Status
Change from base Build 874: 0.09%
Covered Lines: 1296
Relevant Lines: 1593

💛 - Coveralls

import Breadcrumb from './../index';

describe('<Breadcrumb/>', () => {
it('should fallback to href to href="javascript:void(0);" if the prop is not provided', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should fallback the href prop to href="javascript:void(0);" if the prop is not provided

it('should fallback to href to href="javascript:void(0);" if the prop is not provided', () => {
const component = mount(<Breadcrumb label="index" />);

expect(component.find('a[href="javascript:void(0);"]').exists()).toBe(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more descriptive:
expect(component.find('a').prop('href')).toBe('javascript:void(0);')


expect(component.find('a[href="javascript:void(0);"]').exists()).toBe(true);
});
it('should fallback to href to href passed', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should set the href passed

it('should fallback to href to href passed', () => {
const component = mount(<Breadcrumb label="index" href="index" />);

expect(component.find('a[href="index"]').exists()).toBe(true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ^^


expect(component.find('a').text()).toBe('index');
});
it('should set the label passed as children', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is twice

import PropTypes from 'prop-types';
import classnames from 'classnames';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEllipsisH } from '@fortawesome/free-solid-svg-icons';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need to use internals icon for the component since fontawesome is not a library dependency. Ask for icons to @TahimiLeonBravo.

label,
onClick,
disabled,
overflowMenu,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the api doc I don't see this prop. This is not needed, if we need this then pass a ButtonMenu direct as children of the Breadcrumbs, but this case is not used commonly.

@@ -0,0 +1,64 @@
##### breadcrumb

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You put more examples in here and I think that is more needed in Breadcrumbs. It is like Tabset and Tab.
Also remove the example with the overflow menu.

}

.rainbow-breadcrumb-disabled > a {
color: #d2d4de !important;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to not use !important

import Breadcrumb from './../../Breadcrumb/index';

describe('<Breadcrumbs/>', () => {
it('should have a aria-label attribute for accessibility', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test for:
role="navigation" in nav element
Also add a11y test

} = props;

return (
<nav aria-label="Breadcrumbs" style={style} className={className}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you left:
role="navigation"

* This prop that should not be visible in the documentation.
* @ignore
*/
children: PropTypes.node,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children: PropTypes.oneOfType([
        PropTypes.arrayOf(PropTypes.node),
        PropTypes.object,
    ]),

Breadcrumbs.defaultProps = {
className: undefined,
style: undefined,
children: null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children: []

@@ -0,0 +1,94 @@
/* eslint-disable import/no-extraneous-dependencies,no-script-url */
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export the component in the root index

@@ -0,0 +1,42 @@
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export the component in the root index


Breadcrumb.propTypes = {
/** The text label for the breadcrumb. */
label: PropTypes.string.isRequired,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember that the label must be a string or node

it('should be accessible', async () => {
expect.assertions(1);
const html = ReactDOMServer.renderToString(
<Breadcrumbs activeTabName="tab-1">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove activeTabName

@LeandroTorresSicilia LeandroTorresSicilia merged commit 646a0cd into master Dec 26, 2018
@TahimiLeonBravo TahimiLeonBravo deleted the breadcrumb-component branch September 23, 2019 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: implement Breadcrumb component
4 participants