-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deck Editor added #96
Conversation
Hey Eviterin! Thanks for contributing! Could you split the diagram and the deck editor into two different PRs to make it easier to review / faster to merge? Quick feedback on the diagram:
I'm semi-off this week, but I'll try taking a look at the deck editor later this week. |
Thanks for the feedback. Against all odds I have been able to split up the pull request in two. |
We haven't really been doing this in a while, so it's fine. We probably ought to rewrite playwright tests to not use Metamask in most cases (as that makes it very slow and it's more fragile when updating etc). Future work :') |
This is pretty nice! The collection page was also pretty much exploration work, and is even uglier than the rest of the game. We probably won't feature it in the proof of concept. Nevertheless, here's an issue with some ideas of what that facelift could look like. Adding the deck editor is an interesting additional constraint. I like what you've done, and I think we could integrate it into the proposal above with a right panel (but that just displays when visualizing or editing the deck). One thing I would change is to replace the full-size display of cards in the right panel with a "list" view where only the name of the card (and in time, some logo/colors/decorations for its main characteristics, e.g. creature, color, ...). We could display the full card on hover (either inline or in a popup). UX IssuesSome UX problems I've seen in testing:
Card DetailsA question I had was how to handle card details display. Right now we can display all details pretty easily but long term that won't be the case. A hover display works, thought it'd be nice to be able to keep a card displayed and compare with others? Maybe that isn't really needed. Also where to put that display? In the collection UX overhaul issue, we haven't budgeted space for displaying the card on the left as exists currently. Maybe we could reintroduce that (split the left panel in two halves — maybe allowing to minimize the top half (lists of decks & filters) for small screens. We could have a floating hover, but that could be janky when trying to move away from it? Maybe it works. Another option is to require a click for expanded display then have a "Add to Deck / Remove From Deck" button on the expanded display. Next StepsI see two ways to build on this:
|
Hey Norswap. Thank you for the awesome feedback and for sharing your thoughts. There are some things you mention that I don't really have much experience with and might need some pointers on. Marked with (!). Would you prefer these changes in one PR or can I split it up in three, as proposed below. #40 related, short term: #40 related short/medium term: #93 related, medium term: Anything I'm missing? |
Fixed the short term stuff. Although there is a known error: when loading an existing deck, it does not highlight the cards that are in the deck. Seems that since we are using index to identify cards and we have two views (collection and editor) the ids don't match up. ID 0 in collection is ID 24 in editor, 1 in collection is 25 in editor. And so on - since we have 24 cards. This issue should resolve itself once editor and collection have been merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently when I submitted my review it did not post the comments I've been making ... sorry about that, at least they're here now!
{cards.map(card => ( | ||
<div className="m-4 bg-slate-900/50 hover:bg-slate-800 rounded-lg p-4 border-4 border-slate-900" | ||
key={`${card.id}`} | ||
style={{height: 'fit-content'}} | ||
onClick={() => setSelectedCard(card)}> | ||
onMouseEnter={() => setSelectedCard(card)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure I like this as a UX change.
Edit: I understand it in context, since clicking in the editor adds to / removes from the deck. See discussion in big comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to do some alternative experiments and see what sticks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling the collection and editor pages should probably be unified — make the editor part of the collection page. It'll probably require isolating some components to their own file to avoid a bloated source file though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'll get on that... at some point.
packages/webapp/src/pages/editor.tsx
Outdated
import { Address } from "src/chain" | ||
import { FablePage } from "src/pages/_app" | ||
import { router } from 'next/router'; | ||
import { useEffect} from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're avoiding semicolons in the codebase.
We ought to add a formatter in.
packages/webapp/src/pages/editor.tsx
Outdated
if (!isNaN(deckIndex) && decks[deckIndex] != null) { | ||
setDeck(decks[deckIndex].cards); | ||
} | ||
}, [router.query.index, decks]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might clash with the index
parameter used in debug mode to set the wallet address, probably picking another name like deckID
for the URL parameter would be better.
packages/webapp/src/pages/editor.tsx
Outdated
// Add the new deck to the decks state | ||
setDecks(prevDecks => [...prevDecks, newDeck]); | ||
// Add as a new deck | ||
updatedDecks.push({ name: deckName, cards: deck }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could avoid mutation here and use sthing like
let updatedDecks: Decks[] = []
...
// first branch
decks.toSpliced(originalsDeckIndex,1)
...
// second branch
decks.toSpliced(originalDeckIndex, 1, { name: deckName, cards: deck })
The big advantage would be avoiding changing the deck ordering.
Anyway, let's not do that, as we'll need to manage the decks on chain anyway :D
So I'd say before merging this:
The rest of the work can come in the subsequent PR! Oh also, let's try to avoid merge commits in branches. Actually right now we rebase everything (even PRs are merged by rebase), but I'm wondering about merging PRs with merge instead of rebase instead. |
One UX note: the buttons overflow to the right of the textfield, creating a lateral scrollbar — we should avoid that! |
Fixed the semicolon stuff and the index renaming! |
Approved, but needs to be rebased to be mergeable! |
Context (Problem, Motivation, Solution)
There needs to be a deck editor in place (see: #40).
Index page updated to redirect to editor. Which has heavily borrowed content from the collections page.
Describe Your Changes
What's not included?
A place to view the player's decks (I'm thinking collections page)
Logic to save the deck (no onchain transaction)
Checklist
make check
and fixed resulting issuesRan linter and resolved all warnings and errors.
Exploratory testing only. Should I be writing tests in e2e using playwright?
Testing