Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

[FSSS-164] Extract UISelect from Sort to its own component #299

Merged
merged 8 commits into from
Feb 4, 2022

Conversation

heitorado
Copy link
Contributor

@heitorado heitorado commented Feb 2, 2022

What's the purpose of this pull request?

This PR extracts the UISelect component that was being used by the Sort component internally to its own component.

How it works?

This essentially:

  • Removes the sort.scss stylesheet completely
  • Move all styles to the select.scss stylesheet
  • Adds a new Select component that wraps the UISelect from faststore
    • It uses the id attribute to link the label component with the UISelect
    • If it receives a className attribute, it will forward that attribute to the className prop in the outer div. Optional.
    • If it receives a labelText attribute, it will render a label together with the select. Optional.
    • It forwards the aria-label attribute to the UISelect aria-label. This attribute is required.
    • It receives an options attribute which is a Record<string, string> so it can build the available options that will be displayed when the user clicks the Select component. This attribute is required.

How to test it?

yarn test
Verify that all the tests still pass, so the original behaviour is kept.

Also open the local instance and verify that no styles are broken, meaning the change did not affect the styles as well.

References

Thanks to @renatamottam

@heitorado heitorado self-assigned this Feb 2, 2022
@netlify
Copy link

netlify bot commented Feb 2, 2022

✔️ Deploy Preview for basestore ready!

🔨 Explore the source changes: 7805b39

🔍 Inspect the deploy log: https://app.netlify.com/sites/basestore/deploys/61f9f3ca44d9cc00082c7abf

😎 Browse the preview: https://deploy-preview-299--basestore.netlify.app

@vtex-sites
Copy link

vtex-sites bot commented Feb 2, 2022

Preview is ready

This pull request generated a Preview

👀   Preview: https://preview-299--base.preview.vtex.app
🔬   Go deeper by inspecting the Build Logs
📝   based on commit b4e30c5

@gatsby-cloud
Copy link

gatsby-cloud bot commented Feb 2, 2022

Gatsby Cloud Build Report

basestore

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 4m

Performance

Lighthouse report

Metric Score
Performance 🔶 64
Accessibility 💚 100
Best Practices 💚 100
SEO 💚 93

🔗 View full report

@gatsby-cloud
Copy link

gatsby-cloud bot commented Feb 2, 2022

Gatsby Cloud Build Report

basestore

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 5m

Performance

Lighthouse report

Metric Score
Performance 🔶 64
Accessibility 💚 100
Best Practices 💚 100
SEO 💚 93

🔗 View full report

@heitorado heitorado changed the base branch from master to develop February 2, 2022 17:11
Copy link
Contributor

@filipewl filipewl left a comment

Choose a reason for hiding this comment

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

The extraction is looking good! I left some questions for us to think about.

src/components/search/Sort/Sort.tsx Outdated Show resolved Hide resolved
src/components/ui/Select/select.scss Outdated Show resolved Hide resolved
src/components/ui/Select/Select.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@renatamottam renatamottam left a comment

Choose a reason for hiding this comment

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

Nice improvement! 😍

@heitorado heitorado force-pushed the refactor/extract-select-component branch from b516976 to 9f6df2d Compare February 2, 2022 21:10
@heitorado heitorado requested a review from hellofanny February 3, 2022 17:57
Copy link
Contributor

@saranicoly saranicoly left a comment

Choose a reason for hiding this comment

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

Great job!

Copy link
Contributor

@filipewl filipewl left a comment

Choose a reason for hiding this comment

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

Well done!
👏

@heitorado heitorado force-pushed the refactor/extract-select-component branch from 40a8fd4 to 590cac3 Compare February 3, 2022 18:23
src/components/ui/Select/Select.tsx Outdated Show resolved Hide resolved
src/components/ui/Select/Select.tsx Outdated Show resolved Hide resolved
src/components/ui/Select/Select.tsx Outdated Show resolved Hide resolved
src/components/ui/Select/Select.tsx Show resolved Hide resolved
@heitorado heitorado merged commit 5158652 into develop Feb 4, 2022
@heitorado heitorado deleted the refactor/extract-select-component branch February 4, 2022 00:50
@renatamottam renatamottam mentioned this pull request Feb 7, 2022
danzanzini pushed a commit that referenced this pull request Feb 7, 2022
* Extract UISelect from Sort to its own component

* Rename data-ui-select to data-select

* Change attribute className to classes

* Remove whitespace

* Remove aria-label property from Sort

* Make 'id' a required attribute for Select

* Change 'SelectOptions' type to Record

* Use className attribute instead of classes

Co-authored-by: Fanny Chien <fannychienn@gmail.com>
danzanzini pushed a commit that referenced this pull request Feb 7, 2022
* Extract UISelect from Sort to its own component

* Rename data-ui-select to data-select

* Change attribute className to classes

* Remove whitespace

* Remove aria-label property from Sort

* Make 'id' a required attribute for Select

* Change 'SelectOptions' type to Record

* Use className attribute instead of classes

Co-authored-by: Fanny Chien <fannychienn@gmail.com>
@renatamottam renatamottam mentioned this pull request Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants