-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5137.4 #5322
Merged
5137.4 #5322
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2f670d4
Rename translation
roxy-dao 71dab01
Bar only bar
roxy-dao a2dd85c
Change response store stats UI
roxy-dao 87ac18d
Add our store stats as popover
roxy-dao 508317c
Merge branch '5137.3' into 5137.4
roxy-dao dbcfb86
Merge branch '5137.3' into 5137.4
roxy-dao ca5f271
Hide requested if no requested
roxy-dao 97e357f
Make text width longer
roxy-dao 2b2bd8c
Show item details in request store stats
roxy-dao 9794b01
Show requesting store stats next to requested quantity
roxy-dao 1bdd6ae
Fix condition used for revealing requested
roxy-dao 654be3d
Fix typo
roxy-dao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'; |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed cause it's other-requested