-
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
Changes from 24 commits
0318460
79afbd8
9cb871d
28835c5
cae165f
e0a07fc
5482243
c794314
822b8a9
2187df8
bc3dc49
045ce8b
271334e
5bbbeae
49e85f0
ff2ea69
6fe6933
77ffa85
3ad3998
1599a24
4e97c5c
524a567
2d9f8a9
162d929
66af583
89f9aaf
0b2d7a1
f13a346
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import { useInventoryCardsCollectionGetCollection } from "src/generated" | |
import { Card } from "src/store/types" | ||
import { Address } from "src/chain" | ||
import { FablePage } from "src/pages/_app" | ||
import Link from "next/link" | ||
import { router } from 'next/router'; | ||
|
||
// NOTE(norswap & geniusgarlic): Just an example, when the game actually has effects & types, | ||
// fetch those from the chain instead of hardcoding them here. | ||
|
@@ -26,7 +28,7 @@ const initialEffectMap = Object.assign({}, ...effects.map(name => ({[name]: fals | |
const types = ['Creature', 'Magic', 'Weapon'] | ||
const initialTypeMap = Object.assign({}, ...types.map(name => ({[name]: false}))) | ||
|
||
const Collection: FablePage = ({ isHydrated }) => { | ||
const Collection: FablePage = ({ decks, isHydrated }) => { | ||
|
||
const { address } = useAccount() | ||
const [ selectedCard, setSelectedCard ] = useState<Card|null>(null) | ||
|
@@ -80,7 +82,6 @@ const Collection: FablePage = ({ isHydrated }) => { | |
<Head> | ||
<title>0xFable: My Collection</title> | ||
</Head> | ||
|
||
{jotaiDebug()} | ||
<main className="flex h-screen flex-col"> | ||
<Navbar /> | ||
|
@@ -141,22 +142,22 @@ const Collection: FablePage = ({ isHydrated }) => { | |
<div className="text-center m-2">{cardFlavor}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{/* Card Collection Display */} | ||
<div className="col-span-9 flex rounded-xl border overflow-y-auto"> | ||
<div className="col-span-7 flex rounded-xl border overflow-y-auto"> | ||
{ isHydrated && cards.length == 0 && | ||
<div className="flex flex-row w-full justify-center items-center"> | ||
<MintDeckModal callback={refetch} /> | ||
</div>} | ||
|
||
{ isHydrated && cards.length > 0 && | ||
<div className="grid grid-cols-4 gap-4 overflow-y-auto pb-4"> | ||
<div className="grid grid-cols-4 overflow-y-auto pb-4"> | ||
{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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to do some alternative experiments and see what sticks. |
||
{/*TODO handle the image*/} | ||
<Image src="/card_art/0.jpg" alt={card.lore.name} width={256} height={256} /> | ||
<div className="text-center">{card.lore.name}</div> | ||
|
@@ -172,6 +173,30 @@ const Collection: FablePage = ({ isHydrated }) => { | |
))} | ||
</div>} | ||
</div> | ||
|
||
{/* Deck Panel */} | ||
<div className="col-span-2 flex rounded-xl border overflow-y-auto"> | ||
<div className="w-full flex flex-col items-center p-3"> | ||
{/* New Deck Button */} | ||
<Link className="w-full px-4 py-2 mb-2 border rounded-md text-gray-100 bg-purple-900 hover:bg-gray-500 font-bold text-center focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" href={"/editor"}> | ||
New Deck → | ||
</Link> | ||
|
||
{/* Deck Buttons */} | ||
{decks.map((deck, index) => ( | ||
<button | ||
key={index} | ||
className="w-full px-4 py-2 mb-2 border rounded-md text-gray-100 bg-purple-900 hover:bg-gray-500 font-bold text-center focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" | ||
onClick={() => { | ||
// Navigate to the editor view with the selected deck's index as a route parameter | ||
router.push(`/editor?index=${index}`); | ||
}} | ||
> | ||
{deck.name} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
</> | ||
|
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.