-
Notifications
You must be signed in to change notification settings - Fork 2
[CSL-3157] Sort Component #62
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
Conversation
CSL-3157 [MVP] Create a Sorting Component
A Component that renders out Sort functionalities OOTB Definition of done:
Additional Notes: |
esezen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual implementation looks great. I left some comments around CSS
src/components/Sort/sort.css
Outdated
| @@ -0,0 +1,84 @@ | |||
| .plp-sort { | |||
| background-color: #FFFFFF; | |||
| font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? Can we stick to the default font?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was matching Figma designs and our Button component already uses this font.
Should we update the default font to be
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll defer to @Mudaafi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can default to 'Inter', sans-serif like how we do for the other ui-libraries. I believe I've merged this into main already, so I think we can remove this.
src/components/Sort/sort.css
Outdated
| transition: 0.25s ease; | ||
| } | ||
|
|
||
| .plp-sort label span:before { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind adding some comments here to explain what's happening here?
src/components/Sort/Sort.tsx
Outdated
| changeSelectedSort, | ||
| }) | ||
| ) : ( | ||
| <div className='plp-sort'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we prefix all classes with cio-?
src/components/Sort/Sort.tsx
Outdated
| <div className='plp-sort'> | ||
| <button type='button' className='collapsible' onClick={toggleCollapsible}> | ||
| Sort | ||
| <i className={`arrow ${isOpen ? 'up' : 'down'}`} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about repeating the arrrow part here to make sure we don't treat these as 2 separate classes? So instead of arrow up it would be arrow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better!
| width: 20px; | ||
| height: 20px; | ||
| border-radius: 50%; | ||
| transition: 0.25s ease; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The animation on these are so cool 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Mudaafi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the implementation, had a couple of notes but great work so far
src/utils/transformers.ts
Outdated
| return transformedItem; | ||
| } | ||
|
|
||
| export function transformSortOptions(options?: Partial<SortOption>[]): PlpSortOption[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've renamed this by removing the response but wdyt of transformResponseSortOptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that!
src/utils/transformers.ts
Outdated
| facets: response.facets, | ||
| groups: response.groups, | ||
| sortOptions: response.sort_options, | ||
| sortOptions: transformSortOptions(response.sort_options), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loved that you transformed it here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
| import { Meta, Markdown, ArgTypes } from '@storybook/blocks'; | ||
| import * as SortStories from './Sort.stories'; | ||
|
|
||
| <Meta of={SortStories} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the simplicity of this but I feel like our current props table is a little non-descriptive. Could we add descriptions to the props and what they're used for? i.e. isOpen is the default state and searchAndBrowseResponse is mainly for SSR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
esezen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
LGTM! Thanks Hossam, I'll merge it |
Introducing a Sort Component that takes in a search or a browse response and render sort options dynamically:

[GIF]