Last active
August 10, 2021 21:52
-
-
Save robertpenner/b1bd12d2397df0399159203804d00aab to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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
/* | |
TODO: | |
- LIVE status | |
- Pre and Post statuses | |
x delay notice (in context) | |
x switch category, e.g. Pro-Am | |
x loading data | |
x update data | |
x change sort direction | |
x change sort column | |
x more menu | |
x debounce search typing | |
*/ | |
const context_blank = { | |
categories: [], | |
selectedCategory: '', | |
scoringDelayMins: 0, | |
players: [], | |
sortDirection: 'descending', | |
}; | |
const context_pebble_beach = { | |
categories: ['PROS', 'AMATEURS'], | |
selectedCategory: 'PROS', | |
scoringDelayMins: 0, | |
players: [ | |
{ | |
id: '1', | |
position: 'T1', | |
following: true, | |
displayName: 'Rahm, J.', | |
titleist: true, | |
total: '-4', | |
thru: 'F', | |
r2: '-2', | |
}, | |
{ | |
id: '2', | |
position: 'T1', | |
following: false, | |
displayName: 'Palmer, R.', | |
titleist: false, | |
total: '-6', | |
thru: '11', | |
r2: '-4', | |
}, | |
{ | |
id: '3', | |
position: '3', | |
following: false, | |
displayName: 'Fitzpatrick, M.', | |
titleist: true, | |
total: 'E', | |
thru: '13', | |
r2: 'E', | |
}, | |
], | |
}; | |
const machine = Machine({ | |
id: 'Leaderboard - 2021-08-10', | |
context: context_blank, | |
type: 'parallel', | |
states: { | |
'tournament card': { | |
on: { | |
'TAP TOURNAMENT CARD': { | |
actions: 'open tournament half-sheet', | |
}, | |
}, | |
}, | |
'tournament half-sheet': { | |
initial: 'hidden', | |
states: { | |
hidden: { | |
on: { 'SHOW HALF-SHEET': 'visible' }, | |
}, | |
visible: { | |
on: { 'HIDE HALF-SHEET': 'hidden' }, | |
}, | |
}, | |
}, | |
'category selector': { | |
initial: 'hidden', | |
states: { | |
hidden: { | |
on: { | |
'HAS MULTIPLE CATEGORIES': 'closed', | |
} | |
}, | |
closed: { | |
on: { | |
'OPEN CATEGORY SELECTOR': 'open', | |
} | |
}, | |
open: { | |
on: { | |
'CLOSE CATEGORY SELECTOR': 'closed', | |
'SELECT CATEGORY': { | |
target: 'closed', | |
actions: 'assign category', | |
}, | |
}, | |
}, | |
}, | |
}, | |
'search field': { | |
initial: 'hidden', | |
states: { | |
hidden: { | |
on: { | |
'TAP SEARCH ICON': 'visible', | |
}, | |
}, | |
'visible': { | |
exit: 'clear filter', | |
initial: 'empty', | |
states: { | |
empty: { | |
entry: 'clear filter', | |
}, | |
typing: { | |
entry: 'assign filter', | |
on: { | |
'EDIT FILTER': 'typing', | |
}, | |
after: { | |
'DEBOUNCE SEARCH': 'filtering', | |
}, | |
}, | |
filtering: { | |
entry: 'apply filter', | |
}, | |
}, | |
on: { | |
'LEAVE SEARCH': 'hidden', | |
'CLEAR FILTER': '.empty', | |
'EDIT FILTER': '.typing', | |
} | |
}, | |
}, | |
}, | |
'players': { | |
type: 'parallel', | |
states: { | |
'data source': { | |
initial: 'disconnected', | |
states: { | |
disconnected: { | |
on: { | |
'CONNECT': 'connected' | |
} | |
}, | |
connected: { | |
initial: 'empty', | |
states: { | |
empty: {}, | |
populated: {}, | |
}, | |
on: { | |
DISCONNECT: 'disconnected', | |
'RECEIVE RANKINGS DATA': { | |
target: '.populated', | |
actions: 'assign rankings', | |
} | |
} | |
} | |
}, | |
}, | |
sorting: { | |
initial: 'ascending', | |
states: { | |
ascending: { | |
on: { | |
'TAP THE SORT-BY COLUMN': 'descending', | |
}, | |
}, | |
descending: { | |
on: { | |
'TAP THE SORT-BY COLUMN': 'ascending', | |
}, | |
}, | |
}, | |
on: { | |
'TAP AN UNSORTED COLUMN': { | |
target: '.ascending', | |
actions: 'change sort-by column', | |
}, | |
}, | |
}, | |
'player icons': { | |
on: { | |
'TAP A PLAYER FLAG': { | |
actions: 'follow the player', | |
}, | |
'TAP A PLAYER STAR': { | |
actions: 'unfollow the player', | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
{ | |
delays: { | |
'DEBOUNCE SEARCH': 1000, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment