From a01cca9d0e1a2d2ddb4762f61b55edc759ff95fd Mon Sep 17 00:00:00 2001 From: Mido Date: Tue, 15 Oct 2024 23:00:55 +0900 Subject: [PATCH] Release (v3) (#6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ぎがへるつ <67816580+GIGAHERTZ00@users.noreply.github.com> Co-authored-by: KtaK721 <138202999+KtaK721@users.noreply.github.com> Co-authored-by: GIGAHERTZ00 Co-authored-by: KtaK --- apps/frontend/package.json | 1 + .../src/app/components/board/Board.tsx | 5 +- .../src/app/components/board/Cell.tsx | 2 +- .../app/components/replay/InputFileCard.tsx | 6 +- .../app/components/replay/TimelineCard.tsx | 22 ++++++- apps/frontend/src/app/routes/mock.tsx | 23 +++++++ apps/frontend/src/app/routes/replay.tsx | 60 +++++++++++++++--- apps/frontend/vite.config.ts | 3 + apps/mock-server/src/gen.ts | 1 + apps/mock-server/src/index.ts | 22 +++++++ bun.lockb | Bin 495828 -> 496956 bytes packages/schemas/src/replay-info.ts | 2 +- 12 files changed, 128 insertions(+), 19 deletions(-) diff --git a/apps/frontend/package.json b/apps/frontend/package.json index ac51991..0c2c5ca 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -56,6 +56,7 @@ "typescript-remix-routes-plugin": "^1.0.1", "vite": "^5.4.8", "vite-env-only": "^3.0.3", + "vite-plugin-env-compatible": "^2.0.1", "vite-tsconfig-paths": "^4.3.2", "wrangler": "^3.79.0" } diff --git a/apps/frontend/src/app/components/board/Board.tsx b/apps/frontend/src/app/components/board/Board.tsx index 7ce59bb..c29b836 100644 --- a/apps/frontend/src/app/components/board/Board.tsx +++ b/apps/frontend/src/app/components/board/Board.tsx @@ -54,9 +54,8 @@ export const Board = ({ board, width, height, zoomLevel, marks, scrollGroup }: P {columnVirtualizer.getVirtualItems().map((virtualColumn) => { const cell = board[virtualRow.index][virtualColumn.index] as "0" | "1" | "2" | "3"; - const borderColor = shouldMark(marks, virtualColumn.index, virtualRow.index) - ? "var(--orange-8)" - : "var(--mauve-2)"; + const borderColor = + marks && shouldMark(marks, virtualColumn.index, virtualRow.index) ? "var(--orange-8)" : "var(--mauve-2)"; return ( ["0", "1" type Props = { cell: "0" | "1" | "2" | "3"; - size: string; + size?: string; borderColor?: string; style?: CSSProperties; }; diff --git a/apps/frontend/src/app/components/replay/InputFileCard.tsx b/apps/frontend/src/app/components/replay/InputFileCard.tsx index 483acd3..5fdbc48 100644 --- a/apps/frontend/src/app/components/replay/InputFileCard.tsx +++ b/apps/frontend/src/app/components/replay/InputFileCard.tsx @@ -54,7 +54,11 @@ export const InputFileCard = ({ onSetReplayInfo }: Props) => { onChange={(files) => (files ? setFile(files[0]) : setFile(null))} /> - {error && {error}} + {error && ( + + {error} + + )} ); diff --git a/apps/frontend/src/app/components/replay/TimelineCard.tsx b/apps/frontend/src/app/components/replay/TimelineCard.tsx index aaaaebc..3450c1a 100644 --- a/apps/frontend/src/app/components/replay/TimelineCard.tsx +++ b/apps/frontend/src/app/components/replay/TimelineCard.tsx @@ -7,7 +7,6 @@ import { Checkbox, HStack, Heading, - Input, InputGroup, InputLeftElement, InputRightElement, @@ -18,7 +17,7 @@ import { VStack, useBoolean, } from "@yamada-ui/react"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max); @@ -28,6 +27,7 @@ type Props = Readonly<{ onChangeTurn: (turn: number) => void; showDebugOverlay: boolean; onChangeDebugOverlay: (showDebugOverlay: boolean) => void; + onChangeInterval: (interval: number) => void; }>; export const TimelineCard = ({ @@ -36,14 +36,24 @@ export const TimelineCard = ({ onChangeTurn, showDebugOverlay, onChangeDebugOverlay, + onChangeInterval, }: Props) => { const [isPlaying, { off: pause, toggle: togglePlaying }] = useBoolean(false); const [rawInterval, setRawInterval] = useState(""); const interval = rawInterval === "" ? null : Number(rawInterval); + const oldInterval = useRef(interval); + + useEffect(() => { + if (interval !== oldInterval.current) { + oldInterval.current = interval; + + onChangeInterval(interval ?? 0); + } + }, [interval, onChangeInterval]); const turns = actualTurns - 1; // turn starts from 0 - if (currentTurn === turns - 1) pause(); + if (currentTurn === turns && isPlaying) pause(); useEffect(() => { if (isPlaying && interval !== null) { @@ -92,8 +102,14 @@ export const TimelineCard = ({ + + onChangeDebugOverlay(!showDebugOverlay)}> Debug overlay diff --git a/apps/frontend/src/app/routes/mock.tsx b/apps/frontend/src/app/routes/mock.tsx index 161280a..07b8584 100644 --- a/apps/frontend/src/app/routes/mock.tsx +++ b/apps/frontend/src/app/routes/mock.tsx @@ -7,6 +7,8 @@ import { Grid, HStack, Heading, + InputGroup, + InputRightElement, NumberInput, Select, Switch, @@ -59,6 +61,8 @@ export default function Page() { const height = randomHeight || Number.isNaN(rawHeight) ? 0 : Number(rawHeight); const [genKindStart, setGenKindStart] = useState("all-random"); const [genKindGoal, setGenKindGoal] = useState("all-random"); + const [rawWaitDuration, setRawWaitDuration] = useState("5"); + const waitDuration = Number.isNaN(rawWaitDuration) ? 0 : Number(rawWaitDuration); const notice = useNotice(); return ( @@ -79,6 +83,7 @@ export default function Page() { height, genKindStart, genKindGoal, + waitDuration, }), }); @@ -169,6 +174,24 @@ export default function Page() { /> + + + + + + +

s

+
+
+
+