-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create circular progress indicator (#95)
- Loading branch information
Fran McDade
authored and
Fran McDade
committed
Jun 6, 2024
1 parent
d430305
commit 8016af1
Showing
8 changed files
with
132 additions
and
6 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/components/common/Progress/components/CircularProgress/circularProgress.styles.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,6 @@ | ||
import styled from "@emotion/styled"; | ||
|
||
export const ProgressPositioner = styled.div` | ||
display: flex; | ||
position: relative; /* positions track */ | ||
`; |
26 changes: 26 additions & 0 deletions
26
src/components/common/Progress/components/CircularProgress/circularProgress.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,26 @@ | ||
import { | ||
CircularProgress as MCircularProgress, | ||
CircularProgressProps as MCircularProgressProps, | ||
} from "@mui/material"; | ||
import React, { ElementType } from "react"; | ||
import { ProgressPositioner } from "./circularProgress.styles"; | ||
import { CircularProgressTrack } from "./components/CircularProgressTrack/circularProgressTrack"; | ||
|
||
export interface CircularProgressProps extends MCircularProgressProps { | ||
className?: string; | ||
Track?: ElementType<CircularProgressProps>; | ||
} | ||
|
||
export const CircularProgress = ({ | ||
className, | ||
value, | ||
Track = CircularProgressTrack, | ||
...props /* Spread props to allow for CircularProgress specific props e.g. "disableShrink". */ | ||
}: CircularProgressProps): JSX.Element => { | ||
return ( | ||
<ProgressPositioner className={className}> | ||
<Track {...props} /> | ||
<MCircularProgress value={value} {...props} /> | ||
</ProgressPositioner> | ||
); | ||
}; |
33 changes: 33 additions & 0 deletions
33
...ponents/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.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,33 @@ | ||
import styled from "@emotion/styled"; | ||
import { CircularProgress as MCircularProgress } from "@mui/material"; | ||
import { | ||
alertLight, | ||
infoLight, | ||
smokeLight, | ||
successLight, | ||
warningLight, | ||
} from "../../../../../../../styles/common/mixins/colors"; | ||
|
||
export const CircularProgress = styled(MCircularProgress)` | ||
color: ${smokeLight}; | ||
left: 0; | ||
position: absolute; | ||
top: 0; | ||
z-index: 0; | ||
&.MuiCircularProgress-colorAlert { | ||
color: ${alertLight}; | ||
} | ||
&.MuiCircularProgress-colorInfo { | ||
color: ${infoLight}; | ||
} | ||
&.MuiCircularProgress-colorSuccess { | ||
color: ${successLight}; | ||
} | ||
&.MuiCircularProgress-colorWarning { | ||
color: ${warningLight}; | ||
} | ||
`; |
23 changes: 23 additions & 0 deletions
23
...ss/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.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,23 @@ | ||
import { CircularProgressProps as MCircularProgressProps } from "@mui/material"; | ||
import React, { Fragment } from "react"; | ||
import { CircularProgress } from "./circularProgressTrack.styles"; | ||
|
||
export interface CircularProgressTrackProps extends MCircularProgressProps { | ||
className?: string; | ||
track?: boolean; | ||
} | ||
|
||
export const CircularProgressTrack = ({ | ||
className, | ||
track = true, | ||
value = 100, | ||
...props /* Spread props to allow for CircularProgress specific props e.g. "disableShrink". */ | ||
}: CircularProgressTrackProps): JSX.Element => { | ||
return ( | ||
<Fragment> | ||
{track && ( | ||
<CircularProgress className={className} value={value} {...props} /> | ||
)} | ||
</Fragment> | ||
); | ||
}; |
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