generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 204
feat: Add horizontal direction to radio group #3906
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
6 commits
Select commit
Hold shift + click to select a range
6998082
chore: Refactor radio button into internal component
jperals 572b570
feat: Horizontal radio group
jperals 3e45c44
Add dividers
jperals 988a995
Add maximum width
jperals f589b3b
Revert "Add dividers"
jperals 8d7a83b
fix duplicated prop
jperals 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,108 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Link from '~components/link'; | ||
| import { RadioGroupProps } from '~components/radio-group'; | ||
|
|
||
| import createPermutations from '../utils/permutations'; | ||
|
|
||
| const permutations = createPermutations<RadioGroupProps>([ | ||
| { | ||
| value: ['first'], | ||
| items: [ | ||
| [ | ||
| { value: 'first', label: 'First Button' }, | ||
| { value: 'second', label: 'Second Button' }, | ||
| { value: 'third', label: 'Third Button', disabled: true }, | ||
| ], | ||
| [ | ||
| { | ||
| value: 'first', | ||
| label: | ||
| 'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.', | ||
| }, | ||
| { | ||
| value: 'second', | ||
| label: | ||
| 'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.', | ||
| description: | ||
| 'Long text, long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Whatever.', | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| { | ||
| value: ['second'], | ||
| items: [ | ||
| [ | ||
| { value: 'first', label: 'First Button', description: 'Short description' }, | ||
| { value: 'second', label: 'Second Button', description: 'Short description' }, | ||
| { value: 'third', label: 'Third Button', description: 'Short description' }, | ||
| ], | ||
| [ | ||
| { value: 'first', label: 'First Button', description: 'Short description', disabled: true }, | ||
| { value: 'second', label: 'Second Button', description: 'Short description' }, | ||
| { | ||
| value: 'third', | ||
| label: 'Description with link', | ||
| description: ( | ||
| <> | ||
| Long text,{' '} | ||
| <Link variant="primary" fontSize="body-s" href="https://www.google.com"> | ||
| </Link>{' '} | ||
| long enough to wrap. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
| incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco | ||
| laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit | ||
| esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa | ||
| qui officia deserunt mollit anim id est laborum. Whatever. | ||
| </> | ||
| ), | ||
| }, | ||
| { | ||
| value: 'forth', | ||
| label: 'Description with icon', | ||
| description: ( | ||
| <> | ||
| Link at end of description{' '} | ||
| <Link fontSize="body-s" variant="primary" external={true} externalIconAriaLabel="(External)"> | ||
| learn more | ||
| </Link> | ||
| </> | ||
| ), | ||
| }, | ||
| { | ||
| value: 'fifth', | ||
| label: 'Long description with icon', | ||
| description: ( | ||
| <> | ||
| Icon in the middle of long description. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do | ||
| eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud | ||
| exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.{' '} | ||
| <Link fontSize="body-s" variant="primary" external={true} externalIconAriaLabel="(External)"> | ||
| learn more | ||
| </Link>{' '} | ||
| Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
| Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est | ||
| laborum. | ||
| </> | ||
| ), | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| { | ||
| readOnly: [true], | ||
| value: ['first'], | ||
| items: [ | ||
| [ | ||
| { value: 'first', label: 'First Button' }, | ||
| { value: 'second', label: 'Second Button' }, | ||
| { value: 'third', label: 'Third Button', disabled: true }, | ||
| ], | ||
| ], | ||
| }, | ||
| ]); | ||
|
|
||
| export default permutations; | ||
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,57 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Box from '~components/box'; | ||
| import RadioGroup, { RadioGroupProps } from '~components/radio-group'; | ||
|
|
||
| import createPermutations from '../utils/permutations'; | ||
| import PermutationsView from '../utils/permutations-view'; | ||
| import ScreenshotArea from '../utils/screenshot-area'; | ||
| import permutations from './common-permutations'; | ||
|
|
||
| const extraPermutations = createPermutations<RadioGroupProps>([ | ||
| { | ||
| value: ['first'], | ||
| items: [ | ||
| [ | ||
| { value: 'first', label: 'First Button' }, | ||
| { value: 'second', label: 'Second Button' }, | ||
| { value: 'third', label: 'Third Button' }, | ||
| { value: 'fourth', label: 'Fourth Button' }, | ||
| { value: 'fifth', label: 'Fifth Button' }, | ||
| { value: 'sixth', label: 'Sixth Button' }, | ||
| { value: 'seventh', label: 'Seventh Button' }, | ||
| { value: 'eighth', label: 'Eighth Button' }, | ||
| { value: 'ninth', label: 'Ninth Button' }, | ||
| { value: 'tenth', label: 'Tenth Button' }, | ||
| { value: 'eleventh', label: 'Eleventh Button' }, | ||
| { value: 'twelfth', label: 'Twelfth Button' }, | ||
| ], | ||
| ], | ||
| }, | ||
| ]); | ||
|
|
||
| export default function HorizontalRadioGroupPermutations() { | ||
| return ( | ||
| <> | ||
| <h1>RadioGroup horizontal permutations</h1> | ||
| <ScreenshotArea> | ||
| <PermutationsView | ||
| permutations={[...permutations, ...extraPermutations]} | ||
| render={permutation => ( | ||
| <Box margin={{ vertical: 'xl' }}> | ||
| <RadioGroup | ||
| direction="horizontal" | ||
| onChange={() => { | ||
| /*empty handler to suppress react controlled property warning*/ | ||
| }} | ||
| {...permutation} | ||
| /> | ||
| </Box> | ||
| )} | ||
| /> | ||
| </ScreenshotArea> | ||
| </> | ||
| ); | ||
| } |
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
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
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
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.
suggested by AI to be
fourthwhich is correct but this is not blocking at all :D, approving since no other issues found