-
+
{title}
-
+
', () => {
test('create information modal', () => {
component = mount(infoModal);
- expect(component.find('h1.fd-modal__title').text()).toEqual(modalInfoTitle);
+ expect(component.find('.fd-modal__title').text()).toEqual(modalInfoTitle);
// close modal
component.find('button.fd-button--light.fd-modal__close').simulate('click');
@@ -114,19 +114,32 @@ describe('
', () => {
test('create confirm modal', () => {
component = mount(confirmModal);
- expect(component.find('h1.fd-modal__title').text()).toEqual(
+ expect(component.find('.fd-modal__title').text()).toEqual(
modalConfirmTitle
);
});
test('create form modal', () => {
component = mount(formModal);
- expect(component.find('h1.fd-modal__title').text()).toEqual(modalFormTitle);
+ expect(component.find('.fd-modal__title').text()).toEqual(modalFormTitle);
});
test('do not show info modal', () => {
component = mount(infoNoShowModal);
- expect(component.find('h1.fd-modal__title').exists()).toBeFalsy();
+ expect(component.find('.fd-modal__title').exists()).toBeFalsy();
+ });
+
+ describe('Modal Headings', () => {
+ test('should allow customization of header level', () => {
+ component = mount(
+
);
+
+ expect(
+ component.find('.fd-modal__title').type()
+ ).toBe('h2');
+ });
});
describe('Prop spreading', () => {
@@ -171,7 +184,7 @@ describe('
', () => {
).toBe('Sample Title');
});
- test('should allow props to be spread to the Modal component\'s h1 element', () => {
+ test('should allow props to be spread to the Modal component\'s header element', () => {
component = mount(
', () => {
);
expect(
- component.find('h1').getDOMNode().attributes['data-sample']
+ component.find('.fd-modal__title').getDOMNode().attributes['data-sample']
.value
).toBe('Sample Title');
});
diff --git a/src/Panel/Panel.test.js b/src/Panel/Panel.test.js
index 1ed7c2507..555c43c36 100644
--- a/src/Panel/Panel.test.js
+++ b/src/Panel/Panel.test.js
@@ -140,6 +140,16 @@ describe('
', () => {
expect(tree).toMatchSnapshot();
});
+ describe('PanelHead', () => {
+ test('should allow customization of header level', () => {
+ const element = mount(
);
+
+ expect(
+ element.find('.fd-panel__title').type()
+ ).toBe('h2');
+ });
+ });
+
describe('Prop spreading', () => {
test('should allow props to be spread to the Panel component', () => {
const element = mount(
);
@@ -181,7 +191,7 @@ describe('
', () => {
).toBe('Sample');
});
- xtest('should allow props to be spread to the PanelHead component\'s h1 element', () => {
+ xtest('should allow props to be spread to the PanelHead component\'s heading element', () => {
// TODO: placeholder for this test description once that functionality is built
});
diff --git a/src/Panel/_PanelHead.js b/src/Panel/_PanelHead.js
index 3076f677e..3a087afb0 100644
--- a/src/Panel/_PanelHead.js
+++ b/src/Panel/_PanelHead.js
@@ -1,18 +1,21 @@
import classnames from 'classnames';
+import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
import PropTypes from 'prop-types';
import React from 'react';
const PanelHead = props => {
- const { title, description, className, ...rest } = props;
+ const { title, description, className, headingLevel, ...rest } = props;
const panelHeadClasses = classnames(
'fd-panel__head',
className
);
+ const HeadingTag = `h${headingLevel}`;
+
return (
- {title ?
{title} : null}
+ {title ?
{title} : null}
{description ?
{description}
: null}
);
@@ -23,9 +26,14 @@ PanelHead.displayName = 'Panel.Head';
PanelHead.propTypes = {
className: PropTypes.string,
description: PropTypes.string,
+ headingLevel: CustomPropTypes.range(2, 6),
title: PropTypes.string
};
+PanelHead.defaultProps = {
+ headingLevel: 3
+};
+
PanelHead.propDescriptions = {
description: 'Localized text for the description of the panel.',
title: 'Localized text for the title of the panel.'
diff --git a/src/Panel/__snapshots__/Panel.test.js.snap b/src/Panel/__snapshots__/Panel.test.js.snap
index fb6268537..3cede033a 100644
--- a/src/Panel/__snapshots__/Panel.test.js.snap
+++ b/src/Panel/__snapshots__/Panel.test.js.snap
@@ -10,11 +10,11 @@ exports[`
create panels 1`] = `
-
Panel Header with Actions
-
+
@@ -64,11 +64,11 @@ exports[` create panels 2`] = `
-
Panel Header with Actions
-
+
create panels 3`] = `
-
Panel Header with Actions
-
+
diff --git a/src/SideNavigation/SideNav.test.js b/src/SideNavigation/SideNav.test.js
index 2d5f5dd94..c8294094f 100644
--- a/src/SideNavigation/SideNav.test.js
+++ b/src/SideNavigation/SideNav.test.js
@@ -326,6 +326,16 @@ describe(' ', () => {
expect(wrapper.state('selectedId')).toEqual('subitem_25');
});
+ describe('SideNavList', () => {
+ test('should allow customization of header level', () => {
+ const element = mount( );
+
+ expect(
+ element.find('.fd-side-nav__title').type()
+ ).toBe('h2');
+ });
+ });
+
describe('Prop spreading', () => {
test('should allow props to be spread to the SideNav component', () => {
const element = mount( );
@@ -356,11 +366,11 @@ describe(' ', () => {
).toBe('Sample');
});
- test('should allow props to be spread to the SideNavList\'s h1 element', () => {
+ test('should allow props to be spread to the SideNavList\'s heading element', () => {
const element = mount( );
expect(
- element.find('h1').getDOMNode().attributes['data-sample'].value
+ element.find('.fd-side-nav__title').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});
diff --git a/src/SideNavigation/_SideNavList.js b/src/SideNavigation/_SideNavList.js
index 31bcc60ef..0c38510ab 100644
--- a/src/SideNavigation/_SideNavList.js
+++ b/src/SideNavigation/_SideNavList.js
@@ -1,4 +1,5 @@
import classnames from 'classnames';
+import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
import PropTypes from 'prop-types';
import React from 'react';
@@ -8,7 +9,7 @@ class SideNavList extends React.Component {
}
render() {
- const { children, className, hasParent, onItemSelect, open, selectedId, title, titleProps, ...rest } = this.props;
+ const { children, className, hasParent, headingLevel, onItemSelect, open, selectedId, title, titleProps, ...rest } = this.props;
const sideNavListClasses = classnames({
'fd-side-nav__list': !hasParent,
'fd-side-nav__sublist': hasParent
@@ -21,6 +22,8 @@ class SideNavList extends React.Component {
className
);
+ const HeadingTag = `h${headingLevel}`;
+
const sideNavList = (
-
+
{title}
-
+
{sideNavList}
);
@@ -62,6 +65,7 @@ SideNavList.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
hasParent: PropTypes.bool,
+ headingLevel: CustomPropTypes.range(2, 6),
open: PropTypes.bool,
selectedId: PropTypes.string,
title: PropTypes.string,
@@ -69,6 +73,10 @@ SideNavList.propTypes = {
onItemSelect: PropTypes.func
};
+SideNavList.defaultProps = {
+ headingLevel: 3
+};
+
SideNavList.propDescriptions = {
hasParent: '_INTERNAL USE ONLY._',
open: '_INTERNAL USE ONLY._',
diff --git a/src/SideNavigation/__snapshots__/SideNav.test.js.snap b/src/SideNavigation/__snapshots__/SideNav.test.js.snap
index bfacc1fba..7c61159fd 100644
--- a/src/SideNavigation/__snapshots__/SideNav.test.js.snap
+++ b/src/SideNavigation/__snapshots__/SideNav.test.js.snap
@@ -73,11 +73,11 @@ exports[`
create side navigation 2`] = `
-
Group Title
-
+
@@ -141,11 +141,11 @@ exports[` create side navigation 2`] = `
-
Group Title
-
+
diff --git a/src/Tile/Tile.test.js b/src/Tile/Tile.test.js
index 53c5a166c..0a29dd4f2 100644
--- a/src/Tile/Tile.test.js
+++ b/src/Tile/Tile.test.js
@@ -183,6 +183,26 @@ describe(' ', () => {
expect(tree).toMatchSnapshot();
});
+ describe('ProductTileContent', () => {
+ test('should allow customization of header level', () => {
+ const element = mount(
+ );
+ expect(
+ element.find('.fd-product-tile__title').type()
+ ).toBe('h2');
+ });
+ });
+
+ describe('TileContent', () => {
+ test('should allow customization of header level', () => {
+ const element = mount(
+ );
+ expect(
+ element.find('.fd-tile__title').type()
+ ).toBe('h2');
+ });
+ });
+
describe('Prop spreading', () => {
test('should allow props to be spread to the Tile component', () => {
const element = mount( );
@@ -200,11 +220,11 @@ describe(' ', () => {
).toBe('Sample');
});
- test('should allow props to be spread to the TileContent component\'s h2 element', () => {
+ test('should allow props to be spread to the TileContent component\'s header element', () => {
const element = mount( );
expect(
- element.find('h2').getDOMNode().attributes['data-sample'].value
+ element.find('.fd-tile__title').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
@@ -240,11 +260,11 @@ describe(' ', () => {
).toBe('Sample');
});
- test('should allow props to be spread to the ProductTileContent component\'s h2 element', () => {
+ test('should allow props to be spread to the ProductTileContent component\'s heading element', () => {
const element = mount( );
expect(
- element.find('h2').getDOMNode().attributes['data-sample'].value
+ element.find('.fd-product-tile__title').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
diff --git a/src/Tile/_ProductTileContent.js b/src/Tile/_ProductTileContent.js
index aebe664f4..c6f632e5e 100644
--- a/src/Tile/_ProductTileContent.js
+++ b/src/Tile/_ProductTileContent.js
@@ -1,18 +1,21 @@
import classnames from 'classnames';
+import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
import PropTypes from 'prop-types';
import React from 'react';
const ProductTileContent = props => {
- const { title, children, className, titleProps, ...rest } = props;
+ const { title, children, className, headingLevel, titleProps, ...rest } = props;
const tileProductContentClasses = classnames(
'fd-product-tile__content',
className
);
+ const HeadingTag = `h${headingLevel}`;
+
return (
-
{title}
+ {title}
{children}
);
@@ -22,8 +25,13 @@ ProductTileContent.displayName = 'ProductTile.Content';
ProductTileContent.propTypes = {
className: PropTypes.string,
+ headingLevel: CustomPropTypes.range(2, 6),
title: PropTypes.string,
titleProps: PropTypes.object
};
+ProductTileContent.defaultProps = {
+ headingLevel: 3
+};
+
export default ProductTileContent;
diff --git a/src/Tile/_TileContent.js b/src/Tile/_TileContent.js
index b5efc5535..771cfa9e5 100644
--- a/src/Tile/_TileContent.js
+++ b/src/Tile/_TileContent.js
@@ -1,18 +1,21 @@
import classnames from 'classnames';
+import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
import PropTypes from 'prop-types';
import React from 'react';
const TileContent = props => {
- const { title, children, className, titleProps, ...rest } = props;
+ const { title, children, className, headingLevel, titleProps, ...rest } = props;
const tileContentClasses = classnames(
'fd-tile__content',
className
);
+ const HeadingTag = `h${headingLevel}`;
+
return (
-
{title}
+ {title}
{children}
);
@@ -23,7 +26,12 @@ TileContent.displayName = 'Tile.Content';
TileContent.propTypes = {
title: PropTypes.string.isRequired,
className: PropTypes.string,
+ headingLevel: CustomPropTypes.range(2, 6),
titleProps: PropTypes.object
};
+TileContent.defaultProps = {
+ headingLevel: 3
+};
+
export default TileContent;
diff --git a/src/Tile/__snapshots__/Tile.test.js.snap b/src/Tile/__snapshots__/Tile.test.js.snap
index 1b74dbbeb..758a5454a 100644
--- a/src/Tile/__snapshots__/Tile.test.js.snap
+++ b/src/Tile/__snapshots__/Tile.test.js.snap
@@ -7,11 +7,11 @@ exports[` create tile component 1`] = `
-
Tile Title
-
+
Tile Description
@@ -26,11 +26,11 @@ exports[`
create tile component 2`] = `
-
Tile Title
-
+
Tile Description
@@ -54,11 +54,11 @@ exports[`
create tile component 3`] = `
-
Tile Title
-
+
Tile Description
@@ -73,11 +73,11 @@ exports[`
create tile component 4`] = `
-
Tile Title
-
+
create tile component 5`] = `
-
Tile Title
-
+
Tile Description
@@ -139,11 +139,11 @@ exports[`
create tile component 6`] = `
-
Tile Title
-
+
create tile component 7`] = `
-
Tile Title
-
+
Tile Description
@@ -213,11 +213,11 @@ exports[`
create tile component 8`] = `
-
Tile Title
-
+
Tile Description
@@ -235,11 +235,11 @@ exports[`
create tile component 9`] = `
-
Tile Title
-
+
Tile Description
@@ -258,11 +258,11 @@ exports[`
create tile component 10`] = `
-
Tile Title
-
+
Tile Description
diff --git a/src/_playground/documentation/Properties/defaults.js b/src/_playground/documentation/Properties/defaults.js
index ad2643cff..d0685d5cd 100644
--- a/src/_playground/documentation/Properties/defaults.js
+++ b/src/_playground/documentation/Properties/defaults.js
@@ -8,6 +8,7 @@ export const defaultPropDescriptions = {
id: 'Value for the `id` attribute on the element.',
inputProps: 'Additional props to be spread to the `
` element.',
labelProps: 'Additional props to be spread to the `
` element.',
+ headingLevel: 'Heading level. `` is reserved for the page title. It should not appear in components.',
listProps: 'Additional props to be spread to the `` element.',
localizedText: 'Localized text to be updated based on location/language.',
modifier: 'Sets a style variation for a modified appearance.',