-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #993 from primer/cb/ts-styled-octicon
Migrate StyledOcticon to TypeScript
- Loading branch information
Showing
5 changed files
with
41 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/components": patch | ||
--- | ||
|
||
Migrate `StyledOcticon` to TypeScript |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import {COMMON, SystemCommonProps} from './constants' | ||
import theme from './theme' | ||
import sx, {SxProp} from './sx' | ||
import {IconProps} from '@primer/octicons-react' | ||
import {ComponentProps} from './utils/types' | ||
|
||
type OcticonProps = {icon: React.ElementType} & IconProps | ||
|
||
function Octicon({icon: IconComponent, ...rest}: OcticonProps) { | ||
return <IconComponent {...rest} /> | ||
} | ||
|
||
const StyledOcticon = styled(Octicon)<SystemCommonProps & SxProp>` | ||
${COMMON} | ||
${sx} | ||
` | ||
|
||
StyledOcticon.defaultProps = { | ||
theme, | ||
size: 16 | ||
} | ||
|
||
StyledOcticon.propTypes = { | ||
...COMMON.propTypes, | ||
...sx.propTypes, | ||
icon: PropTypes.any.isRequired, | ||
size: PropTypes.any, | ||
theme: PropTypes.object, | ||
verticalAlign: PropTypes.oneOf(['middle', 'text-bottom', 'text-top', 'top']) | ||
} | ||
|
||
export type StyledOcticonProps = ComponentProps<typeof StyledOcticon> | ||
export default StyledOcticon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
62f0925
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: