Skip to content

Commit 3f1af43

Browse files
committed
icons progress
1 parent 170b79d commit 3f1af43

File tree

12 files changed

+982
-46
lines changed

12 files changed

+982
-46
lines changed

components/SLDSIcon/SVG/index.jsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@ module.exports = React.createClass({
1818

1919
getDefaultProps () {
2020
return {
21-
name:'announcenent',
22-
fill:'#fff'
21+
name:'announcenent'
2322
};
2423
},
2524

26-
getIcon (name) {
27-
return SLDS_ICONS_UTIL[name.toLowerCase()];
25+
getPaths (data) {
26+
console.log('DATA: ',data);
27+
if(data instanceof Array){
28+
return data.map((item)=>{
29+
return <path {...item} />;
30+
});
31+
}
32+
return <path {...data} />;
33+
},
34+
35+
getSVG (name) {
36+
const data = SLDS_ICONS_UTIL[name.toLowerCase()];
37+
console.log('DATA: ',data);
38+
return <svg className={this.props.className} {...this.props} viewBox={SLDS_ICONS_UTIL.viewBox}>{this.getPaths(data)}</svg>;
2839
},
2940

3041
render () {
3142
return (
32-
<svg {...this.props} viewBox='0 0 24 24'>
33-
{ this.getIcon(this.props.name) }
34-
</svg>
43+
this.getSVG(this.props.name)
3544
);
3645
}
3746
});

components/SLDSIcon/SVG/slds-icons-util.jsx

Lines changed: 182 additions & 20 deletions
Large diffs are not rendered by default.

components/SLDSIcon/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ module.exports = React.createClass( {
2222
},
2323

2424
render () {
25-
return <SVG name='adduser' width={100} height={100} fill='blue'/>;
25+
return <SVG name='adduser' className='slds-input__icon slds-icon-text-default' width={100} height={100} />;
2626
}
2727
});

demo/static/bundle.js

Lines changed: 30 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/SLDSButton/index.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,9 @@ var Button = (function (_React$Component) {
112112
return _react2['default'].createElement(
113113
'button',
114114
_extends({ className: this.getClassName() }, props, { onClick: click }),
115-
_react2['default'].createElement(
116-
'span',
117-
{ 'aria-live': 'assertive' },
118-
this.props.iconPosition === 'right' ? this.props.label : null
119-
),
115+
this.props.iconPosition === 'right' ? this.props.label : null,
120116
this.renderIcon(),
121-
_react2['default'].createElement(
122-
'span',
123-
{ 'aria-live': 'assertive' },
124-
this.props.iconPosition === 'left' || !this.props.iconPosition ? this.props.label : null
125-
)
117+
this.props.iconPosition === 'left' || !this.props.iconPosition ? this.props.label : null
126118
);
127119
}
128120
}

lib/SLDSIcon/SVG/index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
15+
16+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
17+
18+
var _react = require('react');
19+
20+
var _react2 = _interopRequireDefault(_react);
21+
22+
var _sldsIconsUtil = require('./slds-icons-util');
23+
24+
var _sldsIconsUtil2 = _interopRequireDefault(_sldsIconsUtil);
25+
26+
module.exports = _react2['default'].createClass({
27+
displayName: 'exports',
28+
29+
getDefaultProps: function getDefaultProps() {
30+
return {
31+
name: 'announcenent',
32+
fill: '#fff'
33+
};
34+
},
35+
36+
getIcon: function getIcon(name) {
37+
return _sldsIconsUtil2['default'][name.toLowerCase()];
38+
},
39+
40+
render: function render() {
41+
return _react2['default'].createElement(
42+
'svg',
43+
_extends({}, this.props, { viewBox: '0 0 24 24' }),
44+
this.getIcon(this.props.name)
45+
);
46+
}
47+
});

lib/SLDSIcon/SVG/slds-icons-util.js

Lines changed: 595 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/SLDSIcon/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
var _SVG = require('./SVG');
21+
22+
var _SVG2 = _interopRequireDefault(_SVG);
23+
24+
//import classNames from 'classnames';
25+
26+
module.exports = _react2['default'].createClass({
27+
displayName: 'exports',
28+
29+
onClick: function onClick() {
30+
this.setState({ active: !this.state.active });
31+
},
32+
33+
render: function render() {
34+
return _react2['default'].createElement(_SVG2['default'], { name: 'adduser', width: 100, height: 100, fill: 'blue' });
35+
}
36+
});

lib/utils/react.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 = window.React ? window.React : _react2['default'];

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"dist": "webpack",
99
"compile": "babel -d lib/ components/",
1010
"prepublish": "npm run compile",
11-
"test": "scripts/test --single-run"
11+
"test": "scripts/test --single-run",
12+
"postinstall": "node scripts/postinstall"
1213
},
1314
"repository": {
1415
"type": "git",
@@ -33,6 +34,7 @@
3334
"main": "lib/index.js",
3435
"homepage": "https://github.com/salesforce-ux/design-system-react",
3536
"devDependencies": {
37+
"@salesforce-ux/icons": "latest",
3638
"babel": "^5.8.23",
3739
"babel-core": "^5.4.7",
3840
"babel-eslint": "^3.1.9",
@@ -63,7 +65,8 @@
6365
"style-loader": "^0.9.0",
6466
"url-loader": "^0.5.6",
6567
"webpack": "^1.9.6",
66-
"webpack-dev-server": "^1.8.2"
68+
"webpack-dev-server": "^1.8.2",
69+
"xml2json": "^0.9.0"
6770
},
6871
"dependencies": {
6972
"classnames": "^2.1.3",

scripts/postinstall.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('./utility-icons');
2+
console.log('POSTINSTALL');

scripts/utility-icons.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var parser = require('xml2json');
4+
5+
6+
var inputPath = path.join(__dirname,'..','node_modules','@salesforce-ux','icons','dist','salesforce-lightning-design-system-icons','utility-sprite','svg','symbols.svg');
7+
8+
var text = fs.readFileSync(inputPath,'utf8');
9+
10+
var content = [
11+
"/*\
12+
Copyright (c) 2015, salesforce.com, inc. All rights reserved.\
13+
\
14+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\
15+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\
16+
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.\
17+
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.\
18+
\
19+
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.\
20+
*/",
21+
"import React from 'react';",
22+
"module.exports = {",
23+
];
24+
25+
var sprite = JSON.parse(parser.toJson(text));
26+
27+
console.log(sprite.svg.symbol);
28+
29+
var icons = [];
30+
var viewbox;
31+
sprite.svg.symbol.forEach(function(symbol){
32+
var id = symbol.id;
33+
var paths = symbol.path;
34+
content.push(symbol.id+':'+JSON.stringify(symbol.path)+',');
35+
viewBox = symbol.viewBox;
36+
});
37+
content.push('};');
38+
content.push("module.exports.viewBox = '"+viewBox+"';");
39+
40+
41+
var outputPath = path.join(__dirname,'..','components','SLDSIcon','SVG','slds-icons-util.jsx');
42+
43+
fs.writeFile(outputPath, content.join('\n'), function (err) {
44+
if (err) return console.log(err);
45+
});
46+

0 commit comments

Comments
 (0)