Skip to content

Commit b58048a

Browse files
committed
Merge branch 'master' into lookups-refactor
2 parents 53d5943 + 487ef3f commit b58048a

File tree

6 files changed

+101
-54
lines changed

6 files changed

+101
-54
lines changed

components/SLDSButton/index.js

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Button extends React.Component {
1919

2020
constructor(props) {
2121
super(props);
22+
this.displayName = 'SLDSButton';
2223
this.state = { active: false };
2324
};
2425

@@ -38,20 +39,27 @@ class Button extends React.Component {
3839
}
3940

4041
getClassName() {
41-
let isStateful = this.props.stateful && this.state.active ? true : false;
42+
let isSelected = this.props.stateful && this.state.active ? true : false;
43+
let notSelected = this.props.stateful && !this.state.active ? true : false;
4244
return classNames(this.props.className, 'slds-button', {
4345
[`slds-button--${this.props.variant}`]: this.props.variant,
44-
['slds-is-selected']: isStateful,
46+
['slds-not-selected']: notSelected,
47+
['slds-is-selected']: isSelected,
4548
});
4649
}
4750

4851
renderIcon(){
4952
if(this.props.iconName){
5053
return (
5154
<ButtonIcon
55+
variant={this.props.variant}
56+
disabled={this.props.disabled}
57+
inverse={this.props.inverse}
58+
stateful={this.props.stateful}
5259
name={this.props.iconName}
5360
size={this.props.iconSize}
54-
position={this.props.iconPosition || 'left'} />
61+
position={this.props.iconPosition}
62+
/>
5563
);
5664
}
5765
}
@@ -60,38 +68,25 @@ class Button extends React.Component {
6068
render() {
6169
const props = omit('className', this.props);
6270
const click = createChainedFunction(this.props.onClick, this.onClick.bind(this));
71+
const labelClasses = this.props.variant === 'icon' ? 'slds-assistive-text': '';
6372
if (this.props.disabled) { props['disabled'] = 'disabled' };
6473

65-
//If the button is only an icon render this:
66-
if(this.props.variant === 'icon'){
67-
return (
68-
<button className={this.getClassName()} {...props} onClick={click}>
69-
<Icon
70-
name={this.props.iconName}
71-
category='utility'
72-
size={this.props.iconSize}
73-
/>
74-
<span className="slds-assistive-text">{this.props.label}</span>
75-
</button>
76-
);
77-
}
78-
//Else we assume the button has a visible label (with or without an icon):
79-
else{
80-
return (
81-
<button className={this.getClassName()} {...props} onClick={click}>
82-
{this.props.iconPosition === 'right' ? this.props.label : null}
83-
{this.renderIcon()}
84-
{(this.props.iconPosition === 'left' || !this.props.iconPosition) ? this.props.label : null}
85-
</button>
86-
);
87-
}
74+
return (
75+
<button className={this.getClassName()} {...props} onClick={click}>
76+
{this.props.iconPosition === 'right' ? <span className={labelClasses}>{this.props.label}</span>: null}
77+
{this.renderIcon()}
78+
{(this.props.iconPosition === 'left' || !this.props.iconPosition) ? <span className={labelClasses}>{this.props.label}</span>: null}
79+
</button>
80+
);
8881
}
8982
}
9083

9184
Button.propTypes = {
9285
label: React.PropTypes.string.isRequired,
93-
variant: React.PropTypes.oneOf(['base', 'neutral', 'brand', 'icon']),
86+
variant: React.PropTypes.oneOf(['base', 'neutral', 'brand', 'destructive', 'icon']),
9487
disabled: React.PropTypes.bool,
88+
inverse: React.PropTypes.bool,
89+
stateful: React.PropTypes.bool,
9590
iconName: React.PropTypes.string,
9691
iconSize: React.PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
9792
iconPosition: React.PropTypes.oneOf(['left', 'right']),

components/SLDSIcons.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,24 @@ export const ButtonIcon = React.createClass({
2828

2929
const useTag = '<use xlink:href="'+SLDSSettings.getAssetsPath()+'/icons/' + this.props.category + '-sprite/svg/symbols.svg#' + this.props.name + '" />';
3030
let className = 'slds-button__icon';
31-
if (this.props.stateful) {
32-
className += '--stateful';
33-
}
34-
if (this.props.position) {
35-
className = className + ' slds-button__icon--' + this.props.position;
31+
if (this.props.variant !== 'icon') {
32+
//If no position prop given, default to left
33+
this.props.position ? className += ' slds-button__icon--' + this.props.position : className += ' slds-button__icon--left';
3634
}
3735
if (this.props.size) {
38-
className = className + ' slds-button__icon--' + this.props.size;
36+
className += ' slds-button__icon--' + this.props.size;
3937
}
4038
if (this.props.inverse) {
41-
className = className + ' slds-button__icon--inverse';
39+
className += ' slds-button__icon--inverse';
40+
}
41+
if (this.props.stateful) {
42+
className += ' slds-button__icon--stateful';
4243
}
4344
if (this.props.hint) {
44-
className = className + ' slds-button__icon--hint';
45+
className += ' slds-button__icon--hint';
46+
}
47+
if (this.props.destructive) {
48+
className += ' slds-button__icon--destructive';
4549
}
4650
if(this.props.category === 'utility'){
4751
return <SLDSUtilityIcon name={this.props.name} aria-hidden='true' className={className} />;

components/SLDSModal/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ module.exports = React.createClass( {
189189
headingClasses.push('slds-text-heading--small');
190190
} else {
191191
headingClasses.push('slds-text-heading--medium')
192-
193192
closeButton =(<SLDSButton
194193
label='Close'
195194
variant='icon'
196195
iconName='close'
197-
iconSize='small'
196+
iconSize='large'
197+
inverse={true}
198198
className='slds-modal__close'
199199
onClick={this.closeModal} />);
200200
}

demo/code-snippets/SLDSButton.txt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11

2-
<SLDSButton
3-
label='Neutral'
4-
variant='neutral'
5-
disabled={false}
6-
iconName='download'
7-
iconSize='small'
8-
iconPosition='right'
9-
onClick={this.handleButtonClick} />
10-
11-
* Only label is required
12-
132
Below are component prop defaults and available options:
14-
* variant='base' ('neutral', 'brand', 'icon')
15-
* disabled='false'
16-
* iconSize='medium' ('x-small', 'medium', 'small', 'large')
17-
* iconPosition='left'('left', 'right', 'large')
3+
* label='' *required
4+
* variant='base' ['neutral', 'brand', 'destructive', 'icon']
5+
* disabled={false}
6+
* inverse={false}
7+
* stateful={false}
8+
* iconName='' //see https://www.lightningdesignsystem.com/resources/icons#utility
9+
* iconSize='medium' ['x-small', 'medium', 'small', 'large']
10+
* iconPosition='left' ['left', 'right', 'large']
11+
12+
<SLDSButton label='Neutral' variant='neutral' onClick={this.handleNeutralClick} />
1813

demo/pages/HomePage/ButtonSection.jsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ module.exports = React.createClass( {
3232
alert('Neutral Button Clicked');
3333
},
3434

35+
handleBrandClick () {
36+
alert('Brand Button Clicked');
37+
},
38+
3539
handleDisabledClick () {
3640
alert('Disabled Button Clicked');
3741
},
3842

43+
handleIconClick(){
44+
alert('Icon Button Clicked');
45+
},
46+
3947
render() {
4048
return (
4149

@@ -51,7 +59,11 @@ module.exports = React.createClass( {
5159
<SLDSButton
5260
label='Neutral'
5361
variant='neutral'
54-
disabled={false}
62+
onClick={this.handleNeutralClick} />
63+
64+
<SLDSButton
65+
label='Neutral Icon'
66+
variant='neutral'
5567
iconName='download'
5668
iconSize='small'
5769
iconPosition='right'
@@ -61,8 +73,19 @@ module.exports = React.createClass( {
6173
label='Disabled'
6274
variant='neutral'
6375
disabled={true}
64-
onClick={this.handleButtonClick} />
76+
onClick={this.handleDisabledClick} />
6577

78+
<SLDSButton
79+
label='Brand'
80+
variant='brand'
81+
onClick={this.handleBrandClick} />
82+
83+
<SLDSButton
84+
label='Settings'
85+
variant='icon'
86+
iconName='settings'
87+
iconSize='large'
88+
onClick={this.handleIconClick} />
6689
</div>
6790
</div>
6891

lib/SLDSToast/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
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.
7+
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.
8+
9+
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.
10+
*/
11+
12+
'use strict';
13+
14+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
15+
16+
var _react = require('react');
17+
18+
var _react2 = _interopRequireDefault(_react);
19+
20+
module.exports = _react2['default'].createClass({
21+
displayName: 'exports',
22+
23+
render: function render() {
24+
return _react2['default'].createElement(
25+
'div',
26+
null,
27+
'TOAST!!!'
28+
);
29+
}
30+
});

0 commit comments

Comments
 (0)