-
Notifications
You must be signed in to change notification settings - Fork 1.3k
FormControl refactor/cleanup #2114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
92c4b3f
checkbox animation adjustment
0cfcc31
radio styles
9518046
disabled state
c7135a1
Merge branch 'main' of https://github.com/primer/css into checkbox-radio
8359f2e
pull styles from app header
bfb107f
cleanup spacing/alignment
d269f1c
add checkbox focus styles
343c347
stories + radio focus styles
31b8d0d
convert to css check
8e1c6bb
refactor to pure *CSS* :)
fee87e0
configure multi radio story
9a356db
lint
0be7266
Create neat-sloths-march.md
876fa28
snappier animations
5bb40a3
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
538d49a
Merge branch 'main' of https://github.com/primer/css into checkbox-radio
141f4b0
adjust mask size for better scailing
523ab15
checkbox mask size
3eb2ffd
lint
2af4c0c
Stylelint auto-fixes
actions-user 9b177f6
rename classes
e838d2b
how many times will she refactor?
c6f81be
slight refactor based on original api
0edb6ad
delete component file test
18dc488
Stylelint auto-fixes
actions-user ad4c7da
Merge branch 'main' into checkbox-radio
1342114
add comments around padding
cc57d9a
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
64afdff
Stylelint auto-fixes
actions-user c3b3ba2
undo changes to old forms
1d4b985
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
ec2b681
Merge branch 'main' into checkbox-radio
ba4ce71
increase touch target :)
5343491
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
6364104
remove unused grid + cursor pointer
d7d605b
Stylelint auto-fixes
actions-user c39c876
adjust disabled checked styles
ff5a45c
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
a149ad6
bump primitives
0b3e692
Stylelint auto-fixes
actions-user c63fdbd
Update neat-sloths-march.md
cbf6b34
temp add prefix for testing
74d89a7
Merge branch 'checkbox-radio' of https://github.com/primer/css into c…
02ae03d
test windows high contrast
5067381
cleanup prefix for final build
d3c516c
Merge branch 'main' into checkbox-radio
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 hidden or 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,7 @@ | ||
| --- | ||
| "@primer/css": patch | ||
| --- | ||
|
|
||
| - Updates stories to reflect markup for Rails | ||
| - Clean up FormControl classes | ||
| - Add Radio and Checkbox custom styles |
This file contains hidden or 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 hidden or 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
117 changes: 117 additions & 0 deletions
117
docs/src/stories/rails-form-framework/Checkbox.stories.jsx
This file contains hidden or 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,117 @@ | ||
| import React from 'react' | ||
| import clsx from 'clsx' | ||
|
|
||
| export default { | ||
| title: 'Rails Forms/Checkbox', | ||
| parameters: { | ||
| layout: 'padded' | ||
| }, | ||
| decorators: [ | ||
| Story => ( | ||
| <form> | ||
| <Story /> | ||
| </form> | ||
| ) | ||
| ], | ||
| excludeStories: ['InputTemplate'], | ||
| argTypes: { | ||
| disabled: { | ||
| description: 'disabled field', | ||
| control: {type: 'boolean'}, | ||
| table: { | ||
| category: 'CSS' | ||
| } | ||
| }, | ||
| visuallyHidden: { | ||
| description: 'visually hide label', | ||
| control: {type: 'boolean'}, | ||
| table: { | ||
| category: 'CSS' | ||
| } | ||
| }, | ||
| label: { | ||
| type: 'string', | ||
| name: 'label', | ||
| description: 'string', | ||
| table: { | ||
| category: 'HTML' | ||
| } | ||
| }, | ||
| caption: { | ||
| name: 'caption', | ||
| type: 'string', | ||
| description: 'caption', | ||
| table: { | ||
| category: 'HTML' | ||
| } | ||
| }, | ||
| focusElement: { | ||
| control: {type: 'boolean'}, | ||
| description: 'set focus on element', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| }, | ||
| checked: { | ||
| control: {type: 'boolean'}, | ||
| description: 'checked', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| }, | ||
| indeterminate: { | ||
| control: {type: 'boolean'}, | ||
| description: 'indeterminate', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const focusMethod = function getFocus() { | ||
| // find the focusable element | ||
| var input = document.getElementsByTagName('input')[0] | ||
| // set focus on element | ||
| input.focus() | ||
| } | ||
|
|
||
| export const InputTemplate = ({label, disabled, visuallyHidden, focusElement, caption, checked, indeterminate}) => ( | ||
| <> | ||
| <div data-view-component="true" class="FormControl-checkbox-wrap"> | ||
| <input | ||
| id="input-id" | ||
| type="checkbox" | ||
| disabled={disabled} | ||
| class="FormControl-checkbox" | ||
| checked={checked ? 'true' : undefined} | ||
| indeterminate={indeterminate ? 'true' : undefined} | ||
| ariaDescribedBy={caption ? 'caption-ebb67985' : undefined} | ||
| /> | ||
| <span class="FormControl-checkbox-labelWrap"> | ||
| <label htmlFor="input-id" className={clsx('FormControl-label', visuallyHidden && 'sr-only')}> | ||
| {label} | ||
| </label> | ||
| {caption && ( | ||
| <p className="FormControl-caption" id="caption-ebb67985"> | ||
| {caption} | ||
| </p> | ||
| )} | ||
| </span> | ||
| </div> | ||
|
|
||
| {focusElement && focusMethod()} | ||
| </> | ||
| ) | ||
|
|
||
| export const Playground = InputTemplate.bind({}) | ||
| Playground.args = { | ||
| label: 'Select an option', | ||
| disabled: false, | ||
| focusElement: false, | ||
| caption: 'Caption', | ||
| invalid: false, | ||
| visuallyHidden: false, | ||
| checked: false, | ||
| indeterminate: false | ||
| } | ||
127 changes: 127 additions & 0 deletions
127
docs/src/stories/rails-form-framework/Radio.stories.jsx
This file contains hidden or 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,127 @@ | ||
| import React from 'react' | ||
| import clsx from 'clsx' | ||
|
|
||
| export default { | ||
| title: 'Rails Forms/Radio', | ||
| parameters: { | ||
| layout: 'padded' | ||
| }, | ||
| decorators: [ | ||
| Story => ( | ||
| <form> | ||
| <Story /> | ||
| </form> | ||
| ) | ||
| ], | ||
| excludeStories: ['RadioTemplate'], | ||
| argTypes: { | ||
| disabled: { | ||
| description: 'disabled field', | ||
| control: {type: 'boolean'}, | ||
| table: { | ||
| category: 'CSS' | ||
| } | ||
| }, | ||
| visuallyHidden: { | ||
| description: 'visually hide label', | ||
| control: {type: 'boolean'}, | ||
| table: { | ||
| category: 'CSS' | ||
| } | ||
| }, | ||
| label: { | ||
| type: 'string', | ||
| name: 'label', | ||
| description: 'string', | ||
| table: { | ||
| category: 'HTML' | ||
| } | ||
| }, | ||
| caption: { | ||
| name: 'caption', | ||
| type: 'string', | ||
| description: 'caption', | ||
| table: { | ||
| category: 'HTML' | ||
| } | ||
| }, | ||
| id: { | ||
|
langermank marked this conversation as resolved.
|
||
| name: 'id', | ||
| type: 'string', | ||
| description: 'id', | ||
| table: { | ||
| category: 'Radio' | ||
| } | ||
| }, | ||
| focusElement: { | ||
| control: {type: 'boolean'}, | ||
| description: 'set focus on element', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| }, | ||
| checked: { | ||
| control: {type: 'boolean'}, | ||
| description: 'checked', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| }, | ||
| indeterminate: { | ||
| control: {type: 'boolean'}, | ||
| description: 'indeterminate', | ||
| table: { | ||
| category: 'Interactive' | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const focusMethod = function getFocus() { | ||
| // find the focusable element | ||
| var input = document.getElementsByTagName('input')[0] | ||
| // set focus on element | ||
| input.focus() | ||
| } | ||
|
|
||
| export const RadioTemplate = ({label, disabled, visuallyHidden, focusElement, caption, checked, indeterminate, id}) => ( | ||
| <> | ||
| <div class="FormControl-radio-wrap"> | ||
| <input | ||
| id={id} | ||
| name="radio" | ||
| type="radio" | ||
| disabled={disabled} | ||
| class="FormControl-radio" | ||
| checked={checked ? 'true' : undefined} | ||
| indeterminate={indeterminate ? 'true' : undefined} | ||
| ariaDescribedBy={caption ? 'caption-ebb67985' : undefined} | ||
| /> | ||
| <span class="FormControl-radio-labelWrap"> | ||
| <label htmlFor={id} className={clsx('FormControl-label', visuallyHidden && 'sr-only')}> | ||
| {label} | ||
| </label> | ||
| {caption && ( | ||
| <p className="FormControl-caption" id="caption-ebb67985"> | ||
| {caption} | ||
| </p> | ||
| )} | ||
| </span> | ||
| </div> | ||
|
|
||
| {focusElement && focusMethod()} | ||
| </> | ||
| ) | ||
|
|
||
| export const Playground = RadioTemplate.bind({}) | ||
| Playground.args = { | ||
| id: 'some-id', | ||
| label: 'Select an option', | ||
| disabled: false, | ||
| focusElement: false, | ||
| caption: 'Caption', | ||
| invalid: false, | ||
|
langermank marked this conversation as resolved.
|
||
| visuallyHidden: false, | ||
| checked: false, | ||
| indeterminate: false | ||
| } | ||
14 changes: 14 additions & 0 deletions
14
docs/src/stories/rails-form-framework/RadioFeatures.stories.jsx
This file contains hidden or 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,14 @@ | ||
| import React from 'react' | ||
| import {RadioTemplate} from './Radio.stories.jsx' | ||
|
|
||
| export default { | ||
| title: 'Rails Forms/Radio/Features' | ||
| } | ||
|
|
||
| export const MultiRadios = ({}) => ( | ||
| <form style={{display: 'grid', gap: '.5rem'}}> | ||
| <RadioTemplate label="First radio item" caption="This one has a caption!" id="first" /> | ||
| <RadioTemplate label="Second radio item" id="second" /> | ||
| <RadioTemplate label="Third radio item" id="third" /> | ||
| </form> | ||
| ) |
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.
Uh oh!
There was an error while loading. Please reload this page.