Skip to content

Commit 1cd93df

Browse files
author
Hans Oksendahl
committed
Moved SLDSBreadCrumb to its own component removed randomId function.
1 parent 64c1813 commit 1cd93df

File tree

24 files changed

+62030
-47
lines changed

24 files changed

+62030
-47
lines changed

components/SLDSPageHeader/BreadCrumb/index.js renamed to components/SLDSBreadCrumb/index.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { Component } from 'react';
2-
import randomId from '../randomId';
32

43
const displayName = 'SLDSBreadCrumb';
54
const propTypes = {
@@ -20,12 +19,11 @@ class SLDSBreadCrumb extends Component {
2019
assistiveText,
2120
trail,
2221
} = this.props;
23-
const id = `SLDSBreadCrumb.${randomId()}`;
2422
let trailElement;
2523

2624
const renderTrail = () => {
2725
const breadCrumbTrail = trail.map((crumb, i) => {
28-
const crumbId = `${id}.${i}`;
26+
const crumbId = `SLDSBreadCrumb.${i}`;
2927

3028
return (
3129
<li
@@ -36,7 +34,7 @@ class SLDSBreadCrumb extends Component {
3634
});
3735

3836
return (
39-
<ol className="slds-breadcrumb slds-list--horizontal" aria-labelledby={id}>
37+
<ol className="slds-breadcrumb slds-list--horizontal" aria-labelledby="bread-crumb-label">
4038
{breadCrumbTrail}
4139
</ol>
4240
);
@@ -46,7 +44,7 @@ class SLDSBreadCrumb extends Component {
4644

4745
return (
4846
<nav role="navigation">
49-
<p id={id} className="slds-assistive-text">{assistiveText}</p>
47+
<p id="bread-crumb-label" className="slds-assistive-text">{assistiveText}</p>
5048
{trailElement}
5149
</nav>
5250
);
@@ -57,4 +55,4 @@ SLDSBreadCrumb.displayName = displayName;
5755
SLDSBreadCrumb.propTypes = propTypes;
5856
SLDSBreadCrumb.defaultProps = defaultProps;
5957

60-
export default SLDSBreadCrumb;
58+
module.exports = SLDSBreadCrumb;

components/SLDSPageHeader/DetailRow.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1212
import React, { Component } from 'react';
1313
import classnames from 'classnames';
1414
import omit from 'lodash.omit';
15-
import randomId from './randomId';
1615
import DetailBlock from './DetailBlock';
1716

1817
const displayName = 'SLDSPageHeaderDetailRow';
@@ -44,8 +43,7 @@ class DetailRow extends Component {
4443
return children;
4544
} else {
4645
return details.map((detail, i) => {
47-
const id = randomId();
48-
const key = `SLDSPageHeader.detailBlock.${i}.${id}`;
46+
const key = `SLDSPageHeader.detailBlock.${i}`;
4947

5048
return (
5149
<DetailBlock

components/SLDSPageHeader/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Base from './Base';
2020
import RecordHome from './RecordHome';
2121
import ObjectHome from './ObjectHome';
2222
import SLDSIcon from '../SLDSIcon';
23-
import SLDSBreadCrumb from './BreadCrumb';
23+
import SLDSBreadCrumb from '../SLDSBreadCrumb';
2424

2525
const displayName = 'SLDSPageHeader';
2626
const propTypes = {

components/SLDSPageHeader/randomId.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Neither the name of salesforce.com, inc. nor the names of its contributors may b
99
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1010
*/
1111

12+
import SLDSBreadCrumb from './SLDSBreadCrumb';
1213
import SLDSButton from './SLDSButton';
1314
import SLDSButtonStateful from './SLDSButtonStateful';
1415
import SLDSButtonGroup from './SLDSButtonGroup';
@@ -26,6 +27,7 @@ import SLDSSettings from './SLDSSettings';
2627
import SLDSUtilityIcon from './SLDSUtilityIcon';
2728

2829
module.exports = {
30+
SLDSBreadCrumb: SLDSBreadCrumb,
2931
SLDSButton: SLDSButton,
3032
SLDSButtonStateful: SLDSButtonStateful,
3133
SLDSButtonGroup: SLDSButtonGroup,

demo/CodeMirror.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const ReactDOM = require('react-dom');
99
const classNames = require('classnames');
1010
const trim = require('lodash.trim');
1111

12+
const SLDSBreadCrumb = require('../components/SLDSBreadCrumb');
1213
const SLDSButton = require('../components/SLDSButton');
1314
const SLDSButtonStateful = require('../components/SLDSButtonStateful');
1415
const SLDSButtonGroup = require('../components/SLDSButtonGroup');

demo/Samples.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const Samples = {
2+
BreadCrumbs1: require('fs').readFileSync('demo/code-snippets/BreadCrumbExamples1.js', 'utf8'),
23
Buttons1: require('fs').readFileSync('demo/code-snippets/ButtonExamples1.js', 'utf8'),
34
Buttons2: require('fs').readFileSync('demo/code-snippets/ButtonExamples2.js', 'utf8'),
45
ButtonGroups1: require('fs').readFileSync('demo/code-snippets/ButtonGroupExamples1.js', 'utf8'),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class BreadCrumbExample extends React.Component {
2+
3+
render() {
4+
const trail = [
5+
(<a href="#">Parent Entity</a>),
6+
(<a href="#">Parent Record Name</a>),
7+
];
8+
9+
return (
10+
<SLDSBreadCrumb
11+
trail={trail} />
12+
);
13+
}
14+
15+
}
16+
17+
ReactDOM.render(<BreadCrumbExample />, mountNode);

0 commit comments

Comments
 (0)