-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(FormControl): update existing code for sub-components to pre…
…p for migration (#5342) * refactor(FormControl): update InputLabel, InputCaption * chore: add explicit packageManager for corepack * refactor(FormControl): update LeadingVisual * refactor(InputValidation): update InputValidation * refactor: avoid inline style * revert: move back InputLabel * chore: update import for InputLabel * chore: add changeset * Update packages/react/src/internal/components/InputLabel.tsx Co-authored-by: Jon Rohan <[email protected]> --------- Co-authored-by: Jon Rohan <[email protected]>
- Loading branch information
Showing
13 changed files
with
199 additions
and
136 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/react": minor | ||
--- | ||
|
||
Update FormControl sub-components to use new styled components format for migration |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
|
@@ -93,5 +93,6 @@ | |
"webpack": false, | ||
"running": false | ||
} | ||
] | ||
], | ||
"packageManager": "[email protected]+sha512.c89530d37c4baa38afd43e76a077a84b9aa63840b986426584fd5c5a54ab0a0b21bb1595c851042b733784b0b43706d36a494b4d8ae1a086a762cb8d3f95942a" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react' | ||
import type {SxProp} from '../sx' | ||
import {useFormControlContext} from './_FormControlContext' | ||
import Text from '../Text' | ||
import styled from 'styled-components' | ||
import {get} from '../constants' | ||
import sx from '../sx' | ||
|
||
const StyledCaption = styled(Text)` | ||
color: var(--fgColor-muted); | ||
display: block; | ||
font-size: ${get('fontSizes.0')}; | ||
&:where([data-control-disabled]) { | ||
color: var(--control-fgColor-disabled); | ||
} | ||
${sx} | ||
` | ||
|
||
type FormControlCaptionProps = React.PropsWithChildren< | ||
{ | ||
id?: string | ||
} & SxProp | ||
> | ||
|
||
function FormControlCaption({id, children, sx}: FormControlCaptionProps) { | ||
const {captionId, disabled} = useFormControlContext() | ||
return ( | ||
<StyledCaption id={id ?? captionId} data-control-disabled={disabled ? '' : undefined} sx={sx}> | ||
{children} | ||
</StyledCaption> | ||
) | ||
} | ||
|
||
export {FormControlCaption} |
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
44 changes: 44 additions & 0 deletions
44
packages/react/src/FormControl/FormControlLeadingVisual.tsx
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,44 @@ | ||
import React from 'react' | ||
import {get} from '../constants' | ||
import type {SxProp} from '../sx' | ||
import {useFormControlContext} from './_FormControlContext' | ||
import styled from 'styled-components' | ||
import sx from '../sx' | ||
|
||
const FormControlLeadingVisual: React.FC<React.PropsWithChildren<SxProp>> = ({children, sx}) => { | ||
const {disabled, captionId} = useFormControlContext() | ||
return ( | ||
<StyledLeadingVisual | ||
data-control-disabled={disabled ? '' : undefined} | ||
data-has-caption={captionId ? '' : undefined} | ||
sx={sx} | ||
> | ||
{children} | ||
</StyledLeadingVisual> | ||
) | ||
} | ||
|
||
const StyledLeadingVisual = styled.div` | ||
--leadingVisual-size: ${get('fontSizes.2')}; | ||
color: var(--fgColor-default); | ||
margin-inline-start: ${get('space.2')}; | ||
&:where([data-control-disabled]) { | ||
color: var(--fgColor-muted); | ||
} | ||
& > * { | ||
min-width: var(--leadingVisual-size); | ||
min-height: var(--leadingVisual-size); | ||
fill: currentColor; | ||
} | ||
&:where([data-has-caption]) { | ||
--leadingVisual-size: ${get('fontSizes.4')}; | ||
} | ||
${sx} | ||
` | ||
|
||
export default FormControlLeadingVisual |
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
packages/react/src/FormControl/_FormControlLeadingVisual.tsx
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
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
Oops, something went wrong.