Skip to content

Commit a2cec68

Browse files
committed
Make DefaultHeader and DefaultFooter components
1 parent d8a44ee commit a2cec68

File tree

4 files changed

+86
-56
lines changed

4 files changed

+86
-56
lines changed

components/SLDSLookup/Menu/ActionItem/index.jsx

Lines changed: 0 additions & 53 deletions
This file was deleted.
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 DefaultFooter 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='newItem' tabIndex="-1" className={className}>
28+
<Icon name='add' category="utility" size="x-small" className="slds-icon-text-default" />
29+
{'New ' + this.props.type}
30+
</button>
31+
)
32+
}
33+
}
34+
35+
DefaultFooter.propTypes = {
36+
};
37+
38+
DefaultFooter.defaultProps = {
39+
};
40+
41+
module.exports = DefaultFooter;
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 DefaultHeader 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='searchRecords' tabIndex="-1" className={className}>
28+
<Icon name='search' category="utility" size="x-small" className="slds-icon-text-default" />
29+
{this.props.searchTerm ? '"' + this.props.searchTerm + '"' + ' in ' + this.props.type + 's': ' in ' + this.props.type + 's'}
30+
</button>
31+
)
32+
}
33+
}
34+
35+
DefaultHeader.propTypes = {
36+
};
37+
38+
DefaultHeader.defaultProps = {
39+
};
40+
41+
module.exports = DefaultHeader;

demo/pages/HomePage/LookupBaseSection.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1212
import React from 'react';
1313
import SLDSLookup from '../../../components/SLDSLookup';
1414
import {default as PrismCode} from 'react-prism/lib/PrismCode';
15-
import ActionItem from '../../../components/SLDSLookup/Menu/ActionItem';
15+
import DefaultHeader from '../../../components/SLDSLookup/Menu/DefaultHeader';
16+
import DefaultFooter from '../../../components/SLDSLookup/Menu/DefaultFooter';
1617

1718
const items = [
1819
{label:'Paddy\'s Pub'},
@@ -55,15 +56,15 @@ module.exports = React.createClass( {
5556
getHeader(){
5657
return (
5758
<div className="slds-lookup__item" onClick={this.headerClick} onMouseDown={this.headerClick}>
58-
<ActionItem item='search' type='account' searchTerm={this.state.searchVal} />
59+
<DefaultHeader searchTerm={this.state.searchVal} type='account' />
5960
</div>
6061
)
6162
},
6263

6364
getFooter(){
6465
return (
6566
<div className="slds-lookup__item" onClick={this.footerClick} onMouseDown={this.footerClick}>
66-
<ActionItem item='newItem' type='account' />
67+
<DefaultFooter type='account' />
6768
</div>
6869
)
6970
},

0 commit comments

Comments
 (0)