generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 205
feat: Arbitrary content for select + multiselect #4075
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
Open
SpyZzey
wants to merge
43
commits into
main
Choose a base branch
from
feat/arbitrary-content-for-select
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
43 commits
Select commit
Hold shift + click to select a range
8b32417
fix: padding on non-interactiveGroup parent
SpyZzey bd8ccd4
fix: remove disableContentStyling=true
SpyZzey 009c20f
test: move disable-content-styling prop to custom permutations page
SpyZzey 5787ba6
fix: rename disable-content-styling.permutations.tsx to include .page
SpyZzey e6a2eed
fix: disabled color set when no-content-styling enabled
SpyZzey 03b7782
feat: add renderOption api to autosuggest
SpyZzey 229b725
feat: add renderOption api to select and multiselect
SpyZzey 23a5add
feat: arbitrary content for select, multiselect
SpyZzey b3998da
Revert "feat: add renderOption api to autosuggest"
SpyZzey c7c1121
chore: remove two examples in pages
SpyZzey 7d87fa4
feat: improve api
SpyZzey 684ae6d
test: update snapshots
SpyZzey b162961
revert: checkbox style class
SpyZzey b94eea9
test: add support for test-utils, add data-test-indices to multiselec…
SpyZzey 17c5a3e
test: add tests for select + multiselect renderOption
SpyZzey bf43628
fix: workaround for documenter bug
SpyZzey 712e632
refactor: move renderOption-content to Option-component
SpyZzey 9d48d6f
chore: update snapshots
SpyZzey 97f806b
refactor: restructure BaseSelectItem and BaseMultiselectItem
SpyZzey 2365b78
fix: update snapshots
SpyZzey 85ad376
fix: add null as return value for findCustomContent
SpyZzey 85a8650
feat: change child/parent to item/group in multiselect/select
SpyZzey 83a5b34
test: option displays custom content
SpyZzey 8c1ad75
test: add findLabel in displays custom content test
SpyZzey c7f456e
test: remove options from multiselect+select custom render option test
SpyZzey 65a7175
chore: remove test-indices
SpyZzey 6d4d323
chore: remove comment only related to core-only feature
SpyZzey c57ce94
feat: add custom trigger option for select, refactor: simplify select…
SpyZzey e90f788
fix: unknown property
SpyZzey 265e49e
chore: update snapshots
SpyZzey ab921af
test: renderOption in trigger
SpyZzey 4d93dfb
fix: make index mandatory
SpyZzey af7a8af
refactor: remove uncessary tags in unit test
SpyZzey 93d529f
refactor: add line breaks
SpyZzey cab5c0f
fix: set disableContentStyling incorrectly
SpyZzey 6435be5
feat: add parent property to select option item
SpyZzey f79ea25
feat: use SimplePage instead of ScreenshotArea
SpyZzey 39a4e91
chore: update snapshots
SpyZzey 84702f9
chore: change width to inlineSize
SpyZzey b23285d
chore: change snapshot deprecated goo.gl to long url
SpyZzey 556f3fd
test: remove the findCustomContent testutil
SpyZzey 9ab75e2
test: Add test for parent attribute in select + multiselect
SpyZzey efa8686
refactor: Rename variables in render-option tests
SpyZzey 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
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,67 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import * as React from 'react'; | ||
|
|
||
| import { Multiselect, MultiselectProps } from '~components'; | ||
| import { SelectProps } from '~components/select'; | ||
|
|
||
| import { SimplePage } from '../app/templates'; | ||
| import { i18nStrings } from './constants'; | ||
| const lotsOfOptions: SelectProps.Options = [...Array(50)].map((_, index) => ({ | ||
| value: `Option ${index}`, | ||
| label: `Option ${index}`, | ||
| })); | ||
| const options: SelectProps.Options = [ | ||
| { value: 'first', label: 'Simple' }, | ||
| { value: 'second', label: 'With small icon', iconName: 'folder' }, | ||
| { | ||
| value: 'third', | ||
| label: 'With big icon icon', | ||
| description: 'Very big option', | ||
| iconName: 'heart', | ||
| disabled: false, | ||
| disabledReason: 'disabled reason', | ||
| tags: ['Cool', 'Intelligent', 'Cat'], | ||
| }, | ||
| { | ||
| label: 'Option group', | ||
| options: [{ value: 'forth', label: 'Nested option' }], | ||
| disabledReason: 'disabled reason', | ||
| }, | ||
| ...lotsOfOptions, | ||
| { label: 'Last option', disabled: false, disabledReason: 'disabled reason' }, | ||
| ]; | ||
|
|
||
| export default function SelectPage() { | ||
| const [selectedOptions, setSelectedOptions] = React.useState<MultiselectProps.Options>([]); | ||
| const renderOptionItem: MultiselectProps.MultiselectOptionItemRenderer = ({ item }) => { | ||
| if (item.type === 'select-all') { | ||
| return <div>Select all? {item.selected ? 'Yes' : 'No'}</div>; | ||
| } else if (item.type === 'group') { | ||
| return <div>Group: {item.option.label}</div>; | ||
| } else if (item.type === 'item') { | ||
| return <div>Item: {item.option.label}</div>; | ||
| } | ||
|
|
||
| return null; | ||
| }; | ||
|
|
||
| return ( | ||
| <SimplePage title="Multiselect with custom item renderer" screenshotArea={{}}> | ||
| <div style={{ inlineSize: '400px' }}> | ||
| <Multiselect | ||
| enableSelectAll={true} | ||
| i18nStrings={{ ...i18nStrings, selectAllText: 'Select all' }} | ||
| filteringType={'auto'} | ||
| renderOption={renderOptionItem} | ||
| placeholder="Choose option" | ||
| selectedOptions={selectedOptions} | ||
| onChange={event => { | ||
| setSelectedOptions(event.detail.selectedOptions); | ||
| }} | ||
| options={options} | ||
| /> | ||
| </div> | ||
| </SimplePage> | ||
| ); | ||
| } |
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,67 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import * as React from 'react'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import Select, { SelectProps } from '~components/select'; | ||
|
|
||
| import { SimplePage } from '../app/templates'; | ||
|
|
||
| const lotsOfOptions = [...Array(50).keys()].map(n => { | ||
| const numberToDisplay = (n + 5).toString(); | ||
| return { | ||
| value: numberToDisplay, | ||
| label: `Option ${n + 5}`, | ||
| }; | ||
| }); | ||
|
|
||
| const options: SelectProps.Options = [ | ||
| { value: 'first', label: 'Simple' }, | ||
| { value: 'second', label: 'With small icon', iconName: 'folder' }, | ||
| { | ||
| value: 'third', | ||
| label: 'With big icon icon', | ||
| description: 'Very big option', | ||
| iconName: 'heart', | ||
| disabled: true, | ||
| disabledReason: 'disabled reason', | ||
| tags: ['Cool', 'Intelligent', 'Cat'], | ||
| }, | ||
| { | ||
| label: 'Option group', | ||
| options: [{ value: 'forth', label: 'Nested option' }], | ||
| disabledReason: 'disabled reason', | ||
| }, | ||
| ...lotsOfOptions, | ||
| { label: 'Last option', disabled: true, disabledReason: 'disabled reason' }, | ||
| ]; | ||
|
|
||
| export default function SelectPage() { | ||
| const [selectedOption, setSelectedOption] = useState<SelectProps.Option | null>(null); | ||
| const renderOption: SelectProps.SelectOptionItemRenderer = ({ item }) => { | ||
| if (item.type === 'trigger') { | ||
| return <div>Trigger: {item.option.label}</div>; | ||
| } else if (item.type === 'group') { | ||
| return <div>Group: {item.option.label}</div>; | ||
| } else if (item.type === 'item') { | ||
| return <div>Item: {item.option.label}</div>; | ||
| } | ||
| return null; | ||
| }; | ||
|
|
||
| return ( | ||
| <SimplePage title="Select with custom item renderer" screenshotArea={{}}> | ||
| <div style={{ inlineSize: '400px' }}> | ||
| <Select | ||
| filteringType="auto" | ||
| renderOption={renderOption} | ||
| placeholder="Choose option" | ||
| selectedOption={selectedOption} | ||
| onChange={({ detail }) => setSelectedOption(detail.selectedOption)} | ||
| options={options} | ||
| triggerVariant="option" | ||
| /> | ||
| </div> | ||
| </SimplePage> | ||
| ); | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,3 +120,7 @@ | |
| .trigger-variant { | ||
| @include styles.text-overflow-ellipsis; | ||
| } | ||
|
|
||
| .custom-content { | ||
| inline-size: 100%; | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| &.highlighted { | ||
| z-index: 3; | ||
| background-color: awsui.$color-background-dropdown-item-hover; | ||
|
|
||
Oops, something went wrong.
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.
No
padding-inline-end?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.
No, setting the padding-inline-end to 0 causes the select chevron to overlap the trigger content, so I'd just leave it as is.