-
Notifications
You must be signed in to change notification settings - Fork 3
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
michaeljaltamirano
merged 9 commits into
add-new-tab-component
from
michael/add-new-tab-component
Sep 28, 2021
Merged
[SegmentedControl] Refinements #1177
michaeljaltamirano
merged 9 commits into
add-new-tab-component
from
michael/add-new-tab-component
Sep 28, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…, remove horizontal padding
winstonkim
approved these changes
Sep 24, 2021
There was a problem hiding this 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!
…so focus ring is consistent across control
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CHANGELOG
Run
eslint --fix
to address new standards since branch was created.Replace
80px
border-radius
withtheme.BORDER_RADIUS.large
.0
for the secondary theme, and it is32px
for the primary theme, which is equal to80px
(you can edit in your dev tools to examine this.)Update
transition: transform 0.22s
totransition: transform 0.3s
to match300ms
specified in Figma spec:Move
border
style from item container to individual segment items to prevent issue ofIndicator
being presentationally different from the other segment items.position: absolute
element was larger because theborder
on the parent was not affecting the height.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.
Update the width handling--by removing the horizontal padding from
padding: 0.25rem
--such that theposition: absolute
Indicator element width matches the other elements.Indicator.position.before.mov
Indicator.position.after.mov
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.