Skip to content

Commit

Permalink
chore(tooltip): expose open and close api
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Mar 21, 2022
1 parent a0df702 commit 02fff16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/machines/tooltip/src/tooltip.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export function connect<T extends PropTypes = ReactPropTypes>(
return {
isVisible,
hasAriaLabel: state.context.hasAriaLabel,

open() {
send("OPEN")
},
close() {
send("CLOSE")
},
getAnimationState() {
return {
enter: store.prevId === null && id === store.id,
Expand Down
9 changes: 7 additions & 2 deletions packages/machines/tooltip/src/tooltip.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const machine = createMachine<MachineContext, MachineState>(
isPlacementComplete: (ctx) => !!ctx.currentPlacement,
},

on: {
OPEN: "open",
CLOSE: "closed",
},

states: {
unknown: {
on: {
Expand Down Expand Up @@ -65,12 +70,12 @@ export const machine = createMachine<MachineContext, MachineState>(
on: {
POINTER_LEAVE: "closed",
BLUR: "closed",
SCROLL: "closed",
POINTER_LOCK_CHANGE: "closed",
POINTER_DOWN: {
guard: "closeOnPointerDown",
target: "closed",
},
SCROLL: "closed",
POINTER_LOCK_CHANGE: "closed",
},
},

Expand Down

0 comments on commit 02fff16

Please sign in to comment.