Skip to content

Commit

Permalink
feat: ✨ progress style
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Oct 9, 2023
1 parent 3889172 commit 0b474bf
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/shiraha-ve/src/components/progress/global.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { globalStyle, keyframes } from '@vanilla-extract/css'

import * as styles from './styles'

const indeterminate = keyframes(styles.progressIndeterminateKeyframes)

globalStyle(':where(progress)', styles.progressGlobal)

globalStyle(':where(progress)::-webkit-progress-bar', styles.progressBar)

globalStyle(':where(progress)::-webkit-progress-value', styles.progressValue)

globalStyle(':where(progress)::-moz-progress-bar', styles.progressValue)

globalStyle(':where(progress):not([value])::before', styles.progressIndeterminate(indeterminate))
51 changes: 51 additions & 0 deletions packages/shiraha-ve/src/components/progress/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { ComplexStyleRule, keyframes } from '@vanilla-extract/css'

import { md } from '../../utils/md'
import { vars } from '../../vars.css'

export const progressGlobal = {
appearance: 'none',
backgroundColor: vars.color.surfaceContainerHighest,
height: 4,
overflow: 'hidden',
position: 'relative',
width: '100%',
} as const satisfies ComplexStyleRule

export const progressBar = {
backgroundColor: vars.color.surfaceContainerHighest,
} as const satisfies ComplexStyleRule

export const progressValue = {
backgroundColor: vars.color.primary,
} as const satisfies ComplexStyleRule

export const progressSelectors = {
selectors: {
'&::-moz-progress-bar': progressValue,
'&::-webkit-progress-bar': progressBar,
'&::-webkit-progress-value': progressValue,
},
} as const satisfies ComplexStyleRule

export const progress = {
...progressGlobal,
...progressSelectors,
} as const satisfies ComplexStyleRule

export const progressIndeterminate = (animationName: string) => ({
animation: `${animationName} 2s ${md.motion.standardDecelerate} infinite`,
backgroundColor: vars.color.primary,
content: '',
height: '100%',
left: 0,
position: 'absolute',
top: 0,
width: '100%',
willChange: 'left',
}) as const satisfies ComplexStyleRule

export const progressIndeterminateKeyframes = {
from: { left: '-100%' },
to: { left: '100%' },
} as const satisfies Parameters<typeof keyframes>[0]

0 comments on commit 0b474bf

Please sign in to comment.