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

[BD-46] feat: add Multiselect component #1498

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

monteri
Copy link
Contributor

@monteri monteri commented Jul 25, 2022

Description

  • modify React Select to get Multiselect component according to the design
  • tests
  • update component-generator to place proper quotes

Deploy Preview

Multiselect

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • Does your change adhere to the documented style conventions?
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Were your changes tested in the example app?
  • Is there adequate test coverage for your changes?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please add wittjeff and adamstankiewicz as reviewers on this PR.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks
Copy link

Thanks for the pull request, @monteri!

When this pull request is ready, tag your edX technical lead.

@openedx-webhooks openedx-webhooks added the blended PR is managed through 2U's blended developmnt program label Jul 25, 2022
@netlify
Copy link

netlify bot commented Jul 25, 2022

Deploy Preview for paragon-openedx ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 32d0a0b
🔍 Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/631861a5281b0100086bf10e
😎 Deploy Preview https://deploy-preview-1498--paragon-openedx.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 settings.

@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Base: 91.61% // Head: 91.67% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (0648468) compared to base (9c1557f).
Patch coverage: 97.50% of modified lines in pull request are covered.

❗ Current head 0648468 differs from pull request most recent head 32d0a0b. Consider uploading reports for the commit 32d0a0b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1498      +/-   ##
==========================================
+ Coverage   91.61%   91.67%   +0.06%     
==========================================
  Files         208      210       +2     
  Lines        3541     3581      +40     
  Branches      823      829       +6     
==========================================
+ Hits         3244     3283      +39     
- Misses        282      283       +1     
  Partials       15       15              
Impacted Files Coverage Δ
src/Multiselect/index.jsx 83.33% <83.33%> (ø)
src/Multiselect/MultiselectComponents.jsx 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@viktorrusakov viktorrusakov linked an issue Jul 27, 2022 that may be closed by this pull request
@@ -0,0 +1,126 @@
// Put styles related to your component here
Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded :)


&.show {
z-index: $multiselect-floating-label-zindex;
padding: 0 .5em;
Copy link
Member

Choose a reason for hiding this comment

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

nit: should this be rem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct, mistake


const ClearIndicator = (props) => (
<components.ClearIndicator {...props}>
<Icon src={Close} />
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious if we should be using an IconButton here instead of a regular Icon to get its focus/hover styles, though I imagine it might mess with the spacing inside of the input. There might also be a11y implications for rendering a clickable icon outside of an element that indicates its an interactive element (i.e., its not currently inside of a button element or an element with a role="button" for example).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used IconButton instead of default component. Styled to fit the design. Added some changes according to focus/hover.


const DropdownIndicator = (props) => (
<components.DropdownIndicator {...props}>
<Icon src={KeyboardArrowDown} />
Copy link
Member

Choose a reason for hiding this comment

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

Similar question regarding IconButton vs Icon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same here

@@ -0,0 +1,136 @@
import React from 'react';
import classNames from 'classnames';
import { components } from 'react-select';
Copy link
Member

Choose a reason for hiding this comment

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

nit: import { components as reactSelectComponents } from 'react-select'; just to be a tad more explicit

</components.ValueContainer>
);

const Control = ({
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Did you attempt to make use of Form.Control in any way here to avoid having to replicate CSS styles? Might not be possible or overly complex, but just wondering if we explored that avenue 😄

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 didn't try because if I place Form.Control instead of Control it will appear as Form.Control inside another Form.Control and there a lot of change will be needed vs make some style and logic updates. The only problem that took a lot of time was to set up floating label.

<components.Option className={classNames({ 'is-focus': props.isFocused })} {...props} />
);

const MultiValueContainer = ({ innerProps, ...props }) => {
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Did we try to explore whether we could make use of the existing Chip here? The Chip-like elements in this multiselect implementation are different from the behavior of the Paragon Chip component in that the entire element is clickable to dismiss it, not just the icon.

Related, is there any way to focus with keyboard only navigation on these chips for a11y support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Chip in the Multiselect is different from the Paragon's Chip and actually it was easier to change some styles to fit design vs replacing whole component. In last commit I added a11y support (focus for Chip icon and onKeyPress activates onClick)


return (
<Stack direction="vertical">
<div className="w-100 p-4">
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the horizontal padding is necessary for the examples without a background as it creates unnecessary whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to py-4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blended PR is managed through 2U's blended developmnt program
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Implement Multiselect
4 participants