Skip to content

Commit

Permalink
Merge pull request #1008 from primer/cb/ts-state-label
Browse files Browse the repository at this point in the history
Migrate StateLabel to TypeScript
  • Loading branch information
colebemis authored Feb 4, 2021
2 parents 1c71758 + 7310f8e commit 7884c6c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-carpets-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Migrate `StateLabel` to TypeScript
22 changes: 14 additions & 8 deletions src/StateLabel.js → src/StateLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'
import { GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon, QuestionIcon } from '@primer/octicons-react'
import PropTypes from 'prop-types'
import React from 'react'
import styled from 'styled-components'
import {GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon, QuestionIcon} from '@primer/octicons-react'
import {variant} from 'styled-system'
import theme from './theme'
import {COMMON, get} from './constants'
import { variant } from 'styled-system'
import { COMMON, get, SystemCommonProps } from './constants'
import StyledOcticon from './StyledOcticon'
import sx from './sx'
import sx, { SxProp } from './sx'
import theme from './theme'
import { ComponentProps } from './utils/types'

const octiconMap = {
issueOpened: IssueOpenedIcon,
Expand All @@ -27,7 +28,10 @@ const sizeVariants = variant({
scale: 'stateLabels.sizes'
})

const StateLabelBase = styled.span`
type StyledStateLabelBaseProps = {
variant?: 'small' | 'normal'; status?: keyof typeof octiconMap} & SystemCommonProps & SxProp

const StateLabelBase = styled.span<StyledStateLabelBaseProps>`
display: inline-flex;
align-items: center;
font-weight: 600;
Expand All @@ -41,7 +45,9 @@ const StateLabelBase = styled.span`
${sx};
`

function StateLabel({children, status, variant, ...rest}) {
export type StateLabelProps = ComponentProps<typeof StateLabelBase>

function StateLabel({children, status, variant, ...rest}: StateLabelProps) {
const octiconProps = variant === 'small' ? {width: '1em'} : {}
return (
<StateLabelBase {...rest} variant={variant} status={status}>
Expand Down
File renamed without changes.

1 comment on commit 7884c6c

@vercel
Copy link

@vercel vercel bot commented on 7884c6c Feb 4, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.