Skip to content

Commit

Permalink
feat: fix sheet() and add storeis
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 13, 2018
1 parent f135cc2 commit 923cced
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions .storybook/sheet.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import {storiesOf} from '@storybook/react';
const {action} = require('@storybook/addon-actions');
const {linkTo} = require('@storybook/addon-links');
const {create} = require('../lib');
const {addonSheet} = require('../addon/sheet');
const {addon} = require('../addon/sheet');

const renderer = create(h);
addonSheet(renderer);
addon(renderer);
const {sheet} = renderer;

const styles = sheet({
tomato: {
bd: '1px solid tomato',
border: '1px solid tomato',
},
yellow: {
bd: '1px solid yellow',
border: '1px solid yellow',
},
}, 'hello');


const styles2 = renderer.sheet({
tomato: {
bd: '1px solid tomato',
border: '1px solid tomato',
},
yellow: {
bd: '1px solid yellow',
border: '1px solid yellow',
},
});

Expand Down
4 changes: 2 additions & 2 deletions .storybook/styled.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {storiesOf} from '@storybook/react';
const {action} = require('@storybook/addon-actions');
const {linkTo} = require('@storybook/addon-links');
const {create} = require('../lib');
const {addonStyled} = require('../addon/styled');
const {addon} = require('../addon/styled');

const renderer = create(h);
addonStyled(renderer);
addon(renderer);
const {styled} = renderer;

const RedBorder = styled('div', {
Expand Down
8 changes: 4 additions & 4 deletions addon/sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

var hash = require('../lib/hash').hash;

exports.addonSheet = function (renderer) {
exports.addon = function (renderer) {
renderer.sheet = function (map, block) {
var result = {};

if (!block) {
block = hash(map);
}

function onElementModifiler (elementModifier) {
var onElementModifier = function (elementModifier) {
var styles = map[elementModifier];

Object.defineProperty(result, elementModifier, {
Expand All @@ -25,10 +25,10 @@ exports.addonSheet = function (renderer) {
return classNames;
},
});
}
};

for (var elementModifier in map) {
onElementModifiler(elementModifier);
onElementModifier(elementModifier);
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion addon/styled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

exports.addonStyled = function (renderer) {
exports.addon = function (renderer) {
renderer.styled = function (fn, styles, dynamicTemplate, block) {
var jsxComponent = renderer.jsx(fn, styles, block);

Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ exports.create = function (h) {
raw: '',
cns: {},
pfx: '_',
cnt: 0
cnt: 0,
hash: hash,
};

var putRaw;
Expand Down

0 comments on commit 923cced

Please sign in to comment.