Replies: 1 comment 1 reply
-
This is how the above Figma file is converted (XState V4 state config) {
id:'Page_1',
initial:'Frame_1',
states:{
Frame_1:{
id:'Frame_1',
initial:'idle',
states:{
idle:{},
Anchor_2:{
},
Anchor_1:{
},
Anchor_3:{
},
},
on:{
ON_CLICK_SCROLL_TO_ANCHOR_2_SCROLL_TO:'#Page_1.Frame_1.Anchor_2',
ON_CLICK_SCROLL_TO_ANCHOR_1_SCROLL_TO:'#Page_1.Frame_1.Anchor_1',
ON_CLICK_SCROLL_TO_ANCHOR_3_SCROLL_TO:'#Page_1.Frame_1.Anchor_3',
},
},
},
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The main idea behind the Figma to XState plugin is to transform Figma's prototype into an XState machine to use as a starting point for creating the real XState machine that developers will use.
At the moment, Figma's frames are exported as XState's states, and the reactions that navigate among different frames are transformed into events.
The
SCROLL_TO
reactions are a bit different from theNAVIGATE
ones:NAVIGATE
events bring the users to a different frame, whileSCROLL_TO
ones do notSCROLL_TO
events mimic the standard scroll actions on the page, a behavior not typically bound to a state machineSo the main question is: what would the users expect to see in the XState's machine for Figma's
SCROLL_TO
event?First of all, let's start with Figma's official docs, which say
Based on this, I can think of the
SCROLL_TO
reactions as anchor links, something that's stored in the URL's hash as part of the information on the current page.Multiple anchors
The only difference with a standard web page is that a Figma prototype could have more than one "anchor" link for a single frame. See the following video, where I show the "multi-anchor" concept.
Screen.Recording.2023-11-06.at.17.46.34.mov
You can play with the original Figma file here.
So, remaining on the anchor similarity
Anyway, for the sake of simplicity, I will create one state for the anchor-free Figma frame (as already happening) and one state for every frame+anchor combo.
Beta Was this translation helpful? Give feedback.
All reactions