-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(site): add styleVariants, change createVar to assignVars, ch…
…ange to iife, take unity (#1452) Co-authored-by: Adam Skoufis <[email protected]>
- Loading branch information
Showing
5 changed files
with
44 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
import { style, styleVariants } from '@vanilla-extract/css'; | ||
|
||
export const root = style({ | ||
transition: 'transform .15s ease', | ||
position: 'relative', | ||
top: '1px', | ||
}); | ||
|
||
export const direction = { | ||
down: null, | ||
up: style({ transform: 'rotate(180deg)' }), | ||
left: style({ transform: 'rotate(90deg)' }), | ||
right: style({ transform: 'rotate(270deg)' }), | ||
}; | ||
export const direction = styleVariants({ | ||
down: {}, | ||
up: { transform: 'rotate(180deg)' }, | ||
left: { transform: 'rotate(90deg)' }, | ||
right: { transform: 'rotate(270deg)' }, | ||
}); |
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,35 +1,41 @@ | ||
import { createVar, style } from '@vanilla-extract/css'; | ||
import { assignVars, createThemeContract, style } from '@vanilla-extract/css'; | ||
import { darkMode } from '../system/styles/sprinkles.css'; | ||
import { vars } from '../themes.css'; | ||
|
||
const toggleBrightness = createVar(); | ||
const toggleContent = createVar(); | ||
const focusRingColor = createVar(); | ||
const themeVars = createThemeContract({ | ||
toggleBrightness: null, | ||
toggleContent: null, | ||
focusRingColor: null, | ||
}); | ||
|
||
const lightVars = assignVars(themeVars, { | ||
toggleBrightness: '0', | ||
toggleContent: '"☀️"', | ||
focusRingColor: vars.palette.pink400, | ||
}); | ||
|
||
const darkVars = assignVars(themeVars, { | ||
toggleBrightness: '10', | ||
toggleContent: '"🌙"', | ||
focusRingColor: vars.palette.pink500, | ||
}); | ||
|
||
export const root = style({ | ||
outline: 'none', | ||
fontSize: 24, | ||
height: 42, | ||
width: 42, | ||
vars: { | ||
[toggleBrightness]: '0', | ||
[toggleContent]: '"☀️"', | ||
[focusRingColor]: vars.palette.pink400, | ||
}, | ||
vars: lightVars, | ||
':focus-visible': { | ||
boxShadow: `0px 0px 0px 3px ${focusRingColor}`, | ||
boxShadow: `0px 0px 0px 3px ${themeVars.focusRingColor}`, | ||
}, | ||
'::before': { | ||
content: toggleContent, | ||
filter: `contrast(0) brightness(${toggleBrightness})`, | ||
content: themeVars.toggleContent, | ||
filter: `contrast(0) brightness(${themeVars.toggleBrightness})`, | ||
}, | ||
selectors: { | ||
[`.${darkMode} &`]: { | ||
vars: { | ||
[toggleBrightness]: '10', | ||
[toggleContent]: '"🌙"', | ||
[focusRingColor]: vars.palette.pink500, | ||
}, | ||
vars: darkVars, | ||
}, | ||
}, | ||
}); |
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