Skip to content

Commit cc4b839

Browse files
committed
Merge pull request #1 from ux/master
Merge master into gh-pages
2 parents fb335ee + dba64bd commit cc4b839

File tree

480 files changed

+24031
-16651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

480 files changed

+24031
-16651
lines changed

components/SLDSButton/index.js

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import React from 'react';
1313
const classNames = require('classnames');
1414
import createChainedFunction from '../utils/create-chained-function';
1515
import {ButtonIcon, Icon} from '../SLDSIcons.js';
16-
import {omit} from 'lodash';
16+
import omit from 'lodash.omit';
1717

1818
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/SLDSDropdowns/index.js

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

components/SLDSGrid/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1010
*/
1111

1212
const React = require('react');
13-
import {omit} from 'lodash';
13+
import omit from 'lodash.omit';
1414
const classNames = require('classnames');
1515

1616
class GridColumn extends React.Component {

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} />;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5+
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.
6+
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.
7+
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.
8+
*/
9+
10+
import React, { Component } from 'react';
11+
import {Icon} from "../../../SLDSIcons";
12+
13+
class ActionItem extends React.Component {
14+
constructor(props) {
15+
super(props);
16+
}
17+
18+
componentWillReceiveProps(nextProps){
19+
if(nextProps.isActive !== this.props.isActive && nextProps.isActive === true) this.props.setFocus(this.props.id);
20+
}
21+
22+
render(){
23+
let className = 'slds-button';
24+
if(this.props.isActive) className += ' slds-theme--shade'
25+
26+
return (
27+
<button id={this.props.id} tabIndex="-1" className={className} onClick={this.props.onSelect} onMouseDown={this.props.onSelect}>
28+
<Icon name={this.props.icon} category="utility" size="x-small" className="slds-icon-text-default" />
29+
{this.props.children}
30+
</button>
31+
)
32+
}
33+
}
34+
35+
ActionItem.propTypes = {
36+
};
37+
38+
ActionItem.defaultProps = {
39+
};
40+
41+
module.exports = ActionItem;

0 commit comments

Comments
 (0)