From 6743e2b0146e7d017de78f1ff0f0380830acd1d0 Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Sat, 22 Oct 2016 09:45:41 +0200 Subject: [PATCH] Exposing glamor style as default allowing different ways to import the css helpers --- lib/css.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/css.js b/lib/css.js index ead82183548ec01..50e2d47574b6975 100644 --- a/lib/css.js +++ b/lib/css.js @@ -1 +1,20 @@ -module.exports = require('glamor') +const css = require('glamor') + +/** + * Expose style as default and the whole object as properties + * so it can be used as follows: + * + * import css, { merge } from 'next/css' + * css({ color: 'red' }) + * merge({ color: 'green' }) + * css.merge({ color: 'blue' }) + */ + +css.default = css.style +Object.keys(css).forEach(key => { + if (key !== 'default') { + css.default[key] = css[key] + } +}) + +module.exports = css