-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix checkbox and radio input validation positioning #728
Open
MelissaPastore
wants to merge
13
commits into
main
Choose a base branch
from
melissapastore/checkbox-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9f23722
fix the validation position for checkbox inputs
MelissaPastore 1730cac
add a story for radio with error validation
MelissaPastore cbe8acb
fix linting issues
MelissaPastore 02394bf
prettier changes
MelissaPastore 1714b72
add a changeset
MelissaPastore 87bee7b
Updates from editor
MelissaPastore 138470e
github-actions[bot] Regenerated snapshots
rezrah 2eed248
update form validation styling to use flex-grid for checkbox and radi…
MelissaPastore f421094
fix linting issues
MelissaPastore 59224b2
more linting
MelissaPastore d9c52e6
Merge branch 'main' into melissapastore/checkbox-validation
MelissaPastore 53c9417
prettier changes
MelissaPastore 6fcda52
update the changeset
MelissaPastore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-brand': patch | ||
--- | ||
|
||
Updates the styling of validation messages for checkbox and radio inputs to use flex-grid to fix a bug and adds storybook examples for each scenario. |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
declare const styles: { | ||
readonly "Checkbox-wrapper": string; | ||
readonly "Checkbox": string; | ||
readonly "Checkbox-input": string; | ||
readonly "Checkbox-checkmark": string; | ||
readonly "Checkbox-checkmark-path": string; | ||
readonly "Checkbox--indeterminate": string; | ||
}; | ||
export = styles; | ||
|
||
readonly 'Checkbox-wrapper': string | ||
readonly Checkbox: string | ||
readonly 'Checkbox-input': string | ||
readonly 'Checkbox-checkmark': string | ||
readonly 'Checkbox-checkmark-path': string | ||
readonly 'Checkbox--indeterminate': string | ||
} | ||
export = styles |
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
42 changes: 21 additions & 21 deletions
42
packages/react/src/forms/FormControl/FormControl.module.css.d.ts
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
declare const styles: { | ||
readonly "FormControl": string; | ||
readonly "FormControl--fullWidth": string; | ||
readonly "FormControl--checkbox": string; | ||
readonly "FormControl--border": string; | ||
readonly "FormControl-label": string; | ||
readonly "FormControl-label--visually-hidden": string; | ||
readonly "FormControl-label--medium": string; | ||
readonly "FormControl-label--large": string; | ||
readonly "FormControl-label--checkbox": string; | ||
readonly "FormControl-control--radio": string; | ||
readonly "FormControl-hint": string; | ||
readonly "FormControl-validation": string; | ||
readonly "FormControl-validation--success": string; | ||
readonly "FormControl-validation--error": string; | ||
readonly "FormControl-validation-success-icon": string; | ||
readonly "FormControl-validation-error-icon": string; | ||
readonly "FormControl-validation--animate-in": string; | ||
readonly "FormControlValidationFadeIn": string; | ||
}; | ||
export = styles; | ||
|
||
readonly FormControl: string | ||
readonly 'FormControl--fullWidth': string | ||
readonly 'FormControl--checkbox': string | ||
readonly 'FormControl--border': string | ||
readonly 'FormControl-label': string | ||
readonly 'FormControl-label--visually-hidden': string | ||
readonly 'FormControl-label--medium': string | ||
readonly 'FormControl-label--large': string | ||
readonly 'FormControl-label--checkbox': string | ||
readonly 'FormControl-control--radio': string | ||
readonly 'FormControl-hint': string | ||
readonly 'FormControl-validation': string | ||
readonly 'FormControl-validation--success': string | ||
readonly 'FormControl-validation--error': string | ||
readonly 'FormControl-validation-success-icon': string | ||
readonly 'FormControl-validation-error-icon': string | ||
readonly 'FormControl-validation--animate-in': string | ||
readonly 'FormControl-validation-checkbox': string | ||
readonly FormControlValidationFadeIn: string | ||
} | ||
export = styles |
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 |
---|---|---|
|
@@ -296,12 +296,24 @@ export const CheckboxPlayground = args => { | |
|
||
CheckboxPlayground.storyName = 'w/ Checkbox - Playground' | ||
|
||
export const RadioPlayground = () => ( | ||
export const RadioPlayground = args => ( | ||
<> | ||
<Stack direction={{narrow: 'vertical', regular: 'horizontal'}} gap="condensed" padding="condensed"> | ||
<FormControl> | ||
<FormControl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pretty much borrowed from the CheckboxPlayground implementation so I could re-use this component for the example with a validation message. |
||
required={args.required} | ||
validationStatus={args.validationStatus} | ||
fullWidth={args.fullWidth} | ||
size={args.size} | ||
> | ||
<FormControl.Label>Radio One</FormControl.Label> | ||
<Radio name="radio-group" value="radio one" /> | ||
{args.validationStatus && args.validationStatus === 'error' && ( | ||
// eslint-disable-next-line i18n-text/no-en | ||
<FormControl.Validation>{args.validationText || 'This is an error message'}</FormControl.Validation> | ||
)} | ||
{args.validationStatus && args.validationStatus === 'success' && ( | ||
<FormControl.Validation>{args.validationText || 'Great! It worked.'}</FormControl.Validation> | ||
)} | ||
</FormControl> | ||
<FormControl> | ||
<FormControl.Label>Radio Two</FormControl.Label> | ||
|
@@ -334,3 +346,17 @@ export const ErrorValidation = () => { | |
) | ||
} | ||
ErrorValidation.storyName = 'w/ Error Validation - Playground' | ||
|
||
export const ErrorValidationWithCheckbox = args => <CheckboxPlayground {...args} /> | ||
ErrorValidationWithCheckbox.storyName = 'w/ Error Validation with Checkbox - Playground' | ||
ErrorValidationWithCheckbox.args = { | ||
validationStatus: 'error', | ||
validationText: 'This is an error message', | ||
} | ||
|
||
export const ErrorValidationWithRadio = args => <RadioPlayground {...args} /> | ||
ErrorValidationWithRadio.storyName = 'w/ Error Validation with Radio - Playground' | ||
ErrorValidationWithRadio.args = { | ||
validationStatus: 'error', | ||
validationText: 'This is an error message', | ||
} |
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
Binary file added
BIN
+9.38 KB
...rmControl-FormControl-w-Error-Validation-with-Checkbox---Playground-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.77 KB
...-FormControl-FormControl-w-Error-Validation-with-Radio---Playground-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
declare const styles: { | ||
readonly "Radio-wrapper": string; | ||
readonly "Radio": string; | ||
readonly "Radio-input": string; | ||
readonly "Radio-dot": string; | ||
}; | ||
export = styles; | ||
|
||
readonly 'Radio-wrapper': string | ||
readonly Radio: string | ||
readonly 'Radio-input': string | ||
readonly 'Radio-dot': string | ||
} | ||
export = styles |
Binary file modified
BIN
-1.73 KB
(98%)
...apshots/Visual-Comparison-RiverStoryScroll-RiverStoryScroll-Default-1-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This might be overkill but I wasn't sure if we wanted to always apply the grid-row to the wrapper for the input or only do this when its parent is a form control element?