-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5322 from msupply-foundation/5137.4
5137.4
- Loading branch information
Showing
14 changed files
with
515 additions
and
143 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
37 changes: 37 additions & 0 deletions
37
client/packages/common/src/ui/components/charts/NewValueBar/NewValueBar.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,37 @@ | ||
import React from 'react'; | ||
import { Box } from '@mui/material'; | ||
import { StoryFn, Meta } from '@storybook/react'; | ||
import { NewValueBar } from './NewValueBar'; | ||
|
||
const Template: StoryFn<typeof NewValueBar> = ({ value, total, colour }) => ( | ||
<Box display="flex" width="25%"> | ||
<NewValueBar value={value} total={total} colour={colour} /> | ||
</Box> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
export const NoDividers = Template.bind({}); | ||
export const BothDividers = Template.bind({}); | ||
|
||
Default.args = { | ||
value: 10, | ||
total: 20, | ||
colour: 'gray.main', | ||
}; | ||
|
||
NoDividers.args = { | ||
value: 10, | ||
total: 20, | ||
colour: 'gray.main', | ||
}; | ||
|
||
BothDividers.args = { | ||
value: 10, | ||
total: 20, | ||
colour: 'gray.main', | ||
}; | ||
|
||
export default { | ||
title: 'Charts/ValueBar', | ||
component: NewValueBar, | ||
} as Meta<typeof NewValueBar>; |
44 changes: 44 additions & 0 deletions
44
client/packages/common/src/ui/components/charts/NewValueBar/NewValueBar.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,44 @@ | ||
import React from 'react'; | ||
import { Box, Typography } from '@openmsupply-client/common'; | ||
import { useFormatNumber } from '@common/intl'; | ||
|
||
const MIN_FLEX_BASIS_TO_SHOW_VALUE = 5; | ||
|
||
interface ValueBarProps { | ||
value: number; | ||
total: number; | ||
colour: string; | ||
} | ||
|
||
export const NewValueBar = ({ value, total, colour }: ValueBarProps) => { | ||
const formatNumber = useFormatNumber(); | ||
if (value === 0) return null; | ||
|
||
const flexBasis = Math.min(Math.round((100 * value) / total), 100); | ||
|
||
return ( | ||
<> | ||
<Box display="flex" flexDirection="column" width="100%"> | ||
<Box flexBasis={`${flexBasis}%`} flexGrow={1}> | ||
<Box sx={{ backgroundColor: colour, height: '20px' }}> | ||
{flexBasis > MIN_FLEX_BASIS_TO_SHOW_VALUE ? ( | ||
<Typography | ||
fontSize={12} | ||
sx={{ | ||
color: 'primary.contrastText', | ||
flex: 1, | ||
justifyContent: 'center', | ||
display: 'flex', | ||
fontWeight: 'bold', | ||
}} | ||
component="div" | ||
> | ||
{formatNumber.round(value)} | ||
</Typography> | ||
) : null} | ||
</Box> | ||
</Box> | ||
</Box> | ||
</> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
client/packages/common/src/ui/components/charts/NewValueBar/index.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 @@ | ||
export * from './NewValueBar'; |
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 |
---|---|---|
|
@@ -39,3 +39,4 @@ export { | |
}; | ||
|
||
export * from './ValueBar'; | ||
export * from './NewValueBar'; |
108 changes: 0 additions & 108 deletions
108
...kages/requisitions/src/ResponseRequisition/DetailView/ReponseStats/ResponseStoreStats.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.