cards render well
This commit is contained in:
1
Makefile
1
Makefile
@@ -5,6 +5,7 @@ build:
|
|||||||
--cache-from=type=local,src=/var/cache/docker-build \
|
--cache-from=type=local,src=/var/cache/docker-build \
|
||||||
--cache-to=type=local,dest=/var/cache/docker-build \
|
--cache-to=type=local,dest=/var/cache/docker-build \
|
||||||
--platform linux/arm64 \
|
--platform linux/arm64 \
|
||||||
|
--progress=plain \
|
||||||
--tag games .
|
--tag games .
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "games",
|
"name": "games",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vinxi dev",
|
"dev": "vinxi dev",
|
||||||
"build": "vinxi build",
|
"build": "vinxi build",
|
||||||
|
|||||||
@@ -50,3 +50,7 @@ body::before {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|||||||
12
src/app.tsx
12
src/app.tsx
@@ -5,8 +5,16 @@ import { Suspense } from "solid-js";
|
|||||||
import pkg from "~/../package.json";
|
import pkg from "~/../package.json";
|
||||||
|
|
||||||
const Version = () => (
|
const Version = () => (
|
||||||
<div class="full free">
|
<div class="full free clear">
|
||||||
<span style={{ margin: "5px", "font-size": "0.8rem" }} class="fixed-br">
|
<span
|
||||||
|
style={{
|
||||||
|
margin: "5px",
|
||||||
|
"font-size": "0.8rem",
|
||||||
|
"font-family": "monospace",
|
||||||
|
"pointer-events": "all",
|
||||||
|
}}
|
||||||
|
class="fixed-br"
|
||||||
|
>
|
||||||
v{pkg.version}
|
v{pkg.version}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,25 @@
|
|||||||
import { Component, createResource, Suspense } from "solid-js";
|
import { Component, createResource, Suspense } from "solid-js";
|
||||||
|
import { Card } from "../types/cards";
|
||||||
|
|
||||||
export default (() => {
|
const cardToSvgFilename = (card: Card) => {
|
||||||
|
if (card.kind == "joker") {
|
||||||
|
return `JOKER-${card.color == "black" ? "2" : "3"}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value =
|
||||||
|
{ ace: 1, jack: 11, queen: 12, king: 13 }[card.rank] ??
|
||||||
|
(card.rank as number);
|
||||||
|
return `${card.suit.toUpperCase()}-${value}${
|
||||||
|
value >= 11 ? "-" + (card.rank as string).toUpperCase() : ""
|
||||||
|
}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ((props) => {
|
||||||
const [svgPath] = createResource(
|
const [svgPath] = createResource(
|
||||||
() => import(`~/../assets/views/cards/CLUB-1.svg`)
|
() =>
|
||||||
|
import(
|
||||||
|
`~/../assets/views/cards/${cardToSvgFilename(props.card)}.svg`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -10,4 +27,4 @@ export default (() => {
|
|||||||
<img src={svgPath()?.default} />
|
<img src={svgPath()?.default} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
}) satisfies Component;
|
}) satisfies Component<{ card: Card }>;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default () => {
|
|||||||
style={{ "row-gap": "20px", "font-size": "32px" }}
|
style={{ "row-gap": "20px", "font-size": "32px" }}
|
||||||
>
|
>
|
||||||
games
|
games
|
||||||
<Card />
|
<Card card={{ kind: "joker", color: "red" }} />
|
||||||
coming soon
|
coming soon
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
export type Suit = "hearts" | "diamonds" | "spades" | "clubs";
|
export type Suit = "heart" | "diamond" | "spade" | "club";
|
||||||
|
|
||||||
export type Card = {
|
type Rank = number | "jack" | "queen" | "king" | "ace";
|
||||||
suit: Suit;
|
export type Card =
|
||||||
value: number;
|
| {
|
||||||
};
|
kind: "normal";
|
||||||
|
suit: Suit;
|
||||||
|
rank: Rank;
|
||||||
|
}
|
||||||
|
| { kind: "joker"; color: "red" | "black" };
|
||||||
|
|
||||||
export type Pile = Card[];
|
export type Pile = Card[];
|
||||||
export type Stack = Card[];
|
export type Stack = Card[];
|
||||||
|
|||||||
Reference in New Issue
Block a user