Skip to content

Commit

Permalink
Merge pull request #1003 from primer/cb/ts-truncate
Browse files Browse the repository at this point in the history
Migrate Truncate to TypeScript
  • Loading branch information
colebemis committed Feb 2, 2021
2 parents cc3266c + b0cea82 commit 885e810
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-days-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Migrate `Truncate` to TypeScript
22 changes: 16 additions & 6 deletions src/Truncate.js → src/Truncate.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import styled from 'styled-components'
import {maxWidth} from 'styled-system'
import PropTypes from 'prop-types'
import {TYPOGRAPHY, COMMON} from './constants'
import styled from 'styled-components'
import {maxWidth, MaxWidthProps} from 'styled-system'
import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './constants'
import sx, {SxProp} from './sx'
import theme from './theme'
import sx from './sx'
import {ComponentProps} from './utils/types'

type StyledTruncateProps = {
title: string
inline?: boolean
expandable?: boolean
} & MaxWidthProps &
SystemTypographyProps &
SystemCommonProps &
SxProp

const Truncate = styled('div')`
const Truncate = styled.div<StyledTruncateProps>`
${TYPOGRAPHY}
${COMMON}
display: ${props => (props.inline ? 'inline-block' : 'inherit')};
Expand All @@ -19,7 +29,6 @@ const Truncate = styled('div')`
`

Truncate.defaultProps = {
as: 'div',
expandable: false,
inline: false,
maxWidth: 125,
Expand All @@ -37,4 +46,5 @@ Truncate.propTypes = {
title: PropTypes.string.isRequired
}

export type TruncateProps = ComponentProps<typeof Truncate>
export default Truncate
File renamed without changes.

1 comment on commit 885e810

@vercel
Copy link

@vercel vercel bot commented on 885e810 Feb 2, 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.