Skip to content
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

Re-work multiselect component #4376

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions packages/components/src/Input/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import React, { useState } from 'react';
import { Delete, Search } from '@marigold/icons';
import { Button } from '../Button';
import { Input } from './Input';
Expand Down Expand Up @@ -90,21 +90,26 @@ export const WithLeadingIcons: Story = {
};

export const WithAction: Story = {
render: args => (
<Input
placeholder="Placeholder..."
action={
<Button
size="small"
variant="text"
onPress={() => alert('Action executed')}
>
<Delete />
</Button>
}
{...args}
/>
),
render: args => {
const [value, setValue] = useState('value');
return (
<Input
placeholder="Placeholder..."
action={
<Button
size="small"
variant="text"
onPress={() => alert('Action executed')}
>
<Delete />
</Button>
}
{...args}
// value={value}
defaultValue={'Osama'}
/>
);
},
};

export const WithIcons: Story = {
Expand Down
45 changes: 34 additions & 11 deletions packages/components/src/Multiselect/Multiselect.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react-hooks/rules-of-hooks */
import { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
import { Multiselect } from './Multiselect';

const meta = {
Expand All @@ -13,23 +14,45 @@ const meta = {

export default meta;

const fruits = [
{ id: 10, name: 'Lemon' },
{ id: 11, name: 'Mango' },
{ id: 12, name: 'Nectarine' },
{ id: 13, name: 'Orange' },
{ id: 14, name: 'Papaya' },
{ id: 15, name: 'Quince' },
{ id: 16, name: 'Raspberry' },
{ id: 17, name: 'Strawberry' },
{ id: 18, name: 'Tangerine' },
{ id: 19, name: 'Ugli Fruit' },
{ id: 20, name: 'Watermelon' },
];
export const Basic: StoryObj<typeof Multiselect> = {
render: () => {
// Question: Why should we use selectedItems however we can use selectedKeys
const [selectedItems, setSelectedItems] = useState([
{ id: 10, name: 'Lemon' },
{ id: 11, name: 'Mango' },
]);
console.log('currentSelectedITems', selectedItems);
return (
<>
<Multiselect
label="Animals"
// disabledKeys={['snake']}
defaultSelectedKeys={['cat', 'dog']}
className="max-w-xs"
label="Fruits"
tag={item => (
<Multiselect.Tag textValue={item.name}>{item.name}</Multiselect.Tag>
)}
>
<Multiselect.Item id="red-panda">Red Panda</Multiselect.Item>
<Multiselect.Item id="cat">Cat</Multiselect.Item>
<Multiselect.Item id="dog">Dog</Multiselect.Item>
<Multiselect.Item id="aardvark">Aardvark</Multiselect.Item>
<Multiselect.Item id="kangaroo">Kangaroo</Multiselect.Item>
<Multiselect.Item id="snake">Snake</Multiselect.Item>
<Multiselect.Item id="vegan">Vegan</Multiselect.Item>
<Multiselect.Item id="margrita">Margrita</Multiselect.Item>
<Multiselect.Option textValue={'Watermelon'} id={20}>
Watermelon
</Multiselect.Option>
<Multiselect.Option textValue={'Nectarine'} id={12}>
Nectarine
</Multiselect.Option>
<Multiselect.Option textValue={'Strawberry'} id={17}>
Strawberry
</Multiselect.Option>
</Multiselect>
</>
);
Expand Down
Loading
Loading