Skip to content

Commit b1ad975

Browse files
committed
Remove {...props} from DOM nodes in global nav link, label, menus, page-header, tab
1 parent 4dfaea0 commit b1ad975

File tree

27 files changed

+528
-416
lines changed

27 files changed

+528
-416
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
# filesystem
22
.DS_Store
33

44
# dependencies
@@ -24,5 +24,3 @@ server/public/assets/bundle
2424
scripts/pre-commit.sh
2525
coverage/
2626
storybook/
27-
28-
.jscsrc

components/button-stateful/index.jsx

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -135,29 +135,50 @@ class ButtonStateful extends TooltipTrigger {
135135
}
136136

137137
render () {
138-
const active = isBoolean(this.props.active) ? this.props.active : this.state.active;
139-
140-
if (this.props.variant === 'icon') {
138+
const {
139+
active,
140+
assistiveText,
141+
disabled,
142+
iconName,
143+
iconSize,
144+
id,
145+
onFocus,
146+
onKeyDown,
147+
onKeyPress,
148+
onKeyUp,
149+
onMouseEnter,
150+
onMouseLeave,
151+
stateOne,
152+
stateTwo,
153+
stateThree,
154+
tabIndex,
155+
variant
156+
} = this.props;
157+
158+
const isActive = isBoolean(active) ? active : this.state.active;
159+
160+
if (variant === 'icon') {
141161
return (
142162
<button
143163
aria-live="polite"
144-
className={this.getClassName(active)}
145-
disabled={this.props.disabled}
164+
className={this.getClassName(isActive)}
165+
disabled={disabled}
166+
id={id}
146167
onBlur={this.handleBlur.bind(this)}
147168
onClick={this.handleClick.bind(this)}
148-
onFocus={this.props.onFocus}
149-
onKeyDown={this.props.onKeyDown}
150-
onKeyPress={this.props.onKeyPress}
151-
onKeyUp={this.props.onKeyUp}
152-
onMouseEnter={this.props.onMouseEnter}
169+
onFocus={onFocus}
170+
onKeyDown={onKeyDown}
171+
onKeyPress={onKeyPress}
172+
onKeyUp={onKeyUp}
173+
onMouseEnter={onMouseEnter}
153174
onMouseLeave={this.handleBlur.bind(this)}
154-
tabIndex={this.props.tabIndex}
175+
tabIndex={tabIndex}
155176
>
156177
<ButtonIcon
157-
assistiveText={active ? `${this.props.assistiveText} selected` : this.props.assistiveText}
158-
disabled={this.props.disabled}
159-
name={this.props.iconName}
160-
size={this.props.iconSize}
178+
assistiveText={isActive ? `${assistiveText} selected` : assistiveText}
179+
disabled={disabled}
180+
name={iconName}
181+
size={iconSize}
161182
className="slds-button__icon--stateful"
162183
/>
163184
{this.getTooltip()}
@@ -168,47 +189,48 @@ class ButtonStateful extends TooltipTrigger {
168189
return (
169190
<button
170191
aria-live="assertive"
171-
className={this.getClassName(active)}
172-
disabled={this.props.disabled}
192+
className={this.getClassName(isActive)}
193+
disabled={disabled}
194+
id={id}
173195
onBlur={this.handleBlur.bind(this)}
174196
onClick={this.handleClick.bind(this)}
175-
onFocus={this.props.onFocus}
176-
onKeyDown={this.props.onKeyDown}
177-
onKeyPress={this.props.onKeyPress}
178-
onKeyUp={this.props.onKeyUp}
179-
onMouseEnter={this.props.onMouseEnter}
197+
onFocus={onFocus}
198+
onKeyDown={onKeyDown}
199+
onKeyPress={onKeyPress}
200+
onKeyUp={onKeyUp}
201+
onMouseEnter={onMouseEnter}
180202
onMouseLeave={this.handleBlur.bind(this)}
181-
tabIndex={this.props.tabIndex}
203+
tabIndex={tabIndex}
182204
>
183205
<span className="slds-text-not-selected">
184206
<ButtonIcon
185-
disabled={this.props.disabled}
186-
name={this.props.stateOne.iconName}
207+
disabled={disabled}
208+
name={stateOne.iconName}
187209
size="small"
188210
position="left"
189211
className="slds-button__icon--stateful"
190212
/>
191-
{this.props.stateOne.label}
213+
{stateOne.label}
192214
</span>
193215
<span className="slds-text-selected">
194216
<ButtonIcon
195-
disabled={this.props.disabled}
196-
name={this.props.stateTwo.iconName}
217+
disabled={disabled}
218+
name={stateTwo.iconName}
197219
size="small"
198220
position="left"
199221
className="slds-button__icon--stateful"
200222
/>
201-
{this.props.stateTwo.label}
223+
{stateTwo.label}
202224
</span>
203225
<span className="slds-text-selected-focus">
204226
<ButtonIcon
205-
disabled={this.props.disabled}
206-
name={this.props.stateThree.iconName}
227+
disabled={disabled}
228+
name={stateThree.iconName}
207229
size="small"
208230
position="left"
209231
className="slds-button__icon--stateful"
210232
/>
211-
{this.props.stateThree.label}
233+
{stateThree.label}
212234
</span>
213235
{this.getTooltip()}
214236
</button>

components/button/index.jsx

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import { BUTTON } from '../../utilities/constants';
1919

2020
const displayName = BUTTON;
2121
const propTypes = {
22+
/**
23+
* Used if the Button triggers a menu or popup. Bool indicates if the menu or popup is open or closed.
24+
*/
25+
ariaExpanded: PropTypes.bool,
26+
/**
27+
* True if Button triggers a menu or popup to open/close.
28+
*/
29+
ariaHaspopup: PropTypes.bool,
2230
/**
2331
* Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means.
2432
* If the button has an icon and a visible label, you can omit the <code>assistiveText</code> prop and use the <code>label</code> prop.
@@ -57,7 +65,7 @@ const propTypes = {
5765
*/
5866
iconVariant: PropTypes.oneOf(['bare', 'container', 'border', 'border-filled', 'more', 'global-header']),
5967
/**
60-
* For icon variants, please reference <a href="http://www.lightningdesignsystem.com/components/buttons/#icon">Lightning Design System Icons</a>.
68+
* Id string applied to button node.
6169
*/
6270
id: PropTypes.string,
6371
/**
@@ -192,29 +200,51 @@ class Button extends TooltipTrigger {
192200
}
193201

194202
render () {
203+
const {
204+
ariaExpanded,
205+
ariaHaspopup,
206+
children,
207+
disabled,
208+
iconName,
209+
iconPosition,
210+
iconVariant,
211+
id,
212+
onBlur,
213+
onFocus,
214+
onKeyDown,
215+
onKeyPress,
216+
onKeyUp,
217+
onMouseEnter,
218+
onMouseLeave,
219+
tabIndex
220+
} = this.props;
221+
195222
return (
196223
<button
224+
aria-expanded={ariaExpanded}
225+
aria-haspopup={ariaHaspopup}
197226
className={this.getClassName()}
198-
disabled={this.props.disabled}
199-
onBlur={this.props.onBlur}
227+
disabled={disabled}
228+
id={id}
229+
onBlur={onBlur}
200230
onClick={this.handleClick}
201-
onFocus={this.props.onFocus}
202-
onKeyDown={this.props.onKeyDown}
203-
onKeyPress={this.props.onKeyPress}
204-
onKeyUp={this.props.onKeyUp}
205-
onMouseEnter={this.props.onMouseEnter}
206-
onMouseLeave={this.props.onBlur}
207-
tabIndex={this.props.tabIndex}
231+
onFocus={onFocus}
232+
onKeyDown={onKeyDown}
233+
onKeyPress={onKeyPress}
234+
onKeyUp={onKeyUp}
235+
onMouseEnter={onMouseEnter}
236+
onMouseLeave={onMouseLeave}
237+
tabIndex={tabIndex}
208238
>
209-
{this.props.iconPosition === 'right' ? this.renderLabel() : null}
239+
{iconPosition === 'right' ? this.renderLabel() : null}
210240

211-
{this.props.iconName ? this.renderIcon(this.props.iconName) : null}
212-
{this.props.iconVariant === 'more'
241+
{iconName ? this.renderIcon(this.props.iconName) : null}
242+
{iconVariant === 'more'
213243
? <ButtonIcon category="utility" name="down" size="x-small" />
214244
: null}
215245

216-
{(this.props.iconPosition === 'left' || !this.props.iconPosition) ? this.renderLabel() : null}
217-
{this.props.children}
246+
{(iconPosition === 'left' || !iconPosition) ? this.renderLabel() : null}
247+
{children}
218248
{this.getTooltip()}
219249
</button>
220250
);

0 commit comments

Comments
 (0)