From 2ac3cf7d4679b58b3155edeb5baa8a2ca2a7e5c6 Mon Sep 17 00:00:00 2001 From: Aritra Chatterjee Date: Mon, 4 Mar 2024 11:47:07 +0530 Subject: [PATCH 01/14] feat: style formatting with tailwind prettier plugin --- packages/webapp/.prettierrc.json | 3 +- packages/webapp/package.json | 2 +- packages/webapp/src/actions/joinGame.ts | 3 +- .../webapp/src/components/cards/boardCard.tsx | 14 ++-- .../src/components/cards/cardContainer.tsx | 2 +- .../src/components/cards/draggedCard.tsx | 2 +- .../webapp/src/components/cards/handCard.tsx | 16 ++--- .../collection/cardCollectionDisplay.tsx | 12 ++-- .../src/components/collection/deckList.tsx | 6 +- .../src/components/collection/deckPanel.tsx | 16 ++--- .../src/components/collection/filterPanel.tsx | 20 +++--- packages/webapp/src/components/hand.tsx | 12 ++-- packages/webapp/src/components/lib/modal.tsx | 2 +- .../src/components/lib/modalElements.tsx | 4 +- .../src/components/modals/createGameModal.tsx | 4 +- .../modals/inGameMenuModalContent.tsx | 2 +- .../src/components/modals/joinGameModal.tsx | 4 +- .../src/components/modals/mintDeckModal.tsx | 2 +- packages/webapp/src/components/navbar.tsx | 6 +- .../webapp/src/components/playerBoard.tsx | 12 ++-- packages/webapp/src/pages/collection.tsx | 8 +-- packages/webapp/src/pages/index.tsx | 6 +- packages/webapp/src/pages/play.tsx | 10 +-- pnpm-lock.yaml | 64 ++++++++++++++++++- 24 files changed, 146 insertions(+), 86 deletions(-) diff --git a/packages/webapp/.prettierrc.json b/packages/webapp/.prettierrc.json index da298910..1367ec9a 100644 --- a/packages/webapp/.prettierrc.json +++ b/packages/webapp/.prettierrc.json @@ -4,5 +4,6 @@ "singleQuote": false, "tabWidth": 4, "useTabs": false, - "printWidth": 120 + "printWidth": 120, + "plugins": ["prettier-plugin-tailwindcss"] } diff --git a/packages/webapp/package.json b/packages/webapp/package.json index e373bebe..241f462a 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -53,7 +53,7 @@ "eslint": "^8.52.0", "eslint-config-next": "^13.5.6", "postcss": "^8.4.31", - "prettier": "2.8.8", + "prettier-plugin-tailwindcss": "^0.5.11", "tailwindcss": "^3.3.3", "typescript": "^5.2.2" } diff --git a/packages/webapp/src/actions/joinGame.ts b/packages/webapp/src/actions/joinGame.ts index c4a3c235..fbb1c6ed 100644 --- a/packages/webapp/src/actions/joinGame.ts +++ b/packages/webapp/src/actions/joinGame.ts @@ -85,7 +85,8 @@ async function joinGameImpl(args: JoinGameArgs): Promise { if (gameStatus < GameStatus.JOINED) { // we can skip the join step if already performed const promise = doJoinGameTransaction(args, privateInfo.saltHash) - if (gameID === null) await promise // gameID starts null and the call will set it + if (gameID === null) + await promise // gameID starts null and the call will set it else checkFresh(await freshWrap(promise)) } diff --git a/packages/webapp/src/components/cards/boardCard.tsx b/packages/webapp/src/components/cards/boardCard.tsx index 3c672e86..370218c4 100644 --- a/packages/webapp/src/components/cards/boardCard.tsx +++ b/packages/webapp/src/components/cards/boardCard.tsx @@ -12,14 +12,14 @@ const BoardCard = forwardRef(({ id }, ref) => { return (
setShowCardName(true)} onMouseLeave={() => setShowCardName(false)} > {`${id}`}(({ id }, ref) => { /> {showCardName && ( <> -
-
+
+
{`${testCards[id]?.attack}`}
-
+
{`${testCards[id]?.defense}`}
{`${testCards[id]?.name}`} diff --git a/packages/webapp/src/components/cards/cardContainer.tsx b/packages/webapp/src/components/cards/cardContainer.tsx index 6267b9ca..9c5fcfa1 100644 --- a/packages/webapp/src/components/cards/cardContainer.tsx +++ b/packages/webapp/src/components/cards/cardContainer.tsx @@ -49,7 +49,7 @@ const CardContainer: React.FC = ({ id, handHovered, placement, ca } return (
(({ id }, ref) <> {`${id}`}(({ id, isDragging, ha return (
(({ id, isDragging, ha {testCards[id]?.name} @@ -49,17 +49,17 @@ const HandCard = forwardRef(({ id, isDragging, ha src={testCards[id]?.image} width={showingDetails ? 375 : 200} height={showingDetails ? 375 : 200} - className="pointer-events-none rounded-xl border select-none" + className="pointer-events-none select-none rounded-xl border" style={{ boxShadow: (cardHover && !isDetailsVisible) || cardGlow ? "0 0 10px 2px gold" : "none", // Adds golden glow when hovered }} /> {showingDetails && ( <> -

+

{testCards[id]?.description}

-
+

⚔️ {testCards[id]?.attack}

🛡 {testCards[id]?.defense}

diff --git a/packages/webapp/src/components/collection/cardCollectionDisplay.tsx b/packages/webapp/src/components/collection/cardCollectionDisplay.tsx index 0a2faadc..f3911809 100644 --- a/packages/webapp/src/components/collection/cardCollectionDisplay.tsx +++ b/packages/webapp/src/components/collection/cardCollectionDisplay.tsx @@ -23,9 +23,9 @@ const CardCollectionDisplay: React.FC = ({ }) => { return ( <> -
+
{isHydrated && cards.length === 0 && ( -
+
)} @@ -39,7 +39,7 @@ const CardCollectionDisplay: React.FC = ({ selectedCards.some((c) => c.id === card.id) ? "shadow-highlight shadow-orange-300" : "" - } hover:bg-slate-800 rounded-lg p-4 border-4 border-slate-900 grow w-[220px] max-w-[330px]`} + } w-[220px] max-w-[330px] grow rounded-lg border-4 border-slate-900 p-4 hover:bg-slate-800`} onMouseEnter={() => setSelectedCard(card)} onClick={() => { if (isEditing) { @@ -55,11 +55,11 @@ const CardCollectionDisplay: React.FC = ({ height={256} />
{card.lore.name}
-
-
+
+
{card.stats.attack}
-
+
{card.stats.defense}
diff --git a/packages/webapp/src/components/collection/deckList.tsx b/packages/webapp/src/components/collection/deckList.tsx index 0d6c312a..d85fdc10 100644 --- a/packages/webapp/src/components/collection/deckList.tsx +++ b/packages/webapp/src/components/collection/deckList.tsx @@ -10,12 +10,12 @@ interface DeckCollectionDisplayProps { const DeckCollectionDisplay: React.FC = ({ decks, onDeckSelect }) => { return ( -
+
{/* New Deck Button */}
@@ -26,7 +26,7 @@ const DeckCollectionDisplay: React.FC = ({ decks, on
{/* Types */} -

Types

+

Types

{types.map((type, index) => (
diff --git a/packages/webapp/src/components/hand.tsx b/packages/webapp/src/components/hand.tsx index f2724475..b38ff4d4 100644 --- a/packages/webapp/src/components/hand.tsx +++ b/packages/webapp/src/components/hand.tsx @@ -44,7 +44,7 @@ const Hand = ({
{ setIsFocused(true) @@ -55,14 +55,14 @@ const Hand = ({ > {showLeftArrow && isFocused && (
- +
)}
-
+
@@ -82,10 +82,10 @@ const Hand = ({
{showRightArrow && isFocused && (
- +
)}
diff --git a/packages/webapp/src/components/lib/modal.tsx b/packages/webapp/src/components/lib/modal.tsx index cf118bae..a9b874b7 100644 --- a/packages/webapp/src/components/lib/modal.tsx +++ b/packages/webapp/src/components/lib/modal.tsx @@ -103,7 +103,7 @@ const ModalInner = ({ ctrl, children }: { ctrl: ModalController; children: React onClick={state.surroundCloseable ? ctrl.close : undefined} style={{ display: displayed ? "flex" : "none" }} > -
+
{state.closeable && ( diff --git a/packages/webapp/src/components/modals/createGameModal.tsx b/packages/webapp/src/components/modals/createGameModal.tsx index da174081..e77b7b86 100644 --- a/packages/webapp/src/components/modals/createGameModal.tsx +++ b/packages/webapp/src/components/modals/createGameModal.tsx @@ -42,7 +42,7 @@ export const CreateGameModal = () => { @@ -189,7 +189,7 @@ const CreateGameModalContent: React.FC = ({ loading
)} {joined && ( -
+
{!allPlayersJoined && ( @@ -151,7 +151,7 @@ const JoinGameModalContent: React.FC = ({ loading, se placeholder="Game ID" min={0} onChange={handleInputChange} - className="mr-2 w-full max-w-xs text-white placeholder-gray-500 font-mono" + className="mr-2 w-full max-w-xs font-mono text-white placeholder-gray-500" /> diff --git a/packages/webapp/src/components/navbar.tsx b/packages/webapp/src/components/navbar.tsx index 2006f88c..b5f15b94 100644 --- a/packages/webapp/src/components/navbar.tsx +++ b/packages/webapp/src/components/navbar.tsx @@ -9,8 +9,8 @@ export const Navbar = () => { - @@ -20,7 +20,7 @@ export const Navbar = () => { - diff --git a/packages/webapp/src/components/playerBoard.tsx b/packages/webapp/src/components/playerBoard.tsx index 500985e9..7c33b0f8 100644 --- a/packages/webapp/src/components/playerBoard.tsx +++ b/packages/webapp/src/components/playerBoard.tsx @@ -19,9 +19,9 @@ const PlayerBoard: React.FC = ({ playerAddress, playedCards }) const convertedCards = convertBigIntArrayToStringArray(playedCards) return (
= ({ playerAddress, playedCards }) }} >
-
-

+

+

{`🛡 ${shortenAddress(playerAddress)}`}

-

♥️ 100

+

♥️ 100

diff --git a/packages/webapp/src/pages/collection.tsx b/packages/webapp/src/pages/collection.tsx index 4cc00f70..43439324 100644 --- a/packages/webapp/src/pages/collection.tsx +++ b/packages/webapp/src/pages/collection.tsx @@ -165,9 +165,9 @@ const Collection: FablePage = ({ isHydrated }) => { {jotaiDebug()}
-
+
{/* Left Panel - Search and Filters */} -
+
{
{/* Middle Panel - Card Collection Display */} -
+
{
{/* Right Panel - Deck List */} -
+
{isEditing && currentDeck ? ( { const isWrongNetwork = !notConnected && !chainSupported return ( -
+

0xFABLE @@ -48,7 +48,7 @@ const Home: FablePage = ({ isHydrated }) => {
diff --git a/packages/webapp/src/pages/play.tsx b/packages/webapp/src/pages/play.tsx index c6688294..007f7660 100644 --- a/packages/webapp/src/pages/play.tsx +++ b/packages/webapp/src/pages/play.tsx @@ -229,7 +229,7 @@ const Play: FablePage = ({ isHydrated }) => { cards={playerHand as readonly bigint[]} setLoading={setLoading} cancellationHandler={cancellationHandler} - className={`absolute left-0 right-0 mx-auto z-[100] translate-y-1/2 transition-all duration-500 rounded-xl ease-in-out hover:translate-y-0`} + className={`absolute left-0 right-0 z-[100] mx-auto translate-y-1/2 rounded-xl transition-all duration-500 ease-in-out hover:translate-y-0`} />
@@ -239,7 +239,7 @@ const Play: FablePage = ({ isHydrated }) => { {showDrawButton && (