Skip to content

Commit

Permalink
feat: pass entire theme to css fn
Browse files Browse the repository at this point in the history
Previously, only tokens were passed to functions passed to css(), but
this meant that breakpoints weren't accessible. Might as well pass the
entire theme object, just in case it's helpful.
  • Loading branch information
estrattonbailey committed Mar 25, 2021
1 parent e240017 commit 7cf6cb0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function hypostyle (theme = {}, config = {}) {

return {
css (props) {
const p = typeof props === 'function' ? props(t.tokens) : props
const p = typeof props === 'function' ? props(t) : props
return Object.keys(p).length ? nano.rule(style(p, t)) : ''
},
injectGlobal (props) {
Expand Down
2 changes: 1 addition & 1 deletion test/hypostyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default (test, assert) => {
test('css as a function', () => {
const { css, flush } = hypostyle(defaults)

css(tokens => ({ fs: tokens.fontSize[1] }))
css(theme => ({ fs: theme.tokens.fontSize[1] }))

const sheet = flush()

Expand Down

0 comments on commit 7cf6cb0

Please sign in to comment.