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

Refactor: move <Filter /> component #2823

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Refactor: move <Filter /> component #2823

wants to merge 3 commits into from

Conversation

balanza
Copy link
Member

@balanza balanza commented Jul 25, 2024

Description

The <Filter /> component has been moved out from the <Table /> component so that it can be used separately.
This is a preparatory work in order to enhance the usage of tables in more diversified scenarios.

No changes in the behavior of the component have been introduced (except for the default value).

All references to the component has been updated.

Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!
I shared a suggestion we might want to consider, although not blocking.


import Filter from '.';

export default {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we might want to follow storybook's guidelines about writing stories.
I think it maximizes expressiveness and minimizes repetition.

export default {
  title: 'Components/Filter',
  component: Filter,
  argTypes: {
    options: {/** type, description, control... */},
    title: {/** type, description, control... */},
    value: {/** type, description, control... */},
    onChange: {/** type, description, control... */}
  },
  render: (args) => {
    const [value, setValue] = useState(args.value);

    return (
      <Filter
        title={args.title}
        options={args.options}
        value={value}
        onChange={(newValue) => {
          setValue(newValue);
          action('onChange')(newValue);
        }}
      />
    );
  }
};

export const Default = {
  args: {
    title: 'Title',
    options: [
      'Tony Kekw',
      'Chad Carbonara',
      'Chuck Amatriciana',
      'K.C.O. Pepe',
      'Virgin Gricia',
    ],
    value: [],
  },
};

export const WithValue = {
  args: {
    ...Default.args,
    value: ['Tony Kekw'],
  },
};

export const WithMultipleValues = {
  args: {
    ...Default.args,
    value: ['Tony Kekw', 'Chad Carbonara'],
  },
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it's indeed better to stick with guidelines. Done in c37218f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants