Skip to content

Commit d10038f

Browse files
committed
inlined icons fixes
1 parent cb2396a commit d10038f

File tree

6 files changed

+25
-31
lines changed

6 files changed

+25
-31
lines changed

components/SLDSIcons.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const ButtonIcon = React.createClass({
2424
},
2525

2626
render() {
27-
const useTag = '<use xlink:href="'+SLDSSettings.getAssetsPath()+'/icons/' + this.props.category + '-sprite/svg/symbols.svg#' + this.props.name + '" />';
2827

2928
let className = 'slds-button__icon';
3029
if (this.props.variant !== 'icon') {
@@ -69,7 +68,10 @@ export const Icon = React.createClass({
6968

7069
render() {
7170

72-
const useTag = '<use xlink:href="'+SLDSSettings.getAssetsPath()+'/icons/' + this.props.category + '-sprite/svg/symbols.svg#' + this.props.name + '" />';
71+
const name = this.props.name.replace(/_/g,'-');
72+
const iconClassName = 'slds-icon-' + this.props.category + '-' + (this.props.theme || name);
73+
const styles = this.props.category === 'action'?{padding:'.5rem'}:null;
74+
7375
let className = 'slds-icon';
7476
if (this.props.stateful) {
7577
className += '--stateful';
@@ -83,11 +85,8 @@ export const Icon = React.createClass({
8385
if (this.props.position) {
8486
className += ' slds-icon--' + this.props.position;
8587
}
86-
className = className + ' slds-icon-' + this.props.category + '-' + (this.props.theme || this.props.name);
87-
// if(this.props.category === 'utility'){
88-
return <span className='slds-icon__container'><SLDSUtilityIcon name={this.props.name} category={this.props.category} aria-hidden='true' className={className} style={this.props.style} /></span>;
89-
// }
90-
// return <span className='slds-icon__container'><svg aria-hidden='true' className={className} style={this.props.style} dangerouslySetInnerHTML={{__html: useTag }} /></span>;
88+
className = className + ' ' + iconClassName;
89+
return <span className={'slds-icon__container '} style={styles}><SLDSUtilityIcon name={this.props.name} category={this.props.category} aria-hidden='true' className={className} style={this.props.style} /></span>;
9190
}
9291

9392
});
@@ -101,7 +100,6 @@ export const InputIcon = React.createClass({
101100
},
102101

103102
render() {
104-
const useTag = '<use xlink:href="'+SLDSSettings.getAssetsPath()+'icons/utility-sprite/svg/symbols.svg#' + this.props.name + '" />';
105103
const className = 'slds-input__icon slds-icon-text-default';
106104
return <SLDSUtilityIcon name={this.props.name} category={this.props.category} aria-hidden='true' className={className} />;
107105
}

dist/design-system-react.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,6 @@ return /******/ (function(modules) { // webpackBootstrap
34723472

34733473
// Utility Icon Reference: https://www.lightningdesignsystem.com/resources/icons#utility
34743474
render: function render() {
3475-
var useTag = '<use xlink:href="' + _SLDSSettings2['default'].getAssetsPath() + '/icons/' + this.props.category + '-sprite/svg/symbols.svg#' + this.props.name + '" />';
34763475

34773476
var className = 'slds-button__icon';
34783477
if (this.props.variant !== 'icon') {
@@ -3517,7 +3516,10 @@ return /******/ (function(modules) { // webpackBootstrap
35173516

35183517
render: function render() {
35193518

3520-
var useTag = '<use xlink:href="' + _SLDSSettings2['default'].getAssetsPath() + '/icons/' + this.props.category + '-sprite/svg/symbols.svg#' + this.props.name + '" />';
3519+
var name = this.props.name.replace(/_/g, '-');
3520+
var iconClassName = 'slds-icon-' + this.props.category + '-' + (this.props.theme || name);
3521+
var styles = this.props.category === 'action' ? { padding: '.5rem' } : null;
3522+
35213523
var className = 'slds-icon';
35223524
if (this.props.stateful) {
35233525
className += '--stateful';
@@ -3531,11 +3533,8 @@ return /******/ (function(modules) { // webpackBootstrap
35313533
if (this.props.position) {
35323534
className += ' slds-icon--' + this.props.position;
35333535
}
3534-
className = className + ' slds-icon-' + this.props.category + '-' + (this.props.theme || this.props.name);
3535-
// if(this.props.category === 'utility'){
3536-
return _react2['default'].createElement('span', { className: 'slds-icon__container' }, _react2['default'].createElement(_SLDSUtilityIcon2['default'], { name: this.props.name, category: this.props.category, 'aria-hidden': 'true', className: className, style: this.props.style }));
3537-
// }
3538-
// return <span className='slds-icon__container'><svg aria-hidden='true' className={className} style={this.props.style} dangerouslySetInnerHTML={{__html: useTag }} /></span>;
3536+
className = className + ' ' + iconClassName;
3537+
return _react2['default'].createElement('span', { className: 'slds-icon__container ', style: styles }, _react2['default'].createElement(_SLDSUtilityIcon2['default'], { name: this.props.name, category: this.props.category, 'aria-hidden': 'true', className: className, style: this.props.style }));
35393538
}
35403539

35413540
});
@@ -3551,7 +3550,6 @@ return /******/ (function(modules) { // webpackBootstrap
35513550
},
35523551

35533552
render: function render() {
3554-
var useTag = '<use xlink:href="' + _SLDSSettings2['default'].getAssetsPath() + 'icons/utility-sprite/svg/symbols.svg#' + this.props.name + '" />';
35553553
var className = 'slds-input__icon slds-icon-text-default';
35563554
return _react2['default'].createElement(_SLDSUtilityIcon2['default'], { name: this.props.name, category: this.props.category, 'aria-hidden': 'true', className: className });
35573555
}

dist/design-system-react.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)