Skip to content

Commit

Permalink
Better platform handling
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Mar 4, 2024
1 parent a496a38 commit ac6b5fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 1 addition & 8 deletions src/components/Menu/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,10 @@ export function Trigger({
onOut: onMouseLeave,
} = useInteractionState()
const {state: focused, onIn: onFocus, onOut: onBlur} = useInteractionState()
const {
state: pressed,
onIn: onPressIn,
onOut: onPressOut,
} = useInteractionState()

return (
<DropdownMenu.Trigger asChild>
<Pressable
onPressIn={onPressIn}
onPressOut={onPressOut}
onFocus={onFocus}
onBlur={onBlur}
style={flatten([web({outline: 0})])}
Expand All @@ -77,7 +70,7 @@ export function Trigger({
state: {
hovered,
focused,
pressed,
pressed: false,
},
handlers: {},
})}
Expand Down
8 changes: 7 additions & 1 deletion src/components/Menu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export type TriggerChildProps =
isNative: true
control: Dialog.DialogOuterProps['control']
state: {
/**
* Web only, `false` on native
*/
hovered: false
focused: boolean
pressed: boolean
Expand All @@ -27,7 +30,10 @@ export type TriggerChildProps =
state: {
hovered: boolean
focused: boolean
pressed: boolean
/**
* Native only, `false` on web
*/
pressed: false
}
handlers: {}
}
2 changes: 1 addition & 1 deletion src/view/screens/Storybook/Menus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Menus() {
<Menu.Root>
<Menu.Trigger>
{({state, handlers}) => {
console.log(state)
console.log(state.hovered, state.focused, state.pressed)
return <Text {...handlers}>Open</Text>
}}
</Menu.Trigger>
Expand Down

0 comments on commit ac6b5fa

Please sign in to comment.