Skip to content

Conversation

@HHHindawy
Copy link
Contributor

Introducing a Sort Component that takes in a search or a browse response and render sort options dynamically:
[GIF]
Sort

@HHHindawy HHHindawy requested a review from a team March 20, 2024 20:51
@linear
Copy link

linear bot commented Mar 20, 2024

CSL-3157 [MVP] Create a Sorting Component

A Component that renders out Sort functionalities OOTB

Definition of done:

  • Utilize the useSortOrders Hook
  • Surface the relevant parameters from the context if the user wants to use them as RenderProps params
  • Tests
  • Documentation

Additional Notes:

image.png

https://www.figma.com/file/bWsxaLJGgHTX9ystM0Ko5Z/Open-Source-Demo?type=design&node-id=352-2174&mode=design&t=aDRZGD2jDWPrSIau-0

@Mudaafi Mudaafi self-assigned this Mar 29, 2024
Copy link
Contributor

@esezen esezen left a 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

@@ -0,0 +1,84 @@
.plp-sort {
background-color: #FFFFFF;
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

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.

transition: 0.25s ease;
}

.plp-sort label span:before {
Copy link
Contributor

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?

changeSelectedSort,
})
) : (
<div className='plp-sort'>
Copy link
Contributor

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-?

<div className='plp-sort'>
<button type='button' className='collapsible' onClick={toggleCollapsible}>
Sort
<i className={`arrow ${isOpen ? 'up' : 'down'}`} />
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

@Mudaafi Mudaafi left a 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

return transformedItem;
}

export function transformSortOptions(options?: Partial<SortOption>[]): PlpSortOption[] {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that!

facets: response.facets,
groups: response.groups,
sortOptions: response.sort_options,
sortOptions: transformSortOptions(response.sort_options),
Copy link
Contributor

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!

Copy link
Contributor Author

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} />
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

@esezen esezen self-requested a review April 24, 2024 19:23
Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

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

LGTM!

@HHHindawy HHHindawy requested a review from Mudaafi April 24, 2024 20:41
@Mudaafi
Copy link
Contributor

Mudaafi commented Apr 26, 2024

LGTM! Thanks Hossam, I'll merge it

@Mudaafi Mudaafi merged commit 1d6ad47 into main Apr 26, 2024
@Mudaafi Mudaafi deleted the csl-3157-mvp-create-a-sorting-component branch April 26, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants