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

[SegmentedControl] Refinements #1177

Merged

Conversation

michaeljaltamirano
Copy link
Contributor

@michaeljaltamirano michaeljaltamirano commented Sep 24, 2021

CHANGELOG

  1. Run eslint --fix to address new standards since branch was created.

  2. Replace 80px border-radius with theme.BORDER_RADIUS.large.

    • It is accurately 0 for the secondary theme, and it is 32px for the primary theme, which is equal to 80px (you can edit in your dev tools to examine this.)
  3. Update transition: transform 0.22s to transition: transform 0.3s to match 300ms specified in Figma spec: Screen Shot 2021-09-24 at 12 24 01 AM

  4. Move border style from item container to individual segment items to prevent issue of Indicator being presentationally different from the other segment items.

    • Before: Screen Shot 2021-09-24 at 12 29 39 AM
      • The height of the position: absolute element was larger because the border on the parent was not affecting the height.
    • After: Screen Shot 2021-09-24 at 12 29 46 AM

    TODO: There' still some refinement that could be made here: the absolutely positioned indicator is 172px width compared to 168px width for the non-indicator buttons, so they should be made more consistent, probably.

  5. Update the width handling--by removing the horizontal padding from padding: 0.25rem--such that the position: absolute Indicator element width matches the other elements.

    • Before:
    Indicator.position.before.mov
    • After:
    Indicator.position.after.mov
  6. Add visual regression tests for un-selected focus state.

TODO for future PRs

The current functionality sits somewhere between a RadioGroup and a TabList. In both examples the keyboard controls use tabbing to focus the options, and then arrow keys to toggle between the options, where changing the selection is done automatically, without a button "click" event.

If we decide to use neither of these paradigms, the biggest problem right now is that because the Indicator comes before the more appropriately interactive button elements, toggling through the options sometimes paradoxically goes backwards in order. (See also this comment in the other PR.) This video shows normal tabbing behavior: the first selection is the indicator, and then it starts from the first available button, and then skips the button that matches the indicator selection and proceeds to the next focusable element:

segmentedcontrol.tab.behavior.mov

This needs to be fixed in a future PR, but for now we are maintaining this behavior to unblock UI development this week.

@snags88 snags88 temporarily deployed to curology-radiance-pr-1177 September 24, 2021 03:39 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-1177 September 24, 2021 04:42 Inactive
Copy link
Contributor

@winstonkim winstonkim left a comment

Choose a reason for hiding this comment

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

oh didn't even realize the component looked the same with borderRadius.large. good catch! 😅

looks good - thanks for refining this!

@michaeljaltamirano michaeljaltamirano merged commit 87e96b7 into add-new-tab-component Sep 28, 2021
@michaeljaltamirano michaeljaltamirano deleted the michael/add-new-tab-component branch September 28, 2021 03:13
winstonkim added a commit that referenced this pull request Sep 28, 2021
* add SegmentedControl element

* add docs

* add handling for active index

* add type for example element

* add variable items to example story

* update comments

* add tests

* fix styling

* update snapshot

* add focus box-shadow

* update snapshot

* remove Knobs

* update

* focus styling

* update snapshot

* return null if length is less than 1

* update

* Update to new Component Story Format

* Remove markdown file

* Pull COLORS from theme object, use theme test utils, update onClick test

* use React Testing Library instead of Enzyme

* Add secondary stories

* Update snapshots

* Add sstyling for secondary theme

* Run ESLint fix

* Use BORDER_RADIUS.large (32px equivalent to 80px)

* [SegmentedControl] Refinements (#1177)

* Run ESLint fix

* Use BORDER_RADIUS.large (32px equivalent to 80px)

* Move border to items instead of container to account for absolutely positioned indicator

* Update snapshots

* Rename width to segmentWidth to not set width property to DOM element, remove horizontal padding

* Remove errant (redundant?) box-shadow, use padding instead of border so focus ring is consistent across control

* Add slight margin to get button dimensions better matching Figma file

* Add regression tests for focus states

* Update snapshot

* use Z_SCALE constant

* Update snapshot for 40px height change

Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>
Co-authored-by: Winston Kim <winzton.kim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants