-
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.
Merge branch 'develop' into header-responsive
- Loading branch information
Showing
9 changed files
with
1,914 additions
and
170 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Empty file.
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,20 @@ | ||
import { StoryObj, Meta } from "@storybook/react"; | ||
import { Loader } from "./Loader"; | ||
|
||
export default { | ||
component: Loader, | ||
} as Meta<typeof Loader>; | ||
type Story = StoryObj<typeof Loader>; | ||
|
||
export const IndeterminateLoader: Story = { | ||
args: { | ||
variant: "indeterminate" | ||
}, | ||
}; | ||
|
||
export const DeterminateLoader: Story = { | ||
args: { | ||
variant: "determinate", | ||
value: 17 | ||
}, | ||
}; |
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,27 @@ | ||
import renderer from "react-test-renderer" | ||
import { Loader } from "./Loader" | ||
|
||
describe('Loader', () => { | ||
|
||
test('Indeterminate Loader component renders correctly', () => { | ||
const component = renderer.create( | ||
<Loader variant="indeterminate" /> | ||
) | ||
|
||
const tree = component.toJSON() | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('Determinate Loader component renders correctly', () => { | ||
|
||
const component = renderer.create( | ||
<Loader variant={'determinate'} value={17} /> | ||
) | ||
|
||
const tree = component.toJSON() | ||
|
||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
}) |
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,61 @@ | ||
import CircularProgress, { CircularProgressProps } from '@mui/material/CircularProgress'; | ||
import Typography from '@mui/material/Typography'; | ||
import Box from '@mui/material/Box'; | ||
import { ReactElement } from "react"; | ||
|
||
type DeterminateLoaderProps = { | ||
variant: 'determinate' | ||
/** Progress value to display */ | ||
value: number; | ||
}; | ||
|
||
type IndeterminateLoaderProps = { | ||
variant: 'indeterminate' | ||
} | ||
|
||
type LoaderProps = DeterminateLoaderProps | IndeterminateLoaderProps; | ||
|
||
function CircularProgressWithLabel( | ||
props: CircularProgressProps & { value: number }, | ||
) { | ||
return ( | ||
<Box sx={{ position: 'relative', display: 'inline-flex' }}> | ||
<CircularProgress variant="determinate" {...props} /> | ||
<Box | ||
sx={{ | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0, | ||
position: 'absolute', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<Typography | ||
variant="caption" | ||
component="div" | ||
color="text.secondary" | ||
>{`${Math.round(props.value)}%`}</Typography> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
/** | ||
* A basic determinate or indeterminate loader | ||
*/ | ||
export const Loader = (props: LoaderProps) => { | ||
|
||
let progressComponent:ReactElement; | ||
if( props.variant == "determinate") { | ||
progressComponent = <CircularProgressWithLabel value={props.value}/> | ||
} else { | ||
progressComponent = <CircularProgress /> | ||
} | ||
|
||
return ( | ||
progressComponent | ||
); | ||
}; |
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 "./Loader"; |
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