Skip to content

Commit

Permalink
Merge pull request #995 from primer/cb/ts-flash
Browse files Browse the repository at this point in the history
Migrate Flash to TypeScript
  • Loading branch information
smockle authored Jan 28, 2021
2 parents 8ae2b82 + a17cd37 commit 320c3b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
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
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.
File renamed without changes.

1 comment on commit 320c3b5

@vercel
Copy link

@vercel vercel bot commented on 320c3b5 Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.