mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-12 06:06:21 +00:00
Compare commits
1 Commits
feature/ti
...
bugfix/chr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cf42b9a98 |
49
package.json
49
package.json
@@ -17,42 +17,39 @@
|
|||||||
"deploy": "bun run build && firebase deploy --only hosting"
|
"deploy": "bun run build && firebase deploy --only hosting"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mui/icons-material": "^6.4.5",
|
"firebase": "^10.3.0",
|
||||||
"@mui/material": "^6.4.5",
|
|
||||||
"firebase": "^10.14.1",
|
|
||||||
"ga-4-react": "^0.1.281",
|
"ga-4-react": "^0.1.281",
|
||||||
"react": "^18.3.1",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.2.0",
|
||||||
"react-screen-wake-lock": "^3.0.2",
|
"react-screen-wake-lock": "^3.0.2",
|
||||||
"react-swipeable": "^7.0.2",
|
"react-swipeable": "^7.0.1",
|
||||||
"react-timer-hook": "^3.0.8",
|
"react-twc": "^1.3.0",
|
||||||
"react-twc": "^1.4.2",
|
"semver": "^7.6.2",
|
||||||
"semver": "^7.7.1",
|
"zod": "^3.22.4"
|
||||||
"zod": "^3.24.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.11.4",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.11.5",
|
||||||
"@savvywombat/tailwindcss-grid-areas": "^4.0.0",
|
"@savvywombat/tailwindcss-grid-areas": "^4.0.0",
|
||||||
"@svgr/cli": "^8.1.0",
|
"@svgr/cli": "^8.1.0",
|
||||||
"@types/react": "^18.3.18",
|
"@types/react": "^18.3.1",
|
||||||
"@types/react-dom": "^18.3.5",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.8.0",
|
||||||
"@vitejs/plugin-react-swc": "^3.8.0",
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.19",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.45.0",
|
||||||
"eslint-plugin-react-hooks": "^4.6.2",
|
"eslint-plugin-react-hooks": "^4.6.2",
|
||||||
"eslint-plugin-react-refresh": "^0.4.19",
|
"eslint-plugin-react-refresh": "^0.4.6",
|
||||||
"firebase-tools": "^13.31.2",
|
"firebase-tools": "^13.7.5",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.4.38",
|
||||||
"prettier": "2.8.8",
|
"prettier": "2.8.8",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.3",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.4.5",
|
||||||
"vite": "^5.4.14",
|
"vite": "^5.2.10",
|
||||||
"vite-plugin-pwa": "^0.20.5"
|
"vite-plugin-pwa": "^0.20.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7599
pnpm-lock.yaml
generated
7599
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -2,4 +2,5 @@ import { twc } from 'react-twc';
|
|||||||
|
|
||||||
export const Paragraph = twc.p`text-text-primary`;
|
export const Paragraph = twc.p`text-text-primary`;
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-refresh/only-export-components
|
||||||
export const H1 = twc.h1`text-text-primary;`;
|
export const H1 = twc.h1`text-text-primary;`;
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
import { useStopwatch } from 'react-timer-hook';
|
|
||||||
import { TimerStyle, TimerWrapper } from './Timer';
|
|
||||||
import { Time } from './Time';
|
|
||||||
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
|
||||||
import PauseIcon from '@mui/icons-material/Pause';
|
|
||||||
|
|
||||||
export const NegativeStopWatch = ({
|
|
||||||
autoStart = false,
|
|
||||||
}: {
|
|
||||||
autoStart?: boolean;
|
|
||||||
}) => {
|
|
||||||
// Initialize the timer using the useTimer hook.
|
|
||||||
const { seconds, minutes, hours, isRunning, start, pause } = useStopwatch({
|
|
||||||
autoStart,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TimerWrapper>
|
|
||||||
<TimerStyle>
|
|
||||||
{'-'}
|
|
||||||
<Time time={{ hours, minutes, seconds }} />
|
|
||||||
<div>
|
|
||||||
{!isRunning && (
|
|
||||||
<button onClick={start}>
|
|
||||||
<PlayArrowIcon />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{isRunning && (
|
|
||||||
<button onClick={pause}>
|
|
||||||
<PauseIcon />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</TimerStyle>
|
|
||||||
</TimerWrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { formatTime } from '../../../Utils/formatTime';
|
|
||||||
|
|
||||||
export const Time = ({
|
|
||||||
time,
|
|
||||||
}: {
|
|
||||||
time: { hours: number; minutes: number; seconds: number };
|
|
||||||
}) => {
|
|
||||||
return <div className="tabular-nums">{formatTime({ time })}</div>;
|
|
||||||
};
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import { useState } from 'react';
|
|
||||||
import { useTimer } from 'react-timer-hook';
|
|
||||||
import { NegativeStopWatch } from './NegativeStopWatch';
|
|
||||||
import { twc } from 'react-twc';
|
|
||||||
import PauseIcon from '@mui/icons-material/Pause';
|
|
||||||
import RestartAltIcon from '@mui/icons-material/RestartAlt';
|
|
||||||
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
|
||||||
import { Time } from './Time';
|
|
||||||
|
|
||||||
export const TimerWrapper = twc.div`
|
|
||||||
absolute z-50 top-0 w-screen flex items-center flex-col
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const TimerStyle = twc.div`
|
|
||||||
flex gap-2 bg-interface-recentDifference-background py-1 px-4 rounded-full
|
|
||||||
`;
|
|
||||||
|
|
||||||
const TIMER_MINUTES = 50;
|
|
||||||
|
|
||||||
export const Timer = () => {
|
|
||||||
// Set the default expiry time to 50 minutes from now.
|
|
||||||
const defaultExpiry = new Date();
|
|
||||||
defaultExpiry.setMinutes(defaultExpiry.getMinutes() + TIMER_MINUTES);
|
|
||||||
|
|
||||||
const [hasStarted, setHasStarted] = useState(false);
|
|
||||||
|
|
||||||
// Initialize the timer using the useTimer hook.
|
|
||||||
const { seconds, minutes, hours, isRunning, start, pause, restart } =
|
|
||||||
useTimer({
|
|
||||||
expiryTimestamp: defaultExpiry,
|
|
||||||
onExpire: () => console.warn('Timer expired'),
|
|
||||||
autoStart: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Function to restart the timer for 50 minutes.
|
|
||||||
const handleRestart = () => {
|
|
||||||
const time = new Date();
|
|
||||||
time.setMinutes(time.getMinutes() + TIMER_MINUTES);
|
|
||||||
restart(time);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleStart = () => {
|
|
||||||
setHasStarted(true);
|
|
||||||
start();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handlePause = () => {
|
|
||||||
setHasStarted(false);
|
|
||||||
pause();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (hasStarted && !isRunning) {
|
|
||||||
return <NegativeStopWatch autoStart />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TimerWrapper>
|
|
||||||
<TimerStyle>
|
|
||||||
<Time
|
|
||||||
time={{
|
|
||||||
hours,
|
|
||||||
minutes,
|
|
||||||
seconds,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
{!isRunning && (
|
|
||||||
<button onClick={handleStart}>
|
|
||||||
<PlayArrowIcon />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{isRunning && (
|
|
||||||
<button onClick={handlePause}>
|
|
||||||
<PauseIcon />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<button onClick={handleRestart}>
|
|
||||||
<RestartAltIcon />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</TimerStyle>
|
|
||||||
</TimerWrapper>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -6,7 +6,6 @@ import { PreStartMode } from '../../Types/Settings';
|
|||||||
import LifeCounter from '../LifeCounter/LifeCounter';
|
import LifeCounter from '../LifeCounter/LifeCounter';
|
||||||
import { RoulettePlayerCard } from '../PreStartGame/Games/RandomKing/RoulettePlayerCard';
|
import { RoulettePlayerCard } from '../PreStartGame/Games/RandomKing/RoulettePlayerCard';
|
||||||
import { GridLayout } from '../Views/Play';
|
import { GridLayout } from '../Views/Play';
|
||||||
import { Timer } from '../Misc/Timer/Timer';
|
|
||||||
|
|
||||||
const getGridArea = (player: PlayerType) => {
|
const getGridArea = (player: PlayerType) => {
|
||||||
switch (player.index) {
|
switch (player.index) {
|
||||||
@@ -37,7 +36,6 @@ export const Players = ({ gridLayout }: { gridLayout: GridLayout }) => {
|
|||||||
return (
|
return (
|
||||||
<PlayersWrapper>
|
<PlayersWrapper>
|
||||||
<div className={`grid w-full h-full gap-1 box-border ${gridLayout} `}>
|
<div className={`grid w-full h-full gap-1 box-border ${gridLayout} `}>
|
||||||
<Timer />
|
|
||||||
{players.map((player) => {
|
{players.map((player) => {
|
||||||
const gridArea = getGridArea(player);
|
const gridArea = getGridArea(player);
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export const Play = () => {
|
|||||||
useGlobalSettings();
|
useGlobalSettings();
|
||||||
|
|
||||||
let gridLayout: GridLayout;
|
let gridLayout: GridLayout;
|
||||||
|
|
||||||
switch (players.length) {
|
switch (players.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (initialGameSettings?.orientation === Orientation.Portrait) {
|
if (initialGameSettings?.orientation === Orientation.Portrait) {
|
||||||
@@ -102,6 +101,7 @@ export const Play = () => {
|
|||||||
settings.preStartMode !== PreStartMode.None &&
|
settings.preStartMode !== PreStartMode.None &&
|
||||||
!playing &&
|
!playing &&
|
||||||
settings.showStartingPlayer && <PreStart />}
|
settings.showStartingPlayer && <PreStart />}
|
||||||
|
|
||||||
<Players gridLayout={gridLayout} />
|
<Players gridLayout={gridLayout} />
|
||||||
</MainWrapper>
|
</MainWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
export const formatTime = ({
|
|
||||||
time,
|
|
||||||
}: {
|
|
||||||
time: { hours: number; minutes: number; seconds: number };
|
|
||||||
}) => {
|
|
||||||
const h = time.hours.toString().padStart(2, '0');
|
|
||||||
const m = time.minutes.toString().padStart(2, '0');
|
|
||||||
const s = time.seconds.toString().padStart(2, '0');
|
|
||||||
|
|
||||||
if (time.hours > 0) {
|
|
||||||
return `${h}:${m}:${s}`;
|
|
||||||
} else if (time.minutes > 0) {
|
|
||||||
return `${m}:${s}`;
|
|
||||||
} else {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user