Switch to deno

This commit is contained in:
Dylan Pizzo
2024-12-29 23:00:38 -05:00
parent 5ec05e3db7
commit b81144153b
15 changed files with 232 additions and 1116 deletions

6
src/client/App.tsx Normal file
View File

@ -0,0 +1,6 @@
import { sampleCard } from "../sampleData.ts";
import { Card } from "./Card.tsx";
export const App = () => {
return <div><Card card={sampleCard}/></div>;
};

26
src/client/Card.tsx Normal file
View File

@ -0,0 +1,26 @@
import { drawCard } from "../draw.ts";
import { DominionCard } from "../types.ts";
const sizeMap = {
card: {
width: 1403,
height: 2151,
},
landscape: {
width: 2151,
height: 1403,
}
}
export const Card = (props: {card: DominionCard}) => {
const {card} = props;
const {width, height} = sizeMap[card.orientation];
return <canvas style={{width: "2.5in"}} width={width} height={height} ref={(canvasElement) => {
if (canvasElement) {
const context = canvasElement.getContext("2d");
if (context) {
drawCard(context, card);
}
}
}}></canvas>
}

14
src/client/index.tsx Normal file
View File

@ -0,0 +1,14 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom";
import { App } from "./App.tsx";
const rootElement = document.getElementById("root");
if (!rootElement) {
throw Error("No root element to attach react to.");
}
createRoot(rootElement).render(
<StrictMode>
<App />
</StrictMode>,
);