You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario, I have a width property on a control. The user of the control can either pass in a classname or a pixel width. The rest of my themes are specified in the theme object as global classes. The theme function picks either style or className, but does not allow a mix.
Just ran into this problem, can be worked around with className hacks right now, but frustrating. Do you intend to add support for this @markdalgleish?
Scenario, I have a width property on a control. The user of the control can either pass in a classname or a pixel width. The rest of my themes are specified in the theme object as global classes. The theme function picks either style or className, but does not allow a mix.
Here is my re-write:
require('babel-polyfill');
function is_string(str) {
return (typeof(str) === 'string' || str instanceof String);
}
export default theme => (key, ...names) => {
const classes = names
.map(name => theme[name])
.filter(v => is_string(v))
.filter(v => v);
const styles = names
.map(name => theme[name])
.filter(v => !is_string(v))
.filter(v => v);
let result = { key: key };
if (classes.length > 0) result.className = classes.join(' ');
if (styles.length > 0) result.style = Object.assign({}, ...styles);
return result;
};
The text was updated successfully, but these errors were encountered: