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(PPDSC-2054): add feedback element and transition preset to slider, checkbox & radio button #160

Conversation

evgenitsn
Copy link
Contributor

@evgenitsn evgenitsn commented Apr 13, 2022

PPDSC-2054

What

Added:

  • Feedback element to the thumb on the slider component
  • opacityChange preset
  • opacityChange applied on the feedback element on the slider thumb
  • opacityChange applied on the checkbox and radio button (base-switch) feedback elements
  • Support for active state (mouse down event) for checkbox, radio button and slider thumb

Feedback preset is now extracted and reused in the components mentioned above.

This PR combines:
https://nidigitalsolutions.jira.com/browse/PPDSC-2054
and
https://nidigitalsolutions.jira.com/browse/PPDSC-1965

I have done:

  • Written unit tests against changes
  • Written functional tests against the component and/or NewsKit site
  • Updated relevant documentation

I have tested manually:

  • The feature's functionality is working as expected on Chrome, Firefox, Safari and Edge
  • The screen reader reads and flows through the elements as expected.
  • There are no new errors in the browser console coming from this PR.
  • When visual test is not added, it renders correctly on different browsers and mobile viewports (Safari, Firefox, small mobile viewport, tablet)
  • The Playground feature is working as expected
Screen.Recording.2022-04-13.at.3.54.40.pm.mov
Screen.Recording.2022-04-13.at.3.55.22.pm.mov
Screen.Recording.2022-04-13.at.3.54.05.pm.mov

@evgenitsn evgenitsn added the ready for design review Please assist in getting this reviewed label Apr 13, 2022
@github-actions github-actions bot added the feature This change contains a new feature label Apr 13, 2022
mutebg
mutebg previously approved these changes Apr 21, 2022
src/base-switch/base-switch.tsx Outdated Show resolved Hide resolved
src/base-switch/base-switch.tsx Outdated Show resolved Hide resolved
mutebg
mutebg previously approved these changes Apr 21, 2022
src/slider/styled.ts Outdated Show resolved Hide resolved
src/base-switch/base-switch.tsx Show resolved Hide resolved
src/base-switch/styled.tsx Show resolved Hide resolved
@@ -117,6 +118,11 @@ const ThemelessSlider: React.FC<SliderProps> = ({
data-testid={`${dataTestId}-thumb`}
overrides={overrides}
>
<StyledFeedback
Copy link

Choose a reason for hiding this comment

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

Just to clarify that this feedback component unlike the one one the base sitch is layered above the thumb, right ?
Screenshot 2022-04-21 at 21 27 56

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I am not sure about that one. I haven't thought about it at all.
Now looking at the code I can see that we control with layering on the BaseSwitch using this right?

const STACKING_CONTEXT = {
  feedback: '1',
  input: '2',
};

I haven't seen any specific requirement for that, so maybe we want to align that layering for the slider to be the same as the BaseSwitch?

Copy link

Choose a reason for hiding this comment

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

My personal preference would be to get the Feedback component to work the same way across all components, including the layering as well.
But on the other hand, it looks like there is no need for such change now.

@mutebg We need to check how these z-indices will work inside a Layer for example

@evgenitsn evgenitsn added ready for review Please assist in getting this reviewed and removed ready for design review Please assist in getting this reviewed labels Apr 26, 2022
Currently only Safari 15.4 supports :focus-visible.
For the previous versions of Safari, we will return true here which means that the focus ring on the elements which are using this function will be visible on mouse click. So this acts more like an incremental enhancement for Safari. For all other supported browsers this will work as expected because they have good support for :focus-visible.
*/
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

In which cases will it return false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

False would be returned only in the try block if the element doesn't have this selector applied, i.e. if this is false e.target.matches(':focus-visible');

In the catch block the result will only be true. The catch block will only be triggered if the browser does not support :focus-visible which means that in this case it's better to just return true to toggle the focus ring for the targeted element every time.

@pdimova pdimova self-requested a review April 27, 2022 07:30
@evgenitsn evgenitsn merged commit ca22226 into main Apr 27, 2022
@evgenitsn evgenitsn deleted the feat/PPDSC-2054-add-feedback-element-and-transition-preset-to-slider-checkbox-radio branch April 27, 2022 11:29
Xin00163 pushed a commit that referenced this pull request Oct 17, 2022
…r, checkbox & radio button (#160)

* feat(PPDSC-2054): add feedback element and transition preset

* feat(PPDSC-2054): added :focus-visible support

* feat(PPDSC-2054): update feedback override for the audio player seek bar

* feat(PPDSC-2054): update snapshots

* feat(PPDSC-2054): polishing code

* feat(PPDSC-2054): update components naming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This change contains a new feature ready for review Please assist in getting this reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the feedback element & transitionPreset for feedback to Slider & seekBar thumb
6 participants