Created
April 7, 2020 18:09
-
-
Save kyleshevlin/bcdabf85791e47127e507c7cf3f34fce to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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
const VIEWS = { | |
FULL: 'FULL', | |
SIDE: 'SIDE' | |
} | |
const itemMachine = Machine({ | |
id: 'item', | |
context: { | |
view: VIEWS.SIDE, | |
}, | |
on: { | |
SELECT_ALL: 'forSelection.selected', | |
UNSELECT_ALL: 'forSelection.unselected', | |
SET_VIEW: { | |
target: ['forHover.idle', 'forSelection.unselected'], | |
actions: ['setView'], | |
}, | |
}, | |
type: 'parallel', | |
states: { | |
forHover: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
HOVER: 'hovered', | |
}, | |
}, | |
hovered: { | |
entry: ['hoverItem', 'updateAssetSelection'], | |
exit: ['leaveItem', 'resetAssetSelection'], | |
initial: 'normal', | |
states: { | |
normal: { | |
on: { | |
PRESELECT: { | |
target: 'preselected', | |
cond: 'isFullView', | |
}, | |
}, | |
}, | |
preselected: { | |
on: { | |
LEAVE: 'normal', | |
}, | |
}, | |
}, | |
on: { | |
LEAVE: 'idle', | |
}, | |
}, | |
}, | |
}, | |
forSelection: { | |
initial: 'unselected', | |
states: { | |
unselected: { | |
on: { | |
SELECT: 'selected', | |
}, | |
}, | |
selected: { | |
on: { | |
UNSELECT: 'unselected', | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment