Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
refactor(FormControl): update existing code for sub-components to prep for migration#5342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ea1eee1600e34531c069805bca284fe23dc374ea5a552f8a3edbc6a456d9da2dbd9e32File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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.
Uh oh!
There was an error while loading. Please reload this page.
| 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} |
| 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.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.