-
Notifications
You must be signed in to change notification settings - Fork 17
[major] Reimplement Chip component #2431
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
15 commits
Select commit
Hold shift + click to select a range
5ae8ad9
Implement Chip component
PelayoFelgueroso a9d4641
Merge branch 'master' into PelayoFelgueroso/chip-redesign
PelayoFelgueroso 075c3d6
Change `mode` prop definition on types.ts and CodePage
PelayoFelgueroso ee321ff
Add types condition
PelayoFelgueroso eb75c48
Add accesibility props and conditionate the props and the available v…
PelayoFelgueroso c124264
Add last tests
PelayoFelgueroso 3b112ed
Change example content
PelayoFelgueroso 637f612
Add type to Chip styled props
PelayoFelgueroso 36f2b50
Add images to Overview Page and fix based on comments
PelayoFelgueroso add70c5
Fix max-width, tabIndex on dismissible mode
PelayoFelgueroso 73fd8c7
Remove test with ts error, change getByText for getByRole and add exp…
PelayoFelgueroso 68dac19
Fix codePage examples
PelayoFelgueroso 0f679b7
Merge branch 'master' into PelayoFelgueroso/chip-redesign
PelayoFelgueroso 801b8ee
Merge branch 'master' into PelayoFelgueroso/chip-redesign
PelayoFelgueroso a2280a8
Merge branch 'master' into PelayoFelgueroso/chip-redesign
Jialecl 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
34 changes: 0 additions & 34 deletions
34
apps/website/screens/components/chip/code/examples/avatar.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
apps/website/screens/components/chip/code/examples/basicUsage.tsx
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
apps/website/screens/components/chip/code/examples/dismissible.tsx
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,79 @@ | ||
| import { DxcChip, DxcFlex, DxcInset, DxcSelect } from "@dxc-technology/halstack-react"; | ||
| import { useState } from "react"; | ||
|
|
||
| type Option = { label: string; value: string; icon: string }; | ||
|
|
||
| const options: Option[] = [ | ||
| { label: "Electric Car", value: "car", icon: "electric_car" }, | ||
| { label: "Motorcycle", value: "motorcycle", icon: "Motorcycle" }, | ||
| { label: "Train", value: "train", icon: "train" }, | ||
| { label: "Bike", value: "bike", icon: "pedal_bike" }, | ||
| ]; | ||
|
|
||
| const findOptionByValue = (value: string): Option | null => options.find((opt) => opt.value === value) ?? null; | ||
|
|
||
| type TransportSelectProps = { | ||
| selectedOptions: Option[]; | ||
| onChange: (selected: Option[]) => void; | ||
| }; | ||
|
|
||
| const TransportSelect = ({ selectedOptions, onChange }: TransportSelectProps) => { | ||
| const handleSelectChange = ({ value }: { value: string | string[] }) => { | ||
| if (Array.isArray(value)) { | ||
| onChange(value.map((val) => findOptionByValue(val)).filter(Boolean) as Option[]); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <DxcSelect | ||
| label="Select your favourite hobbies" | ||
| placeholder="Choose your hobbies" | ||
| options={options} | ||
| onChange={handleSelectChange} | ||
| value={selectedOptions.map((opt) => opt.value)} | ||
| multiple | ||
| enableSelectAll | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| const code = `() => { | ||
| const [selectedOptions, setSelectedOptions] = useState([options[0], options[2]]); | ||
|
|
||
| const handleDismiss = (valueToRemove) => { | ||
| setSelectedOptions(selectedOptions.filter(opt => opt.value !== valueToRemove)); | ||
| }; | ||
|
|
||
| return ( | ||
| <DxcInset space="var(--spacing-padding-xl)"> | ||
| <DxcFlex direction="column" gap="var(--spacing-gap-m)"> | ||
| <TransportSelect selectedOptions={selectedOptions} onChange={setSelectedOptions} /> | ||
|
|
||
| {selectedOptions.length > 0 && ( | ||
| <DxcFlex gap="var(--spacing-gap-s)" wrap="wrap"> | ||
| {selectedOptions.map((option) => ( | ||
| <DxcChip | ||
| key={option.value} | ||
| mode="dismissible" | ||
| label={option.label} | ||
| prefix={option.icon} | ||
| onClick={() => handleDismiss(option.value)} | ||
| /> | ||
| ))} | ||
| </DxcFlex> | ||
| )} | ||
| </DxcFlex> | ||
| </DxcInset> | ||
| ); | ||
| }`; | ||
|
|
||
| const scope = { | ||
| DxcChip, | ||
| DxcInset, | ||
| DxcFlex, | ||
| useState, | ||
| options, | ||
| TransportSelect, | ||
| }; | ||
|
|
||
| export default { code, scope }; |
34 changes: 0 additions & 34 deletions
34
apps/website/screens/components/chip/code/examples/icons.tsx
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.