-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add missing hold affordance icon for longPress S2 MenuTriggers #10066
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
34c5c2b
add action button hold affordance + menu
LFDanLu d924bb8
add toggle button support
LFDanLu 880afd8
chromatic stories
LFDanLu 899e267
missed the fact that trigger already existed as a prop...
LFDanLu 20baef5
add tests and review comments
LFDanLu 89fbda8
fix comment location
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import {ActionButtonContext} from './ActionButton'; | ||
| import { | ||
| Menu as AriaMenu, | ||
| MenuItem as AriaMenuItem, | ||
|
|
@@ -23,7 +24,6 @@ import { | |
| SubmenuTriggerProps as AriaSubmenuTriggerProps, | ||
| MenuItemRenderProps | ||
| } from 'react-aria-components/Menu'; | ||
|
|
||
| import { | ||
| baseColor, | ||
| centerPadding, | ||
|
|
@@ -61,17 +61,18 @@ import {edgeToText} from '../style/spectrum-theme' with {type: 'macro'}; | |
| import {forwardRefType} from './types'; | ||
| import {HeaderContext, HeadingContext, KeyboardContext, Text, TextContext} from './Content'; | ||
| import {IconContext} from './Icon'; | ||
| import {ImageContext} from './Image'; | ||
| import InfoCircleIcon from '../s2wf-icons/S2_Icon_InfoCircle_20_N.svg'; // chevron right removed?? | ||
| import {ImageContext} from './Image'; // chevron right removed?? | ||
| import InfoCircleIcon from '../s2wf-icons/S2_Icon_InfoCircle_20_N.svg'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. misplaced comment? Or should this be removed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugh, must of been the formatter or auto import moving things around, thanks for the catch |
||
| import {InPopoverContext, Popover, PopoverContext} from './Popover'; | ||
| import intlMessages from '../intl/*.json'; | ||
| // @ts-ignore | ||
| import intlMessages from '../intl/*.json'; | ||
| import LinkOutIcon from '../ui-icons/LinkOut'; | ||
| import {mergeStyles} from '../style/runtime'; | ||
| import {Placement} from 'react-aria/useOverlayPosition'; | ||
| import {PressResponder} from 'react-aria/private/interactions/PressResponder'; | ||
| import {pressScale} from './pressScale'; | ||
| import {Separator, SeparatorProps} from 'react-aria-components/Separator'; | ||
| import {ToggleButtonContext} from './ToggleButton'; | ||
| import {useGlobalListeners} from 'react-aria/private/utils/useGlobalListeners'; | ||
| import {useId} from 'react-aria/useId'; | ||
| import {useLocale} from 'react-aria/I18nProvider'; | ||
|
|
@@ -736,7 +737,7 @@ function MenuTrigger(props: MenuTriggerProps): ReactNode { | |
| ); | ||
| }; | ||
|
|
||
| let {align = 'start', direction = 'bottom', shouldFlip} = props; | ||
| let {align = 'start', direction = 'bottom', shouldFlip, trigger = 'press'} = props; | ||
| let placement: Placement; | ||
| switch (direction) { | ||
| case 'left': | ||
|
|
@@ -750,25 +751,32 @@ function MenuTrigger(props: MenuTriggerProps): ReactNode { | |
| default: | ||
| placement = `${direction} ${align}` as Placement; | ||
| } | ||
| let holdAffordance = trigger === 'longPress'; | ||
|
|
||
| return ( | ||
| <InternalMenuTriggerContext.Provider | ||
| value={{ | ||
| align: props.align, | ||
| direction: props.direction, | ||
| shouldFlip: props.shouldFlip | ||
| }}> | ||
| <PopoverContext.Provider | ||
| value={{hideArrow: true, offset: 8, crossOffset: 0, placement, shouldFlip}}> | ||
| <InPopoverContext.Provider value={false}> | ||
| <AriaMenuTrigger {...props}> | ||
| <PressResponder onPressStart={onPressStart} isPressed={isPressed}> | ||
| {props.children} | ||
| </PressResponder> | ||
| </AriaMenuTrigger> | ||
| </InPopoverContext.Provider> | ||
| </PopoverContext.Provider> | ||
| </InternalMenuTriggerContext.Provider> | ||
| <Provider | ||
| values={[ | ||
| [ActionButtonContext, {holdAffordance}], | ||
| [ToggleButtonContext, {holdAffordance}] | ||
| ]}> | ||
| <InternalMenuTriggerContext.Provider | ||
| value={{ | ||
| align: props.align, | ||
| direction: props.direction, | ||
| shouldFlip: props.shouldFlip | ||
| }}> | ||
| <PopoverContext.Provider | ||
| value={{hideArrow: true, offset: 8, crossOffset: 0, placement, shouldFlip}}> | ||
| <InPopoverContext.Provider value={false}> | ||
| <AriaMenuTrigger {...props}> | ||
| <PressResponder onPressStart={onPressStart} isPressed={isPressed}> | ||
| {props.children} | ||
| </PressResponder> | ||
| </AriaMenuTrigger> | ||
| </InPopoverContext.Provider> | ||
| </PopoverContext.Provider> | ||
| </InternalMenuTriggerContext.Provider> | ||
| </Provider> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
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.
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.
just add to the context interface?
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 good point, I guess I could use the same context in the Chromatic instead of using the prop directly too