Skip to content

Commit

Permalink
Merge 10f1153 into 469477a
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccaalpert authored Feb 4, 2019
2 parents 469477a + 10f1153 commit a519e52
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const propTypes = {
const defaultProps = {
children: null,
className: '',
'aria-label': 'breadcrumb'
'aria-label': 'Breadcrumb'
};

const Breadcrumb = ({ className, children, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`Breadcrumb component should render breadcrumb with children 1`] = `
}
<nav
aria-label="breadcrumb"
aria-label="Breadcrumb"
className="pf-c-breadcrumb"
>
<ol
Expand Down Expand Up @@ -71,7 +71,7 @@ exports[`Breadcrumb component should render breadcrumb with className 1`] = `
}
<nav
aria-label="breadcrumb"
aria-label="Breadcrumb"
className="pf-c-breadcrumb className"
>
<ol
Expand All @@ -91,7 +91,7 @@ exports[`Breadcrumb component should render default breadcrumb 1`] = `
}
<nav
aria-label="breadcrumb"
aria-label="Breadcrumb"
className="pf-c-breadcrumb"
>
<ol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface NavProps extends Omit<HTMLProps<HTMLDivElement>, 'onSelect'> {
className?: string;
onSelect?(groupId: number, itemId: number, event: FormEvent<HTMLInputElement>): void;
onToggle?(groupId: number, expanded: boolean, event: FormEvent<HTMLInputElement>): void;
'aria-label': string;
'aria-label'?: string;
}

declare const Nav: FunctionComponent<NavProps>;
Expand Down
8 changes: 5 additions & 3 deletions packages/patternfly-4/react-core/src/components/Nav/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const propTypes = {
/** Callback for when a list is expanded or collapsed */
onToggle: PropTypes.func,
/** Accessibility label */
'aria-label': PropTypes.string.isRequired,
'aria-label': PropTypes.string,
/** Additional props are spread to the container <nav> */
'': PropTypes.any
};
Expand Down Expand Up @@ -50,7 +50,7 @@ class Nav extends React.Component {
}

render() {
const { children, className, ...props } = this.props;
const { 'aria-label': ariaLabel, children, className, ...props } = this.props;

return (
<NavContext.Provider
Expand All @@ -60,7 +60,9 @@ class Nav extends React.Component {
onToggle: (event, groupId, expanded) => this.onToggle(event, groupId, expanded)
}}
>
<nav className={css(styles.nav, className)} {...props}>
<nav className={css(styles.nav, className)}
{...props}
aria-label={ariaLabel ? ariaLabel : typeof this.props.children.props !== 'undefined' && this.props.children.props.variant === 'tertiary' ? 'Local' : 'Global'}>
{children}
</nav>
</NavContext.Provider>
Expand Down
18 changes: 9 additions & 9 deletions packages/patternfly-4/react-core/src/components/Nav/Nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const context = {

test('Default Nav List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList>
{props.items.map(item => (
<NavItem to={item.to} key={item.to}>
Expand All @@ -43,7 +43,7 @@ test('Default Nav List', () => {
test('Default Nav List - Trigger item active update', () => {
window.location.hash = '#link2';
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList>
{props.items.map(item => (
<NavItem to={item.to} key={item.to}>
Expand All @@ -63,7 +63,7 @@ test('Default Nav List - Trigger item active update', () => {

test('Simple Nav List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList variant="simple">
{props.items.map(item => (
<NavItem to={item.to} key={item.to}>
Expand All @@ -79,7 +79,7 @@ test('Simple Nav List', () => {

test('Expandable Nav List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList>
<NavExpandable id="grp-1" title="Section 1">
{props.items.map(item => (
Expand All @@ -98,7 +98,7 @@ test('Expandable Nav List', () => {
test('Expandable Nav List - Trigger toggle', () => {
window.location.hash = '#link2';
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList>
<NavExpandable id="grp-1" title="Section 1" className="expandable-group" isExpanded>
{props.items.map(item => (
Expand Down Expand Up @@ -138,7 +138,7 @@ test('Expandable Nav List with aria label', () => {

test('Nav Grouped List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavGroup id="grp-1" title="Section 1">
<NavList>
{props.items.map(item => (
Expand All @@ -165,7 +165,7 @@ test('Nav Grouped List', () => {

test('Horizontal Nav List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList variant="horizontal">
{props.items.map(item => (
<NavItem to={item.to} key={item.to}>
Expand All @@ -181,7 +181,7 @@ test('Horizontal Nav List', () => {

test('Tertiary Nav List', () => {
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList variant="tertiary">
{props.items.map(item => (
<NavItem to={item.to} key={item.to}>
Expand All @@ -198,7 +198,7 @@ test('Tertiary Nav List', () => {
test('Nav List with custom item nodes', () => {
const CustomNode = () => <div>My custom node</div>;
const view = mount(
<Nav aria-label="Test">
<Nav>
<NavList variant="tertiary">
<NavItem to="/components/nav#link1">
<CustomNode />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ exports[`Default Nav List - Trigger item active update 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -188,13 +187,12 @@ exports[`Default Nav List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -368,13 +366,12 @@ exports[`Expandable Nav List - Trigger toggle 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -620,13 +617,12 @@ exports[`Expandable Nav List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -1112,13 +1108,12 @@ exports[`Horizontal Nav List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -1319,13 +1314,12 @@ exports[`Nav Grouped List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -1602,13 +1596,12 @@ exports[`Nav List with custom item nodes 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Local"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -1684,13 +1677,12 @@ exports[`Simple Nav List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Global"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down Expand Up @@ -1838,13 +1830,12 @@ exports[`Tertiary Nav List 1`] = `
}
<Nav
aria-label="Test"
className=""
onSelect={[Function]}
onToggle={[Function]}
>
<nav
aria-label="Test"
aria-label="Local"
className="pf-c-nav"
onSelect={[Function]}
onToggle={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NavDefaultList extends React.Component {
render() {
const { activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} aria-label="Primary Nav Default Example">
<Nav onSelect={this.onSelect}>
<NavList>
<NavItem to="#default-link1" itemId={0} isActive={activeItem === 0}>
Link 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NavExpandableList extends React.Component {
render() {
const { activeGroup, activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} onToggle={this.onToggle} aria-label="Primary Nav Expandable Example">
<Nav onSelect={this.onSelect} onToggle={this.onToggle}>
<NavList>
<NavExpandable title="Link 1" groupId="grp-1" isActive={activeGroup === 'grp-1'} isExpanded>
<NavItem to="#expandable-1" groupId="grp-1" itemId="grp-1_itm-1" isActive={activeItem === 'grp-1_itm-1'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class NavExpandableTitlesList extends React.Component {
render() {
const { activeGroup, activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} onToggle={this.onToggle} aria-label="Nav Expandable with screen reader headings">
<Nav onSelect={this.onSelect} onToggle={this.onToggle}>
<NavList>
<NavExpandable title="Link 1" srText="SR Link" groupId="grp-1" isActive={activeGroup === 'grp-1'} isExpanded>
<NavItem to="#sr-expandable-1" groupId="grp-1" itemId="grp-1_itm-1" isActive={activeItem === 'grp-1_itm-1'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NavGroupedList extends React.Component {
render() {
const { activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} aria-label="Primary Nav Grouped Example">
<Nav onSelect={this.onSelect}>
<NavGroup title="Section title 1">
<NavItem to="#grouped-1" itemId="grp-1_itm-1" isActive={activeItem === 'grp-1_itm-1'}>
Link 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NavHorizontalList extends React.Component {
const { activeItem } = this.state;
return (
<div style={{ backgroundColor: '#292e34', padding: '1rem' }}>
<Nav onSelect={this.onSelect} aria-label="Primary Nav Horizontal Example">
<Nav onSelect={this.onSelect}>
<NavList variant={NavVariants.horizontal}>
<NavItem to="#horizontal-link1" itemId={0} isActive={activeItem === 0}>
Item 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class NavMixedList extends React.Component {
render() {
const { activeGroup, activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} aria-label="Primary Nav Mixed Example">
<Nav onSelect={this.onSelect}>
<NavList>
<NavItem to="#mixed-1" itemId="itm-1" isActive={activeItem === 'itm-1'}>
Link 1 (not expandable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NavSimpleList extends React.Component {
render() {
const { activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} id="nav-primary-simple" aria-label="Primary Nav, Simple List Example">
<Nav onSelect={this.onSelect} id="nav-primary-simple">
<NavList variant={NavVariants.simple}>
<NavItem to="#simple-link1" itemId={0} isActive={activeItem === 0}>
Link 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NavTertiaryList extends React.Component {
render() {
const { activeItem } = this.state;
return (
<Nav onSelect={this.onSelect} aria-label="Tertiary Example">
<Nav onSelect={this.onSelect}>
<NavList variant={NavVariants.tertiary}>
<NavItem to="#tertiary-link1" itemId={0} isActive={activeItem === 0}>
Link 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const defaultProps = {
showNavToggle: false,
isNavOpen: true,
onNavToggle: () => undefined,
'aria-label': 'Toggle global navigation',
'': ''
'aria-label': "Global navigation",
};

const PageHeader = ({
Expand Down
Loading

0 comments on commit a519e52

Please sign in to comment.