Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions components/SLDSPageHeader/Base/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.
*/

import React, { Component } from 'react';
import classnames from 'classnames';
import omit from 'lodash.omit';

const displayName = 'SLDSPageHeaderBase';
const propTypes = {
/**
* Icon node passed by SLDSPageHeader
*/
icon: React.PropTypes.node,
/**
* Title node passed by SLDSPageHeader
*/
title: React.PropTypes.node,
/**
* Info node passed by SLDSPageHeader
*/
info: React.PropTypes.node,
};
const defaultProps = {};

class Base extends Component {
render() {
return (
<div className="slds-media slds-media--center">
<div className="slds-media__figure">
{ this.props.icon }
</div>
<div className="slds-media__body">
{ this.props.title }
{ this.props.info }
</div>
</div>
);
}
}

Base.displayName = displayName;
Base.propTypes = propTypes;
Base.defaultProps = defaultProps;

module.exports = Base;
60 changes: 60 additions & 0 deletions components/SLDSPageHeader/BreadCrumb/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { Component } from 'react';
import randomId from '../randomId';

const displayName = 'SLDSBreadCrumb';
const propTypes = {
/**
* The assistive text for the breadcrumb trail
*/
assistiveText: React.PropTypes.string,
/**
* An array of react elements presumably anchor elements.
*/
trail: React.PropTypes.array,
};
const defaultProps = {};

class SLDSBreadCrumb extends Component {
render() {
const {
assistiveText,
trail,
} = this.props;
const id = `SLDSBreadCrumb.${randomId()}`;
let trailElement;

const renderTrail = () => {
const breadCrumbTrail = trail.map((crumb, i) => {
const crumbId = `${id}.${i}`;

return (
<li
key={crumbId}
className="slds-list__item slds-text-heading--label"
>{crumb}</li>
);
});

return (
<ol className="slds-breadcrumb slds-list--horizontal" aria-labelledby={id}>
{breadCrumbTrail}
</ol>
);
};

trailElement = renderTrail();

return (
<nav role="navigation">
<p id={id} className="slds-assistive-text">{assistiveText}</p>
{trailElement}
</nav>
);
}
}

SLDSBreadCrumb.displayName = displayName;
SLDSBreadCrumb.propTypes = propTypes;
SLDSBreadCrumb.defaultProps = defaultProps;

export default SLDSBreadCrumb;
129 changes: 129 additions & 0 deletions components/SLDSPageHeader/DetailBlock.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.
*/

import React, { Component } from 'react';
import classnames from 'classnames';
import omit from 'lodash.omit';

const displayName = 'SLDSPageHeaderDetailRow';
const propTypes = {
/**
* Optional class name
*/
className: React.PropTypes.string,
/**
* label
*/
label: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
]),
/**
* The content property can be a string or a React element
*/
content: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
]),
/**
* Sets whether the fields truncate
*/
truncate: React.PropTypes.bool.isRequired,
flavor: React.PropTypes.string,
};
const defaultProps = {
label: '',
content: '',
truncate: true,
flavor: '1-of-4',
};

class DetailBlock extends Component {
render() {
const {
className,
label,
content,
truncate,
flavor,
} = this.props;
const attr = omit([
'className',
'label',
'content',
'truncate',
'flavor',
], this.props);
const classes = this._getClassNames(className, flavor);
let labelElement;
let contentElement;

/**
* Render the label
*/
const renderLabel = () => {
const type = typeof label;

if (type === 'string') {
const labelClasses = classnames('slds-text-heading--label-normal', {
'slds-truncate': truncate,
});

return (
<p className={labelClasses} title={label}>{label}</p>
);
} else {
return label;
}
};

/**
* Render the title
*/
const renderContent = () => {
const type = typeof content;

if (type === 'string') {
const labelClasses = classnames('slds-text-body--regular', {
'slds-truncate': truncate,
});

return (
<p className={labelClasses} content={content}>{content}</p>
);
} else {
return content;
}
};

labelElement = renderLabel();
contentElement = renderContent();

return (
<li className={classes} {...attr}>
{labelElement}
{contentElement}
</li>
);
}

_getClassNames(className, flavor) {
return classnames('slds-page-header__detail-block', className, {
[`slds-size--${flavor}`]: flavor,
});
}
}

DetailBlock.displayName = displayName;
DetailBlock.propTypes = propTypes;
DetailBlock.defaultProps = defaultProps;

module.exports = DetailBlock;
79 changes: 79 additions & 0 deletions components/SLDSPageHeader/DetailRow.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.
*/

import React, { Component } from 'react';
import classnames from 'classnames';
import omit from 'lodash.omit';
import randomId from './randomId';
import DetailBlock from './DetailBlock';

const displayName = 'SLDSPageHeaderDetailRow';
const propTypes = {
/**
* Optional class name
*/
className: React.PropTypes.string,
/**
* An array of detail blocks
*/
details: React.PropTypes.array,
};
const defaultProps = {};

class DetailRow extends Component {
render() {
const { children, className, details } = this.props;
const attr = omit(['children', 'className'], this.props);
const classes = this._getClassNames(className);

let detailsElement;

/**
* Render the deets
*/
const renderDetails = () => {
if (children !== void(0)) {
return children;
} else {
return details.map((detail, i) => {
const id = randomId();
const key = `SLDSPageHeader.detailBlock.${i}.${id}`;

return (
<DetailBlock
key={key}
flavor={detail.flavor}
label={detail.label}
content={detail.content} />
);
});
}
};

detailsElement = renderDetails();

return (
<ul className={classes} {...attr}>
{detailsElement}
</ul>
);
}

_getClassNames(className) {
return classnames('slds-grid slds-page-header__detail-row', className);
}
}

DetailRow.displayName = displayName;
DetailRow.propTypes = propTypes;
DetailRow.defaultProps = defaultProps;

module.exports = DetailRow;
49 changes: 49 additions & 0 deletions components/SLDSPageHeader/Info.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.
*/

import React, { Component } from 'react';
import classnames from 'classnames';
import omit from 'lodash.omit';

const displayName = 'SLDSPageHeaderInfo';
const propTypes = {
/**
* Optional class name
*/
className: React.PropTypes.string,
};
const defaultProps = {
className: '',
};

class Info extends Component {
render() {
const { children, className } = this.props;
const attr = omit(['children', 'className'], this.props);
const classes = this._getClassNames(className);

return (
<p className={classes} {...attr}>
{children}
</p>
);
}

_getClassNames(className) {
return classnames('slds-page-header__info', className);
}
}

Info.displayName = displayName;
Info.propTypes = propTypes;
Info.defaultProps = defaultProps;

module.exports = Info;
Loading