-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(suite): Fix firmware update progress bar
- Loading branch information
Showing
3 changed files
with
64 additions
and
71 deletions.
There are no files selected for viewing
49 changes: 36 additions & 13 deletions
49
packages/components/src/components/loaders/ProgressBar/ProgressBar.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 |
---|---|---|
@@ -1,35 +1,58 @@ | ||
import styled from 'styled-components'; | ||
import styled, { useTheme } from 'styled-components'; | ||
|
||
const Wrapper = styled.div` | ||
background: ${({ theme }) => theme.backgroundNeutralSubdued}; | ||
import { CSSColor } from '@trezor/theme'; | ||
|
||
const Wrapper = styled.div<{ $color: CSSColor }>` | ||
background: ${({ $color }) => $color}; | ||
width: 100%; | ||
overflow: hidden; | ||
`; | ||
|
||
type ValueProps = { | ||
$max: number; | ||
$value: number; | ||
$color: CSSColor; | ||
}; | ||
|
||
const Value = styled.div<ValueProps>` | ||
background: ${({ theme }) => theme.iconPrimaryDefault}; | ||
background: ${({ $color }) => $color}; | ||
height: 5px; | ||
max-width: 100%; | ||
width: 1%; | ||
transform: ${({ $max, $value }) => `scaleX(${(100 / $max) * $value})`}; | ||
transform-origin: left; | ||
transition: transform 0.5s; | ||
width: ${({ $max, $value }) => `calc((100% / ${$max}) * ${$value})`}; | ||
transition: width 0.5s; | ||
`; | ||
|
||
export type ProgressBarProps = { | ||
max?: number; | ||
value: number; | ||
backgroundColor?: CSSColor; | ||
foregroundColor?: CSSColor; | ||
'data-testid'?: string; | ||
/** | ||
* @deprecated Legacy prop - do not add non-standard properties | ||
*/ | ||
className?: string; | ||
}; | ||
|
||
export const ProgressBar = ({ max = 100, value, ...props }: ProgressBarProps) => ( | ||
<Wrapper {...props}> | ||
<Value $max={max} $value={value} /> | ||
</Wrapper> | ||
); | ||
export const ProgressBar = ({ | ||
max = 100, | ||
value, | ||
backgroundColor, | ||
foregroundColor, | ||
className, | ||
'data-testid': dataTestId, | ||
}: ProgressBarProps) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<Wrapper | ||
$color={backgroundColor || theme.backgroundNeutralSubdued} | ||
data-testid={dataTestId} | ||
className={className} | ||
> | ||
<Value $max={max} $value={value} $color={foregroundColor || theme.iconPrimaryDefault} /> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
ProgressBar.Value = Value; |
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