Skip to content

Commit 4ede46c

Browse files
committed
Fix merge error in Modal
2 parents 544b390 + d90e322 commit 4ede46c

File tree

7 files changed

+101
-35
lines changed

7 files changed

+101
-35
lines changed

components/SLDSLookup/Menu/index.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
*/
99

1010
import React, { Component } from 'react';
11-
import {Icon} from "../../SLDSIcons";
12-
import {KEYS} from '../../utils';
1311
import Item from './Item';
12+
import {Icon} from "../../SLDSIcons";
1413

1514
class Menu extends React.Component {
1615
constructor(props){
1716
super(props);
1817
this.state = {};
1918
}
2019

21-
componentDidUpdate(){
20+
componentDidUpdate(prevProps, prevState){
2221
let list = React.findDOMNode(this.refs.list).children.length;
2322
this.props.getListLength(list);
2423
}
@@ -49,6 +48,26 @@ class Menu extends React.Component {
4948
});
5049
}
5150

51+
renderEmptyState(){
52+
let className = 'slds-lookup__item';
53+
return (
54+
<li
55+
className={className}
56+
role="presentaion">
57+
<a
58+
href='#'
59+
id='add-item'
60+
tabIndex="-1"
61+
role="option"
62+
onClick={this.props.addItem}
63+
onMouseDown={this.props.addItem}>
64+
<Icon name="add" category="utility" size="x-small" className="slds-icon-text-default" />
65+
New {this.props.type}
66+
</a>
67+
</li>
68+
);
69+
}
70+
5271
render(){
5372
return (
5473
<div
@@ -59,6 +78,7 @@ class Menu extends React.Component {
5978
role="presentation"
6079
ref="list">
6180
{this.renderItems()}
81+
{this.renderEmptyState()}
6282
</ul>
6383
</div>
6484
)

components/SLDSLookup/index.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
99

1010
import React, { Component } from 'react';
1111
import Menu from './Menu';
12-
import {InputIcon, ButtonIcon} from "./../SLDSIcons";
13-
import {Icon} from "../SLDSIcons";
12+
import {Icon, InputIcon, ButtonIcon} from "./../SLDSIcons";
1413
import {KEYS,EventUtil} from '../utils';
1514
import escapeRegExp from 'lodash.escaperegexp';
1615

@@ -36,6 +35,12 @@ class SLDSLookup extends React.Component {
3635
};
3736
}
3837

38+
componentDidUpdate(prevProps, prevState){
39+
if(prevState.selectedIndex && !this.state.selectIndex){
40+
if(this.refs.lookup) React.findDOMNode(this.refs.lookup).focus();
41+
}
42+
}
43+
3944
//=================================================
4045
// Using down/up keys, set Focus on list item and assign it to aria-activedescendant attribute in input.
4146
// Need to keep track of filtered list length to be able to increment/decrement the focus index so it's contained to the number of available list items.
@@ -72,7 +77,7 @@ class SLDSLookup extends React.Component {
7277
handleDeleteSelected() {
7378
this.setState({
7479
selectedIndex: null,
75-
isOpen: false
80+
isOpen: true,
7681
});
7782
}
7883

@@ -144,7 +149,10 @@ class SLDSLookup extends React.Component {
144149
setFocus={this.setFocus.bind(this)}
145150
getListLength={this.getListLength.bind(this)}
146151
listLength={this.state.listLength}
147-
focusIndex={this.state.focusIndex}/>;
152+
focusIndex={this.state.focusIndex}
153+
addItem={this.props.addItem}
154+
type={this.props.type}
155+
/>;
148156
}else{
149157
return null;
150158
}
@@ -181,6 +189,7 @@ class SLDSLookup extends React.Component {
181189
<InputIcon name="search"/>
182190
<input
183191
id="lookup"
192+
ref="lookup"
184193
className={inputClasses}
185194
type="text"
186195
aria-label="lookup"

components/SLDSModal/index.jsx

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const customStyles = {
4242
module.exports = React.createClass( {
4343

4444
propTypes: {
45-
size: React.PropTypes.oneOf(['medium', 'large'])
45+
size: React.PropTypes.oneOf(['medium', 'large']),
46+
prompt: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'wrench', 'offline', 'info'])
4647
},
4748

4849
getDefaultProps () {
@@ -53,6 +54,7 @@ module.exports = React.createClass( {
5354
footer:[],
5455
returnFocusTo:null,
5556
size:'medium',
57+
prompt:'', //if prompt !== '', it renders modal as prompt
5658
directional: false
5759
};
5860
},
@@ -106,48 +108,38 @@ module.exports = React.createClass( {
106108
}
107109
},
108110

111+
isPrompt(){
112+
return this.props.prompt !== '';
113+
},
114+
109115
getModal() {
110116
const modalClass = {
111117
'slds-modal': true,
112118
'slds-fade-in-open':this.state.revealed,
113119
'slds-modal--large':this.props.size === 'large'
114120
};
115121

116-
const footerClass = {
117-
'slds-modal__footer': true,
118-
'slds-modal__footer--directional': this.props.directional
119-
};
120-
121122
return <div
122123
className={cx(modalClass)}
123124
style={{pointerEvents:'inherit'}}
124-
onClick={this.closeModal}
125+
onClick={this.isPrompt() ? undefined : this.closeModal}
125126
>
126127
<div
127128
role='dialog'
128129
className='slds-modal__container'
129130
onClick={this.handleModalClick}
130131
>
131-
<div className='slds-modal__header'>
132-
<h2 className='slds-text-heading--medium'>{this.props.title}</h2>
133-
<SLDSButton
134-
label='Close'
135-
variant='icon'
136-
iconName='close'
137-
iconSize='large'
138-
inverse={true}
139-
className='slds-modal__close'
140-
onClick={this.closeModal} />
141-
</div>
132+
133+
{this.headerComponent()}
142134

143135
<div className='slds-modal__content'>
144136

145137
{this.props.children}
146138

139+
{this.isPrompt() ? this.props.footer : null}
147140
</div>
148-
<div className={cx(footerClass)}>
149-
{this.props.footer}
150-
</div>
141+
142+
{this.footerComponent()}
151143

152144
</div>
153145

@@ -171,6 +163,49 @@ module.exports = React.createClass( {
171163
);
172164
},
173165

166+
footerComponent() {
167+
let footer;
168+
169+
const footerClass = {
170+
'slds-modal__footer': true,
171+
'slds-modal__footer--directional': this.props.directional
172+
};
173+
174+
const hasFooter = this.props.footer && this.props.footer.length > 0;
175+
176+
if (!this.isPrompt() && hasFooter ) {
177+
footer = (<div className={cx(footerClass)}>{this.props.footer}</div>);
178+
}
179+
180+
return footer;
181+
},
182+
183+
headerComponent() {
184+
let headingClasses = [], headerClasses = ['slds-modal__header'];
185+
let closeButton;
186+
187+
if (this.isPrompt()) {
188+
headerClasses.push(`slds-theme--${this.props.prompt}`);
189+
headingClasses.push('slds-text-heading--small');
190+
} else {
191+
headingClasses.push('slds-text-heading--medium')
192+
closeButton =(<SLDSButton
193+
label='Close'
194+
variant='icon'
195+
iconName='close'
196+
iconSize='large'
197+
inverse={true}
198+
className='slds-modal__close'
199+
onClick={this.closeModal} />);
200+
}
201+
202+
return (
203+
<div className={cx(headerClasses)}>
204+
<h2 className={cx(headingClasses)}>{this.props.title}</h2>
205+
{closeButton}
206+
</div>);
207+
},
208+
174209
componentDidUpdate (prevProps, prevState) {
175210

176211

demo/pages/HomePage/LookupBaseSection.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ module.exports = React.createClass( {
3636
return {};
3737
},
3838

39+
addItem(){
40+
alert('Add item clicked');
41+
},
42+
3943

4044
render() {
4145
return (
@@ -53,7 +57,7 @@ module.exports = React.createClass( {
5357
</PrismCode>
5458

5559
<div className="slds-p-vertical--large">
56-
<SLDSLookup items={items} label="Contacts" />
60+
<SLDSLookup items={items} label="Accounts" type="account" addItem={this.addItem} />
5761
</div>
5862

5963
</div>

demo/pages/HomePage/ModalSection.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ Utilize our detailed guidelines to confidently design excellent apps that fit ri
9797
isOpen={this.state.modalIsOpen}
9898
title={<span>Lightning Design System: Style with Ease</span>}
9999
footer={[
100-
<SLDSButton label='Cancel' variant='neutral' onClick={this.closeModal} />,
101-
<SLDSButton label='Save' variant='brand' onClick={this.handleSubmitModal} />
100+
<SLDSButton key='cancelBtn' label='Cancel' variant='neutral' onClick={this.closeModal} />,
101+
<SLDSButton key='saveBtn' label='Save' variant='brand' onClick={this.handleSubmitModal} />
102102
]}
103103
onRequestClose={this.closeModal}>
104104
{this.getModalContent()}

demo/pages/HomePage/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ module.exports = React.createClass( {
5959
</div>
6060
<main className='stage-main slds-grid slds-wrap slds-grow' role='main'>
6161
<div className='region region--main slds-grow slds-size--1-of-1 slds-medium-size--1-of-2 slds-large-size--8-of-12 slds-col-rule--right slds-p-around--large'>
62+
<LookupBaseSection />
6263

6364
<ButtonSection />
6465

6566
<PicklistBaseSection />
6667

6768
<ModalSection />
6869

69-
<LookupBaseSection />
7070

7171
<DatePickerSingleSelectSection />
7272

tests/SLDSButton/button.test.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ describe('SLDSButton: ', function(){
3434
let brand = TestUtils.findRenderedDOMComponentWithClass(button, 'slds-button--brand');
3535
expect(brand).to.not.equal(undefined);
3636
});
37-
38-
})
39-
37+
});
4038

4139
describe('component icon props render', function() {
4240
it('renders icon svg', function() {

0 commit comments

Comments
 (0)