1
1
mirror of https://github.com/primer/css.git synced 2024-12-11 11:16:04 +03:00
css/docs/StatusLabel.js

33 lines
856 B
JavaScript
Raw Normal View History

2019-01-17 09:50:10 +03:00
import React from 'react'
import styled from 'styled-components'
import {BorderBox, StyledOcticon as Octicon, Text} from '@primer/components'
import {PrimitiveDot} from '@githubprimer/octicons-react'
const StyledLabel = styled(BorderBox)`
display: inline-block;
white-space: nowrap;
`
export const STATUS_COLORS = {
stable: 'green.6',
'new release': 'green.6',
experimental: 'yellow.7',
'in review': 'yellow.7',
deprecated: 'red.6'
}
export default function StatusLabel({status, children, ...rest}) {
return (
<StyledLabel px={2} py={1} {...rest}>
<Octicon icon={PrimitiveDot} color={getStatusColor(status)} mr={2} />
2019-01-17 09:46:10 +03:00
<Text color="black" fontSize={1}>
{children || status}
</Text>
</StyledLabel>
)
}
export function getStatusColor(status) {
return STATUS_COLORS[status.toLowerCase()] || 'gray.5'
}