-
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 #999 from primer/cb/ts-form-group
Migrate FormGroup to TypeScript
- Loading branch information
Showing
4 changed files
with
49 additions
and
43 deletions.
There are no files selected for viewing
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,47 @@ | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import {COMMON, get, TYPOGRAPHY, SystemCommonProps, SystemTypographyProps} from './constants' | ||
import theme from './theme' | ||
import sx, {SxProp} from './sx' | ||
import {ComponentProps} from './utils/types' | ||
|
||
const FormGroup = styled.div<SystemCommonProps & SxProp>` | ||
margin: ${get('space.3')} 0; | ||
font-weight: ${get('fontWeights.normal')}; | ||
${COMMON}; | ||
${sx}; | ||
` | ||
|
||
FormGroup.defaultProps = {theme} | ||
|
||
FormGroup.propTypes = { | ||
children: PropTypes.node, | ||
...COMMON.propTypes, | ||
...sx.propTypes | ||
} | ||
|
||
const FormGroupLabel = styled.label<SystemTypographyProps & SystemCommonProps & SxProp>` | ||
display: block; | ||
margin: 0 0 ${get('space.2')}; | ||
font-size: ${get('fontSizes.1')}; | ||
font-weight: ${get('fontWeights.bold')}; | ||
${TYPOGRAPHY}; | ||
${COMMON}; | ||
${sx}; | ||
` | ||
|
||
FormGroupLabel.displayName = 'FormGroup.Label' | ||
|
||
FormGroupLabel.defaultProps = { | ||
theme | ||
} | ||
|
||
FormGroupLabel.propTypes = { | ||
...TYPOGRAPHY.propTypes, | ||
...COMMON.propTypes, | ||
...sx.propTypes | ||
} | ||
|
||
export type FormGroupProps = ComponentProps<typeof FormGroup> | ||
export type FormGroupLabelProps = ComponentProps<typeof FormGroupLabel> | ||
export default Object.assign(FormGroup, {Label: FormGroupLabel}) |
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.