-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Showing
67 changed files
with
3,205 additions
and
921 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './progress'; |
71 changes: 71 additions & 0 deletions
71
packages/frontend/component/src/ui/progress/progress.css.ts
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,71 @@ | ||
import { cssVar } from '@toeverything/theme'; | ||
import { cssVarV2 } from '@toeverything/theme/v2'; | ||
import { createVar, style } from '@vanilla-extract/css'; | ||
|
||
const progressHeight = createVar(); | ||
|
||
export const root = style({ | ||
height: '20px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
width: 240, | ||
gap: 12, | ||
vars: { | ||
[progressHeight]: '10px', | ||
}, | ||
}); | ||
|
||
export const progress = style({ | ||
height: progressHeight, | ||
flex: 1, | ||
background: cssVarV2('layer/background/hoverOverlay'), | ||
borderRadius: 5, | ||
position: 'relative', | ||
}); | ||
|
||
export const sliderRoot = style({ | ||
height: progressHeight, | ||
width: '100%', | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
}); | ||
|
||
export const thumb = style({ | ||
width: '4px', | ||
height: `calc(${progressHeight} + 2px)`, | ||
transform: 'translateY(-1px)', | ||
borderRadius: '2px', | ||
display: 'block', | ||
background: cssVarV2('layer/insideBorder/primaryBorder'), | ||
opacity: 0, | ||
selectors: { | ||
[`${root}:hover &, &:is(:focus-visible, :focus-within)`]: { | ||
opacity: 1, | ||
}, | ||
}, | ||
}); | ||
|
||
export const label = style({ | ||
width: '40px', | ||
fontSize: cssVar('fontSm'), | ||
}); | ||
|
||
export const indicator = style({ | ||
height: '100%', | ||
width: '100%', | ||
borderRadius: 5, | ||
background: cssVarV2('toast/iconState/regular'), | ||
transition: 'background 0.2s ease-in-out', | ||
selectors: { | ||
[`${root}:hover &, &:has(${thumb}:is(:focus-visible, :focus-within, :active))`]: | ||
{ | ||
borderTopRightRadius: 0, | ||
borderBottomRightRadius: 0, | ||
}, | ||
[`[data-state="complete"]&`]: { | ||
background: cssVarV2('status/success'), | ||
}, | ||
}, | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/frontend/component/src/ui/progress/progress.stories.tsx
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,19 @@ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import { useState } from 'react'; | ||
|
||
import type { ProgressProps } from './progress'; | ||
import { Progress } from './progress'; | ||
|
||
export default { | ||
title: 'UI/Progress', | ||
component: Progress, | ||
} satisfies Meta<typeof Progress>; | ||
|
||
const Template: StoryFn<ProgressProps> = () => { | ||
const [value, setValue] = useState<number>(30); | ||
return ( | ||
<Progress style={{ width: '200px' }} value={value} onChange={setValue} /> | ||
); | ||
}; | ||
|
||
export const Default: StoryFn<ProgressProps> = Template.bind(undefined); |
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,51 @@ | ||
import * as RadixProgress from '@radix-ui/react-progress'; | ||
import * as RadixSlider from '@radix-ui/react-slider'; | ||
import clsx from 'clsx'; | ||
|
||
import * as styles from './progress.css'; | ||
|
||
export interface ProgressProps { | ||
/** | ||
* The value of the progress bar. | ||
* A value between 0 and 100. | ||
*/ | ||
value: number; | ||
onChange?: (value: number) => void; | ||
onBlur?: () => void; | ||
readonly?: boolean; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
export const Progress = ({ | ||
value, | ||
onChange, | ||
onBlur, | ||
readonly, | ||
className, | ||
style, | ||
}: ProgressProps) => { | ||
return ( | ||
<div className={clsx(styles.root, className)} style={style}> | ||
<RadixProgress.Root className={styles.progress} value={value}> | ||
<RadixProgress.Indicator | ||
className={styles.indicator} | ||
style={{ width: `${value}%` }} | ||
/> | ||
{!readonly ? ( | ||
<RadixSlider.Root | ||
className={styles.sliderRoot} | ||
min={0} | ||
max={100} | ||
value={[value]} | ||
onValueChange={values => onChange?.(values[0])} | ||
onBlur={onBlur} | ||
> | ||
<RadixSlider.Thumb className={styles.thumb} /> | ||
</RadixSlider.Root> | ||
) : null} | ||
</RadixProgress.Root> | ||
<div className={styles.label}>{value}%</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.