Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
361f692
commit 93151d0
Showing
9 changed files
with
188 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { get } from './get'; | ||
export { createSystem } from './createSystem'; | ||
export { createCss } from './createCss'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { createCss } from '../createCss'; | ||
import { space, color } from '../../props'; | ||
|
||
const breakpoints = [40, 52, 64].map((n) => n + 'em'); | ||
|
||
test('createCss returns a css parser', () => { | ||
const testCss = createCss({ ...space, ...color }); | ||
expect(typeof testCss).toBe('function'); | ||
// @ts-ignore | ||
const styles = testCss({ | ||
color: 'tomato', | ||
backgroundColor: '$primary', | ||
mx: '$2', | ||
opacity: 1, | ||
':hover': { | ||
opacity: 0.5, | ||
}, | ||
$bp1: { | ||
color: 'green', | ||
}, | ||
'@media and (min-width: 300px)': { | ||
mx: '$3', | ||
}, | ||
})({ | ||
theme: { | ||
breakpoints, | ||
mediaQueries: breakpoints.reduce((acc, bp, index) => { | ||
return { ...acc, [`bp${index + 1}`]: `@media and (min-width: ${bp})` }; | ||
}, {}), | ||
space: ['0px', '4px', '8px', '16px', '32px'], | ||
colors: { | ||
primary: 'rebeccapurple', | ||
}, | ||
}, | ||
}); | ||
expect(styles).toEqual({ | ||
color: 'tomato', | ||
backgroundColor: 'rebeccapurple', | ||
marginLeft: '8px', | ||
marginRight: '8px', | ||
opacity: 1, | ||
':hover': { | ||
opacity: 0.5, | ||
}, | ||
'@media and (min-width: 40em)': { | ||
color: 'green', | ||
}, | ||
'@media and (min-width: 300px)': { | ||
marginLeft: '16px', | ||
marginRight: '16px', | ||
}, | ||
}); | ||
}); | ||
|
||
test('createCss takes option to change token prefix', () => { | ||
const testCss = createCss( | ||
{ ...space, ...color }, | ||
{ tokenPrefix: 'noprefix' } | ||
); | ||
expect(typeof testCss).toBe('function'); | ||
// @ts-ignore | ||
const styles = testCss({ | ||
color: 'tomato', | ||
backgroundColor: 'primary', | ||
mx: 2, | ||
opacity: 1, | ||
':hover': { | ||
opacity: 0.5, | ||
}, | ||
bp1: { | ||
color: 'green', | ||
}, | ||
'@media and (min-width: 300px)': { | ||
mx: '3', | ||
}, | ||
})({ | ||
theme: { | ||
breakpoints, | ||
mediaQueries: breakpoints.reduce((acc, bp, index) => { | ||
return { ...acc, [`bp${index + 1}`]: `@media and (min-width: ${bp})` }; | ||
}, {}), | ||
space: ['0px', '4px', '8px', '16px', '32px'], | ||
colors: { | ||
primary: 'rebeccapurple', | ||
}, | ||
}, | ||
}); | ||
expect(styles).toEqual({ | ||
color: 'tomato', | ||
backgroundColor: 'rebeccapurple', | ||
marginLeft: '8px', | ||
marginRight: '8px', | ||
opacity: 1, | ||
':hover': { | ||
opacity: 0.5, | ||
}, | ||
'@media and (min-width: 40em)': { | ||
color: 'green', | ||
}, | ||
'@media and (min-width: 300px)': { | ||
marginLeft: '16px', | ||
marginRight: '16px', | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters