-
Notifications
You must be signed in to change notification settings - Fork 24
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 #4203 from grommet/fix-status-color-example
Fix status color example
- Loading branch information
Showing
5 changed files
with
171 additions
and
125 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Box, Text } from 'grommet'; | ||
import { | ||
StatusCriticalSmall, | ||
StatusWarningSmall, | ||
StatusGoodSmall, | ||
StatusUnknownSmall, | ||
} from 'grommet-icons'; | ||
|
||
export const StatusExample = ({ color, hex }) => { | ||
let Icon; | ||
if (color.includes('critical')) Icon = StatusCriticalSmall; | ||
else if (color.includes('warning')) Icon = StatusWarningSmall; | ||
else if (color.includes('ok')) Icon = StatusGoodSmall; | ||
else if (color.includes('unknown')) Icon = StatusUnknownSmall; | ||
|
||
return ( | ||
<Box align="center" gap="small" margin={{ horizontal: 'small' }}> | ||
<Icon size="xxlarge" color={color} /> | ||
<Box align="center"> | ||
<Text color="text-strong" weight={600} size="small"> | ||
{color} | ||
</Text> | ||
<Text color="text" size="small"> | ||
{hex} | ||
</Text> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
StatusExample.propTypes = { | ||
color: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.shape({ | ||
dark: PropTypes.string, | ||
light: PropTypes.string, | ||
}), | ||
]), | ||
hex: PropTypes.string, | ||
}; |
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,4 +1,5 @@ | ||
export * from './ColorAccessibility'; | ||
export * from './ColorPalettes'; | ||
export * from './ElevationExample'; | ||
export * from './StatusExample'; | ||
export * from './TextExample'; |
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.