-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from sergio222-dev/develop
* added the ability to set the deck's splash art
- Loading branch information
Showing
19 changed files
with
170 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { component$, Slot } from "@builder.io/qwik"; | ||
import type { ButtonHTMLAttributes } from "@builder.io/qwik"; | ||
import { component$, Slot } from "@builder.io/qwik"; | ||
|
||
interface ButtonProps { | ||
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
} | ||
|
||
export const Button = component$<ButtonProps>(() => { | ||
export const Button = component$<ButtonProps>(({ class: className, ...props}) => { | ||
return ( | ||
<button class="bg-secondary rounded px-4 py-1"><Slot/></button> | ||
<button class={`bg-secondary rounded px-1 py-1 disabled:bg-gray-400 ${className}`} {...props}><Slot/></button> | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ButtonHTMLAttributes } from "@builder.io/qwik"; | ||
import { Slot } from "@builder.io/qwik"; | ||
import { component$ } from "@builder.io/qwik"; | ||
import { Button } from "~/components/button/Button"; | ||
|
||
interface ButtonIconProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
|
||
} | ||
|
||
export const ButtonIcon = component$<ButtonIconProps>(({ class: className, ...props }) => { | ||
return ( | ||
<Button class={`border-black border-2 rounded-full p-0 ${className}`} {...props} > | ||
<Slot/> | ||
</Button> | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './Button'; | ||
export * from './ButtonIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { component$ } from "@builder.io/qwik"; | ||
import { Link } from "@builder.io/qwik-city"; | ||
import { createClientBrowser } from "~/lib/supabase-qwik"; | ||
|
||
interface DeckCardProps { | ||
id: number; | ||
splashArt?: string; | ||
name: string; | ||
path?: string; | ||
} | ||
|
||
export const DeckCard = component$<DeckCardProps>(({ id, splashArt, name, path = '/decks/preview' }) => { | ||
const supabase = createClientBrowser(); | ||
|
||
return ( | ||
<Link | ||
href={`${path}/${id}`} | ||
class="aspect-[4/3] w-[100%] 2xl:w-[calc(20%-0.5rem)] xl:w-[calc(25%-0.5rem)] lg:w-[calc(25%-0.5rem)] md:w-[calc(33%-0.5rem)] sm:w-[calc(50%-0.5rem)]" | ||
> | ||
<div | ||
class={`aspect-[4/3] bg-[radial-gradient(transparent,#000000)] shadow hover:shadow-[0_0_4px_0] | ||
hover:shadow-primary border-2 border-secondary hover:border-primary rounded-[24px] cursor-pointer | ||
bg-no-repeat bg-[length:160%_auto] bg-[50%_30%] relative flex flex-col items-center text-white | ||
p-4 | ||
`} | ||
{...(splashArt ? { | ||
style: { | ||
backgroundImage: `radial-gradient(transparent, rgb(0, 0, 0)), url(${supabase.storage.from( | ||
'CardImages/cards').getPublicUrl(splashArt + '.webp').data.publicUrl})` | ||
} | ||
} : {})} | ||
> | ||
<div class="font-bold"> | ||
{name} | ||
</div> | ||
<div class="hidden mt-auto justify-between"> | ||
<p> | ||
{/*{d.description}*/} | ||
</p> | ||
</div> | ||
</div> | ||
</Link> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DeckCard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ export const Create = component$(() => { | |
|
||
return ( | ||
<div> | ||
|
||
<CreateForm/> | ||
<CardFilter/> | ||
<CardListDeck/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
import { $, component$ } from "@builder.io/qwik"; | ||
import { Link } from "@builder.io/qwik-city"; | ||
import type { ColumnDefinition } from "~/components/dataGrid/DataGrid"; | ||
import { DataGrid } from "~/components/dataGrid/DataGrid"; | ||
import { component$ } from "@builder.io/qwik"; | ||
import { DeckCard } from "~/components/deckCard"; | ||
import { useListPublicDeckLoader } from "~/providers/loaders/decks"; | ||
|
||
const columns: ColumnDefinition[] = [ | ||
{ | ||
id: 'name', | ||
label: 'Name', | ||
cell: $((row) => <Link href={`/decks/preview/${row.id}`}>{row.name}</Link>) | ||
}, | ||
{ | ||
id: 'description', | ||
label: 'Description' | ||
}, | ||
{ | ||
id: 'likes', | ||
label: 'Likes' | ||
} | ||
]; | ||
|
||
export const DeckList = component$(() => { | ||
const decks = useListPublicDeckLoader(); | ||
|
||
return ( | ||
<div> | ||
<DataGrid columns={columns} rows={decks.value.decks}/> | ||
<div class="flex flex-wrap gap-[0.5rem]"> | ||
{decks.value.decks.map(d => { | ||
return ( | ||
<DeckCard id={d.id} name={d.name} splashArt={d.splashArt} key={d.id}/> | ||
); | ||
})} | ||
</div> | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
import { $, component$ } from "@builder.io/qwik"; | ||
import { Link } from "@builder.io/qwik-city"; | ||
import type { ColumnDefinition } from "~/components/dataGrid/DataGrid"; | ||
import { DataGrid } from "~/components/dataGrid/DataGrid"; | ||
import { component$ } from "@builder.io/qwik"; | ||
import { DeckCard } from "~/components/deckCard"; | ||
import { useListMyDeckLoader } from "~/providers/loaders/decks"; | ||
|
||
const columns: ColumnDefinition[] = [ | ||
{ | ||
id: 'name', | ||
label: 'Name', | ||
cell: $((row) => <Link href={`/decks/create/${row.id}`}>{row.name}</Link>) | ||
}, | ||
{ | ||
id: 'description', | ||
label: 'Description' | ||
}, | ||
{ | ||
id: 'likes', | ||
label: 'Likes' | ||
} | ||
]; | ||
|
||
export const MyDecks = component$(() => { | ||
const decks = useListMyDeckLoader(); | ||
|
||
return ( | ||
<div> | ||
<DataGrid columns={columns} rows={decks.value.decks}/> | ||
<div class="flex flex-wrap gap-[0.5rem]"> | ||
{decks.value.decks.map(d => { | ||
return ( | ||
<DeckCard path="/decks/create" id={d.id} name={d.name} splashArt={d.splashArt} key={d.id}/> | ||
); | ||
})} | ||
</div> | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useComputed$ } from "@builder.io/qwik"; | ||
import type { DeckState } from "~/models/Deck"; | ||
|
||
export const useDeckQuantity = (deck: DeckState, cardId: number, isSide = false) => { | ||
|
||
const deckQuantity = useComputed$(() => { | ||
const masterDeckQuantity = Object.entries(deck.masterDeck) | ||
.map(([, c]) => c) | ||
.find(c => c.id === cardId)?.quantity ?? 0; | ||
const treasureDeckQuantity = Object.entries(deck.treasureDeck) | ||
.map(([, c]) => c) | ||
.find(c => c.id === cardId)?.quantity ?? 0; | ||
const sideDeckQuantity = Object.entries(deck.sideDeck) | ||
.map(([, c]) => c) | ||
.find(c => c.id === cardId)?.quantity ?? 0; | ||
|
||
return isSide ? sideDeckQuantity : masterDeckQuantity + treasureDeckQuantity; | ||
}); | ||
|
||
return [deckQuantity]; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.