-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate button components to TypeScript
- Loading branch information
Showing
14 changed files
with
107 additions
and
137 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': major | ||
--- | ||
|
||
Migrate button components to TypeScript |
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
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
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,40 @@ | ||
import {COMMON, LAYOUT, get, SystemLayoutProps, SystemCommonProps} from '../constants' | ||
import defaultTheme from '../theme' | ||
import sx, {SxProp} from '../sx' | ||
import {XIcon} from '@primer/octicons-react' | ||
import React, {forwardRef} from 'react' | ||
import styled from 'styled-components' | ||
import {ComponentProps} from '../utils/types' | ||
|
||
type StyledButtonInternalProps = SystemCommonProps & SystemLayoutProps & SxProp | ||
|
||
const StyledButton = styled.button<StyledButtonInternalProps>` | ||
border: none; | ||
padding: 0; | ||
background: transparent; | ||
outline: none; | ||
cursor: pointer; | ||
&:focus { | ||
box-shadow: ${get('buttons.close.shadow.focus')}; | ||
} | ||
&:active { | ||
color: ${get('buttons.close.color.default')}; | ||
} | ||
${COMMON}; | ||
${LAYOUT}; | ||
${sx}; | ||
` | ||
|
||
export type StyledButtonProps = ComponentProps<typeof StyledButton> | ||
|
||
export const ButtonClose = forwardRef<HTMLButtonElement, StyledButtonProps>(({theme = defaultTheme, ...props}, ref) => { | ||
return ( | ||
<StyledButton ref={ref} aria-label="Close" {...{theme, ...props}}> | ||
<XIcon /> | ||
</StyledButton> | ||
) | ||
}) | ||
|
||
export type ButtonCloseProps = ComponentProps<typeof ButtonClose> |
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
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
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
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
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.
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
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,9 @@ | ||
export {Button as default} from './Button' | ||
export {Button} from './Button' | ||
export {ButtonDanger} from './ButtonDanger' | ||
export {ButtonGroup} from './ButtonGroup' | ||
export {ButtonOutline} from './ButtonOutline' | ||
export {ButtonPrimary} from './ButtonPrimary' | ||
export {ButtonInvisible} from './ButtonInvisible' | ||
export {ButtonTableList} from './ButtonTableList' | ||
export {ButtonClose} from './ButtonClose' |