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

feat(filter): L3-4114 - create dumb filter component #418

Merged
merged 12 commits into from
Nov 22, 2024

Conversation

Zach-OfAllTrades
Copy link
Contributor

@Zach-OfAllTrades Zach-OfAllTrades commented Nov 6, 2024

Jira ticket

L3-4114

Screenshots
image
image

Patterns._.FilterControl.-.Overview.Storybook.-.Google.Chrome.2024-11-06.10-16-29.mp4

Summary

This creates a dumb filter component but also manages the state between child and parent filters (like when clicking view all) along with the transition between the two. These components are meant to be composable. In storybook, I implemented this filter in a Drawer component as it will be on the sale page.

Change List (describe the changes made to the files)

  • Added FilterControl, Filter, FilterHeader, and FilterValue components.

Acceptance Test (how to verify the PR)

Being that this is a dumb component, the actual filtering logic will need to be written when implemented. The main thing to test here is that the component and its children render correctly, view all appears after 10 filters is exceeded, that all filters are listed when view all is click, a back button is present on the view all, and that there is a transition between the two.

Things to look for during review

  • PR title should correctly describe the most significant type of commit. I.e. feat(scope): ... if a minor release should be triggered.
  • All commit messages follow convention and are appropriate for the changes
  • All references to phillips class prefix are using the prefix variable
  • All major areas have a data-testid attribute.
  • Document all props with jsdoc comments
  • All strings should be translatable.
  • Unit tests should be written and should have a coverage of 90% or higher in all areas.

New Components

  • Are there any accessibility considerations that need to be taken into account and tested?
  • Default story called "Playground" should be created for all new components
  • Create a jsdoc comment that has an Overview section and a link to the Figma design for the component
  • Export the component and its typescript type from the index.ts file
  • Import the component scss file into the componentStyles.scss file.

Copy link

netlify bot commented Nov 6, 2024

Deploy Preview for phillips-seldon ready!

Name Link
🔨 Latest commit 611a423
🔍 Latest deploy log https://app.netlify.com/sites/phillips-seldon/deploys/673f8dd68b6ea20008fa9682
😎 Deploy Preview https://deploy-preview-418--phillips-seldon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@davidicus davidicus changed the title feat(filter): create dumb filter component feat(filter): L3-4114 - create dumb filter component Nov 6, 2024
@constantinehuzenko
Copy link
Contributor

when you click on this part it should trigger checkbox
image

@constantinehuzenko
Copy link
Contributor

I think this after click state is kinda weird, maybe we can add some border radius?
image

@constantinehuzenko
Copy link
Contributor

the text's height is 8px which kinda cuts it, I'm afraid we will have incorrect spacing because of that
image

<div
{...commonProps}
className={classnames(baseClassName, className, {
[`${px}-has-separators`]: !isLast,
Copy link
Contributor

Choose a reason for hiding this comment

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

not really clear, why do we need this separator?

Copy link
Contributor

Choose a reason for hiding this comment

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

okay I see now, maybe we should Separator component for that, @scottdickerson wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there are multiple filters, the design shows there is a separator between them. This Filter component, for the majority of cases I would think, would be implemented alongside other Filters. I created the FilterControl component to wrap and manage these.

@constantinehuzenko
Copy link
Contributor

this one is responsible for showing that button, I guess it should be separated component, @scottdickerson please confirm
image

key={value.label}
label={value.label}
onChange={(e) => {
e;
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure why we need this e here

@constantinehuzenko
Copy link
Contributor

I guess only one radio button can be selected

image

@Zach-OfAllTrades
Copy link
Contributor Author

this one is responsible for showing that button, I guess it should be separated component, @scottdickerson please confirm image

I kept this as the same component because the only difference was number of options and button placement. When implemented inside the FilterControl component, the different states of being viewAll or not are managed and is displayed with a slide transition.

@Zach-OfAllTrades
Copy link
Contributor Author

I guess only one radio button can be selected

image

I noticed this too but figured it would be handled when the logic was implemented but now on second thought I will probably need to pass some sort of isActive prop down...

@scottdickerson
Copy link
Contributor

I think this after click state is kinda weird, maybe we can add some border radius? image

I'm not sure we want a "focus" state instead of a "focus-visible" state. I don't think a border should show on an input when it's been clicked.

@scottdickerson
Copy link
Contributor

scottdickerson commented Nov 13, 2024

small alignment issue when I'm viewing All, where the checkboxes don't directly align with the labels

image

import Input from '../Input/Input';

// You'll need to change the ComponentProps<"htmlelementname"> to match the top-level element of your component
export interface FilterValueProps extends Omit<ComponentProps<'div'>, 'onChange'> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an FYI this would be a good use of a Type Generic where the ValueType is passed and used in a value prop. So consumers would say <FilterValue<boolean>> for instance and our prop model would say value: ValueType. We're not doing it in the <Input components either so this is kinda tech debt across seldon


return (
<div {...commonProps} className={classnames(baseClassName, className)} {...props} ref={ref}>
<form action={action}>{parsedChildren}</form>
Copy link
Contributor

Choose a reason for hiding this comment

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

I need to be able to pass in the <form element from outside this component so I can pass the Remix <Form component. Perhaps following the element pattern we use in other places?

{...props}
ref={ref}
>
<Text
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use the normal <Input label prop rather than construct your own here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried that originally but couldn't see where I had control over the placement, it was always right of the input. Could be missing something, though.

@constantinehuzenko
Copy link
Contributor

still can't click at some points
image

@constantinehuzenko
Copy link
Contributor

constantinehuzenko commented Nov 20, 2024

can we add padding bottom? so scroll will go little further

image

// label,
inputType = 'checkbox',
isHidden = false,
// onChange,
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove unnecessary props

/>
<Input
{...inputProps}
// checked={isActive}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should remove this as well

Copy link
Contributor

@scottdickerson scottdickerson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@constantinehuzenko constantinehuzenko left a comment

Choose a reason for hiding this comment

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

LGTM

@scottdickerson scottdickerson merged commit 0014771 into main Nov 22, 2024
12 checks passed
@scottdickerson scottdickerson deleted the L3-4114-create-dumb-filter-control branch November 22, 2024 18:56
davidicus pushed a commit that referenced this pull request Nov 22, 2024
# [1.97.0](v1.96.1...v1.97.0) (2024-11-22)

### Features

* **filter:** L3-4114 - create dumb filter component ([#418](#418)) ([0014771](0014771))
@davidicus
Copy link
Collaborator

🎉 This issue has been resolved in version 1.97.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants