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 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dde651c
Create multiselect component
OsamaAbdellateef Jan 9, 2025
2e797b2
Adding on remove function and filter
OsamaAbdellateef Jan 9, 2025
80ca4e8
Adding onInputChange
OsamaAbdellateef Jan 9, 2025
ccdc508
Adding popLast
OsamaAbdellateef Jan 9, 2025
d2364d0
adding onKeyCapture
OsamaAbdellateef Jan 9, 2025
0403734
Adding observer for the width
OsamaAbdellateef Jan 9, 2025
a40214e
Adding styles
OsamaAbdellateef Jan 13, 2025
c0340f8
remove unwanted imports
OsamaAbdellateef Jan 13, 2025
bad3078
Dont' rely on items
OsamaAbdellateef Jan 13, 2025
d698315
edit items value
OsamaAbdellateef Jan 13, 2025
dd56025
Adding more styles
OsamaAbdellateef Jan 14, 2025
16bc87a
Adjust styles
OsamaAbdellateef Jan 14, 2025
51a55ed
fix disabled status
OsamaAbdellateef Jan 14, 2025
1224a2f
Adding readOnly status styles
OsamaAbdellateef Jan 14, 2025
a40c477
clean up the code
OsamaAbdellateef Jan 14, 2025
503c14f
Adding react-select stuff 😎
OsamaAbdellateef Jan 19, 2025
367ec26
fixing lints
OsamaAbdellateef Jan 20, 2025
2c43621
fix lint
OsamaAbdellateef Jan 20, 2025
50e044b
remove isOpenMenu
OsamaAbdellateef Jan 20, 2025
314e084
Adding styles for on focus
OsamaAbdellateef Jan 20, 2025
8a28027
Move component to storybook
OsamaAbdellateef Jan 21, 2025
a7c4bdb
Adding read-only styles
OsamaAbdellateef Jan 21, 2025
d6ef3f7
Adding label element
OsamaAbdellateef Jan 22, 2025
07ac70c
Adding helptext
OsamaAbdellateef Jan 27, 2025
de6dbfa
Adjusting the component
OsamaAbdellateef Jan 28, 2025
8aff500
Fix label
OsamaAbdellateef Jan 28, 2025
4bcf0ca
Adding missing styles & storybook
OsamaAbdellateef Jan 30, 2025
d26b2c4
Cleaning the code up and add more of storybook
OsamaAbdellateef Jan 30, 2025
b7d444e
Adding tests
OsamaAbdellateef Jan 30, 2025
75d3a87
Adding tests
OsamaAbdellateef Jan 31, 2025
0144f1e
Merge branch 'main' into multiselect-rework
OsamaAbdellateef Jan 31, 2025
a1bd45f
test
OsamaAbdellateef Jan 31, 2025
fb55308
Fixing lock file
OsamaAbdellateef Jan 31, 2025
fd68f17
Fixing typecheck
OsamaAbdellateef Jan 31, 2025
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@marigold/prettier-config": "workspace:*",
"@marigold/tsconfig": "workspace:*",
"@parcel/watcher": "2.5.0",
"@react-aria/label": "3.7.14",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.2.0",
Expand All @@ -34,6 +35,7 @@
"postcss-import": "16.1.0",
"postcss-loader": "8.1.1",
"prettier": "3.4.2",
"react-select": "5.9.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"tailwindcss": "3.4.17",
Expand Down
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
141 changes: 121 additions & 20 deletions packages/components/src/Multiselect/Multiselect.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,138 @@
/* eslint-disable react-hooks/rules-of-hooks */
import { useState } from '@storybook/preview-api';
import { Meta, StoryObj } from '@storybook/react';
import { Multiselect } from './Multiselect';
import { Stack } from '../Stack';
import { Multiselect2 } from './Multiselect2';

const meta = {
title: 'Components/Multiselect',
argTypes: {},
argTypes: {
label: {
control: {
type: 'text',
},
description: 'Set the label of the Multiselect',
table: {
type: { summary: 'text' },
defaultValue: { summary: '' },
},
},
description: {
control: {
type: 'text',
},
description: 'Set the help text description.',
table: {
type: { summary: 'text' },
defaultValue: { summary: 'This is a help text description' },
},
},
disabled: {
control: {
type: 'boolean',
},
description: 'Disable Multiselect',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
},
error: {
control: {
type: 'boolean',
},
description: 'Is the input invalid?',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
},
errorMessage: {
control: {
type: 'text',
},
description: 'Set the Error Message',
table: {
type: { summary: 'text' },
defaultValue: { summary: 'Something went wrong' },
},
},
placeholder: {
control: {
type: 'text',
},
description: 'Set the placeholder text',
table: {
type: { summary: 'text' },
defaultValue: { summary: 'undefined' },
},
},
width: {
control: {
type: 'text',
},
description:
'The width of the field. For that we use the Tailwind tokens.',
table: {
type: { summary: 'text' },
defaultValue: { summary: 'full' },
},
},
},
args: {
description: 'This is a help text description',
errorMessage: 'Something went wrong',
error: false,
disabled: false,
width: 'full',
placeholder: undefined,
label: 'Label',
},
} satisfies Meta;

export default meta;

export const Basic: StoryObj<typeof Multiselect> = {
render: () => {
const drinks = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];

export const Basic: StoryObj<any> = {
render: args => (
<Multiselect2
label="Label"
placeholder="Enter value"
items={drinks}
{...args}
/>
),
};

export const Controlled: StoryObj<any> = {
render: args => {
const [current, setCurrent] = useState<string>('');
const [selectedValues, setSelectedValues] = useState<Array<object>>([]);

return (
<>
<Multiselect
label="Animals"
// disabledKeys={['snake']}
defaultSelectedKeys={['cat', 'dog']}
>
<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>
</>
<Stack space={3}>
<Multiselect2
label="Label"
items={drinks}
onChange={value => setCurrent(value)}
onSelectionChange={(selectedValues: object[]) =>
setSelectedValues(selectedValues)
}
{...args}
/>
<hr />
<pre>
current: {current}, selected:{' '}
{selectedValues
.map(({ value }: { value: string }) => value)
.join(', ')}
</pre>
</Stack>
);
},
};
Loading
Loading