Slay the Spire #4: Links are real, and strong, and they are my friend
August 3, 2024The thing about doing a project as daily writing-and-coding sessions is you get a lot of time inbetween sessions to mull things over. Two things have been stuck in my mind since last time:
- My unease with the navigation issue, overriding and re-implementing link behavior.
- How to dynamically render the HTML based on game state.
I have a good idea for that second issue now, but I just returned from holiday, and lack the time and energy to finish it today. Ideally, I'd like to get a bit of coding done in each post I do, but if I leave this post in the pipes for a third day in a row, I'm going to feel constipated.
Today, we're only talking navigation.
To recap the navigation issue: I concluded that we want to navigate between game states, as if they were pages, and that links are the most appropriate UI control for that. I also concluded that we will have too much state to keep all the data in URLs, meaning we have to override normal link behavior and re-implement it all to work with our application state.
I was aware, at the time, that it would be messy and difficult to do right. Having sat with it for a day, it now looks even worse in my mind.
When pages have state stored outside the URL, and links modify that state instead of navigating to a URL, here are all the affordances I can think of that we lose:
- Page history
- Navigating to the next/previous page
- Opening links in a new tab
- Reloading pages without losing data
- Browser bookmarks
- Sharing page links with others
Some of those items sound like a pain to re-implement to the standard of normal links. The rest of them sound impossible to re-implement to the same standard.
These affordances are useful and expected. Messing them up would make our app kind of crap. I don't want to make this project kind of crap, I want to make it nice. Messing with link behavior would make a mess that we cannot clean up.
However. I was struck with an idea. I think it is possible to fit all the necessary page state in less than a couple thousand characters. And if we accomplish that, the constraint that pushed us down this dark path in the first place is gone.
In other words:
Plain links are back on menu!