Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Migrate Flash to TypeScript #995

Merged
merged 3 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dull-cheetahs-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Migrate `Flash` to TypeScript
smockle marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 11 additions & 15 deletions src/Flash.js → src/Flash.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {variant} from 'styled-system'
import {COMMON, get} from './constants'
import {COMMON, get, SystemCommonProps} from './constants'
import theme from './theme'
import sx from './sx'

const schemeMap = {
red: 'danger',
blue: 'default',
yellow: 'warning',
green: 'success'
}
import sx, {SxProp} from './sx'

const variants = variant({
scale: 'flash'
})

const getIconColor = (variant, theme) => get(`flashIcon.${variant}`)(theme)

const Flash = styled.div`
const Flash = styled.div<
{
variant?: 'default' | 'warning' | 'success' | 'danger'
full?: boolean
} & SystemCommonProps &
SxProp
>`
position: relative;
color: ${get('colors.text.grayDark')};
padding: ${get('space.3')};
Expand All @@ -32,12 +29,12 @@ const Flash = styled.div`
}

svg {
color: ${props => getIconColor(props.variant, props.theme)};
color: ${props => get(`flashIcon.${props.variant}`)(props.theme)};
margin-right: ${get('space.2')};
}

${COMMON};
${variants}
${variants};
${sx};
`

Expand All @@ -49,7 +46,6 @@ Flash.defaultProps = {
Flash.propTypes = {
children: PropTypes.node,
full: PropTypes.bool,
scheme: PropTypes.oneOf(Object.keys(schemeMap)), // deprecate 20.0.0
variant: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
...COMMON.propTypes,
...sx.propTypes
Expand Down
File renamed without changes.