Skip to content

Commit

Permalink
test: add jsx() stories
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 13, 2018
1 parent 7721f0b commit cf2070f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .storybook/jsx.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {createElement as h} from 'react';
import {storiesOf} from '@storybook/react';
const {action} = require('@storybook/addon-actions');
const {linkTo} = require('@storybook/addon-links');
const {create} = require('../lib');

const renderer = create(h);
const {jsx} = renderer;

const RedBorder = jsx('div', {
border: '1px solid red'
});

storiesOf('jsx()', module)
.add('Default', () =>
h(RedBorder, null, 'Hello world')
)
.add('Custom CSS', () =>
h(RedBorder, {css: {fontWeight: 'bold'}}, 'Hello world')
)
.add('Inline styles', () =>
h(RedBorder, {style: {color: 'red'}, css: {fontWeight: 'bold'}}, 'Hello world')
)
2 changes: 1 addition & 1 deletion .storybook/rule.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const className1 = rule({
border: '1px solid red'
}, 'RedBorder');

storiesOf('Light/rule()', module)
storiesOf('rule()', module)
.add('Default', () =>
h('div', {className: className1}, 'Hello world')
)
2 changes: 1 addition & 1 deletion lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ exports.hash = function(styles) {
hash = (hash * 33) ^ str.charCodeAt(--i);
}

return '_' + (hash >>> 0);
return '_' + (hash >>> 0).toString(36);
};
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ exports.create = function (h) {
var dynamicClassName = fromCache(props.css);
delete copy.css;

copy.className = (props.className + '') + className + dynamicClassName;
copy.className = (props.className || '') + className + dynamicClassName;

return isElement ? h(fn, copy) : fn(copy);
};
Expand Down

0 comments on commit cf2070f

Please sign in to comment.