Skip to content

Commit

Permalink
feat: added inline variants support (#334)
Browse files Browse the repository at this point in the history
Solves #333
  • Loading branch information
jguddas committed Apr 15, 2022
1 parent 4dac9a3 commit acfa364
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/system/src/style.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ describe('#style', () => {
states: { hover: '&:hover', first: '&:first-child' },
screens: { _: 0, md: 400 },
}
expect(fontFamily({ fontFamily: { '&:empty': 'title' }, theme })).toEqual({
'&:empty': {
fontFamily: 'title',
},
})
expect(fontFamily({ fontFamily: { hover: 'title' }, theme })).toEqual({
'&:hover': {
fontFamily: 'title',
Expand Down Expand Up @@ -164,6 +169,14 @@ describe('#style', () => {
fontFamily: 'title',
},
})
expect(fontFamily({
fontFamily: { '@media (min-width: 355px)': 'title' },
theme
})).toEqual({
'@media (min-width: 355px)': {
fontFamily: 'title',
},
})
})

it('works with a theme', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/system/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const reduceVariants = <T extends Props>(
for (const value in values) {
const style = getStyle(values[value])
if (style === null) continue
const state = variants[value]
const state = value in variants ? variants[value] : value
if (state === undefined) continue
if (state === null) {
styles = merge(styles, style)
Expand Down

0 comments on commit acfa364

Please sign in to comment.