Skip to content

Commit

Permalink
fix: fix atoms addon
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 13, 2018
1 parent edc5d59 commit 7bac059
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions .storybook/atoms.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 {addon} = require('../addon/atoms');

const renderer = create(h);
addon(renderer);
const {rule} = renderer;

const className = rule({
bd: '1px solid red'
}, 'atoms');

storiesOf('Atoms', module)
.add('Default', () =>
h('div', {className}, 'Red')
)
6 changes: 3 additions & 3 deletions addon/atoms.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var atoms = {
};

exports.addon = function (renderer) {
var originalKey = renderer.key;
renderer.key = function (key, value) {
return originalKey(atoms[key] || key, value);
var originalDecl = renderer.decl;
renderer.decl = function (key, value) {
return originalDecl(atoms[key] || key, value);
};
};
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports.create = function (h) {
var fromCache = function (styles) {
if (!styles) return '';

var key = hash(styles);
var key = renderer.hash(styles);

if (!cache[key]) {
cache[key] = renderer.rule(styles, key);
Expand All @@ -71,7 +71,7 @@ exports.create = function (h) {

renderer.rule = function(styles, block) {
if (!block) {
block = hash(styles);
block = renderer.hash(styles);
}

if (isClient) {
Expand Down

0 comments on commit 7bac059

Please sign in to comment.