forked from external-repos/LifeTrinket
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89e1eaff4e | ||
|
|
0f4e896342 | ||
|
|
dc1d5fe01d | ||
|
|
41e73d2c0c | ||
|
|
724dcf086c | ||
|
|
51f9c4d20e | ||
|
|
354c0dbbb2 | ||
|
|
3770d13beb | ||
|
|
13733242a2 | ||
|
|
81f3891b20 |
10
package.json
10
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "life-trinket",
|
"name": "life-trinket",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.5.51",
|
"version": "0.6.1",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18",
|
"node": ">=18",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-screen-wake-lock": "^3.0.2",
|
"react-screen-wake-lock": "^3.0.2",
|
||||||
|
"react-swipeable": "^7.0.1",
|
||||||
"react-twc": "^1.3.0",
|
"react-twc": "^1.3.0",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
@@ -43,8 +44,9 @@
|
|||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"postcss": "^8.4.32",
|
"postcss": "^8.4.32",
|
||||||
"prettier": "2.8.8",
|
"prettier": "2.8.8",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.3.3",
|
||||||
"vite": "^4.4.5"
|
"vite": "^5.0.12",
|
||||||
|
"vite-plugin-pwa": "^0.17.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,10 +66,6 @@ export const CommanderDamage = ({
|
|||||||
const [timeoutFinished, setTimeoutFinished] = useState(false);
|
const [timeoutFinished, setTimeoutFinished] = useState(false);
|
||||||
const [hasPressedDown, setHasPressedDown] = useState(false);
|
const [hasPressedDown, setHasPressedDown] = useState(false);
|
||||||
|
|
||||||
const isSide =
|
|
||||||
player.settings.rotation === Rotation.Side ||
|
|
||||||
player.settings.rotation === Rotation.SideFlipped;
|
|
||||||
|
|
||||||
const handleCommanderDamageChange = (
|
const handleCommanderDamageChange = (
|
||||||
index: number,
|
index: number,
|
||||||
increment: number,
|
increment: number,
|
||||||
@@ -132,9 +128,9 @@ export const CommanderDamage = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const opponentIndex = opponent.index;
|
const opponentIndex = opponent.index;
|
||||||
const fontSize = isSide ? '4vmax' : '7vmin';
|
const fontSize = player.isSide ? '4vmax' : '7vmin';
|
||||||
const fontWeight = 'bold';
|
const fontWeight = 'bold';
|
||||||
const strokeWidth = isSide ? '0.4vmax' : '0.7vmin';
|
const strokeWidth = player.isSide ? '0.4vmax' : '0.7vmin';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommanderDamageContainer
|
<CommanderDamageContainer
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ type ExtraCounterProps = {
|
|||||||
type: CounterType;
|
type: CounterType;
|
||||||
setCounterTotal: (updatedCounterTotal: number, type: CounterType) => void;
|
setCounterTotal: (updatedCounterTotal: number, type: CounterType) => void;
|
||||||
rotation: number;
|
rotation: number;
|
||||||
|
isSide: boolean;
|
||||||
playerIndex: number;
|
playerIndex: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,15 +57,13 @@ const ExtraCounter = ({
|
|||||||
setCounterTotal,
|
setCounterTotal,
|
||||||
type,
|
type,
|
||||||
rotation,
|
rotation,
|
||||||
|
isSide,
|
||||||
playerIndex,
|
playerIndex,
|
||||||
}: ExtraCounterProps) => {
|
}: ExtraCounterProps) => {
|
||||||
const timeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
const timeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
||||||
const [timeoutFinished, setTimeoutFinished] = useState(false);
|
const [timeoutFinished, setTimeoutFinished] = useState(false);
|
||||||
const [hasPressedDown, setHasPressedDown] = useState(false);
|
const [hasPressedDown, setHasPressedDown] = useState(false);
|
||||||
|
|
||||||
const isSide =
|
|
||||||
rotation === Rotation.Side || rotation === Rotation.SideFlipped;
|
|
||||||
|
|
||||||
const handleCountChange = (increment: number) => {
|
const handleCountChange = (increment: number) => {
|
||||||
if (!counterTotal) {
|
if (!counterTotal) {
|
||||||
setCounterTotal(increment, type);
|
setCounterTotal(increment, type);
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import { Rotation } from '../../Types/Player';
|
|||||||
import { RotationDivProps } from './CommanderDamage';
|
import { RotationDivProps } from './CommanderDamage';
|
||||||
|
|
||||||
const LoseButton = twc.div<RotationDivProps>((props) => [
|
const LoseButton = twc.div<RotationDivProps>((props) => [
|
||||||
'absolute flex-grow border-none outline-none cursor-pointer bg-interface-loseButton-background rounded-lg select-none z-[1] webkit-user-select-none',
|
'absolute flex-grow border-none outline-none cursor-pointer bg-interface-loseButton-background rounded-lg select-none z-[1] webkit-user-select-none py-2 px-4 ',
|
||||||
|
|
||||||
props.$rotation === Rotation.SideFlipped
|
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
|
||||||
? `right-auto top-[15%] left-[27%]`
|
? `left-[19%]`
|
||||||
: props.$rotation === Rotation.Side
|
: 'top-[21%]',
|
||||||
? `right-auto top-[15%] left-[27%]`
|
|
||||||
: 'right-[15%] top-1/4',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
type LoseButtonProps = {
|
type LoseButtonProps = {
|
||||||
@@ -24,6 +22,8 @@ export const LoseGameButton = ({ rotation, onClick }: LoseButtonProps) => {
|
|||||||
? rotation
|
? rotation
|
||||||
: rotation === Rotation.Side
|
: rotation === Rotation.Side
|
||||||
? rotation - 180
|
? rotation - 180
|
||||||
|
: rotation === Rotation.Flipped
|
||||||
|
? rotation - 180
|
||||||
: rotation;
|
: rotation;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -33,7 +33,7 @@ export const LoseGameButton = ({ rotation, onClick }: LoseButtonProps) => {
|
|||||||
aria-label={`Lose Game`}
|
aria-label={`Lose Game`}
|
||||||
style={{ rotate: `${calcRotation}deg` }}
|
style={{ rotate: `${calcRotation}deg` }}
|
||||||
>
|
>
|
||||||
<Skull size="5vmin" color="black" opacity={0.5} />
|
<Skull size="8vmin" color="black" opacity={0.5} />
|
||||||
</LoseButton>
|
</LoseButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
|
|||||||
(counter) => counter.type === 'commanderTax'
|
(counter) => counter.type === 'commanderTax'
|
||||||
)?.value
|
)?.value
|
||||||
}
|
}
|
||||||
|
isSide={player.isSide}
|
||||||
setCounterTotal={handleCounterChange}
|
setCounterTotal={handleCounterChange}
|
||||||
playerIndex={player.index}
|
playerIndex={player.index}
|
||||||
/>
|
/>
|
||||||
@@ -114,6 +115,7 @@ const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
|
|||||||
(counter) => counter.type === 'partnerTax'
|
(counter) => counter.type === 'partnerTax'
|
||||||
)?.value
|
)?.value
|
||||||
}
|
}
|
||||||
|
isSide={player.isSide}
|
||||||
setCounterTotal={handleCounterChange}
|
setCounterTotal={handleCounterChange}
|
||||||
playerIndex={player.index}
|
playerIndex={player.index}
|
||||||
/>
|
/>
|
||||||
@@ -127,6 +129,7 @@ const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
|
|||||||
player.extraCounters?.find((counter) => counter.type === 'poison')
|
player.extraCounters?.find((counter) => counter.type === 'poison')
|
||||||
?.value
|
?.value
|
||||||
}
|
}
|
||||||
|
isSide={player.isSide}
|
||||||
setCounterTotal={handleCounterChange}
|
setCounterTotal={handleCounterChange}
|
||||||
playerIndex={player.index}
|
playerIndex={player.index}
|
||||||
/>
|
/>
|
||||||
@@ -140,6 +143,7 @@ const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
|
|||||||
player.extraCounters?.find((counter) => counter.type === 'energy')
|
player.extraCounters?.find((counter) => counter.type === 'energy')
|
||||||
?.value
|
?.value
|
||||||
}
|
}
|
||||||
|
isSide={player.isSide}
|
||||||
setCounterTotal={handleCounterChange}
|
setCounterTotal={handleCounterChange}
|
||||||
playerIndex={player.index}
|
playerIndex={player.index}
|
||||||
/>
|
/>
|
||||||
@@ -154,6 +158,7 @@ const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
|
|||||||
(counter) => counter.type === 'experience'
|
(counter) => counter.type === 'experience'
|
||||||
)?.value
|
)?.value
|
||||||
}
|
}
|
||||||
|
isSide={player.isSide}
|
||||||
setCounterTotal={handleCounterChange}
|
setCounterTotal={handleCounterChange}
|
||||||
playerIndex={player.index}
|
playerIndex={player.index}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import LifeCounterButton from '../Buttons/LifeCounterButton';
|
import LifeCounterButton from '../Buttons/LifeCounterButton';
|
||||||
import { OutlinedText } from '../Misc/OutlinedText';
|
import { OutlinedText } from '../Misc/OutlinedText';
|
||||||
|
|
||||||
const LifeCountainer = twc.div<RotationDivProps>((props) => [
|
const LifeContainer = twc.div<RotationDivProps>((props) => [
|
||||||
'flex flex-grow relative w-full h-full justify-between items-center',
|
'flex flex-grow relative w-full h-full justify-between items-center',
|
||||||
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
|
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
|
||||||
? 'flex-col-reverse'
|
? 'flex-col-reverse'
|
||||||
@@ -49,7 +49,6 @@ type HealthProps = {
|
|||||||
|
|
||||||
const Health = ({
|
const Health = ({
|
||||||
player,
|
player,
|
||||||
rotation,
|
|
||||||
handleLifeChange,
|
handleLifeChange,
|
||||||
differenceKey,
|
differenceKey,
|
||||||
recentDifference,
|
recentDifference,
|
||||||
@@ -99,12 +98,13 @@ const Health = ({
|
|||||||
}, [textContainerRef]);
|
}, [textContainerRef]);
|
||||||
|
|
||||||
const calculateFontSize = (container: HTMLDivElement) => {
|
const calculateFontSize = (container: HTMLDivElement) => {
|
||||||
const isSide =
|
const widthRatio = player.isSide
|
||||||
rotation === Rotation.SideFlipped || rotation === Rotation.Side;
|
? container.clientHeight
|
||||||
|
: container.clientWidth;
|
||||||
|
|
||||||
const widthRatio = isSide ? container.clientHeight : container.clientWidth;
|
const heightRatio = player.isSide
|
||||||
|
? container.clientWidth
|
||||||
const heightRatio = isSide ? container.clientWidth : container.clientHeight;
|
: container.clientHeight;
|
||||||
|
|
||||||
const minRatio = Math.min(widthRatio, heightRatio);
|
const minRatio = Math.min(widthRatio, heightRatio);
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ const Health = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LifeCountainer $rotation={player.settings.rotation}>
|
<LifeContainer $rotation={player.settings.rotation}>
|
||||||
<LifeCounterButton
|
<LifeCounterButton
|
||||||
lifeTotal={player.lifeTotal}
|
lifeTotal={player.lifeTotal}
|
||||||
setLifeTotal={handleLifeChange}
|
setLifeTotal={handleLifeChange}
|
||||||
@@ -154,7 +154,7 @@ const Health = ({
|
|||||||
operation="add"
|
operation="add"
|
||||||
increment={1}
|
increment={1}
|
||||||
/>
|
/>
|
||||||
</LifeCountainer>
|
</LifeContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useSwipeable } from 'react-swipeable';
|
||||||
import { twc } from 'react-twc';
|
import { twc } from 'react-twc';
|
||||||
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
|
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
|
||||||
import { usePlayers } from '../../Hooks/usePlayers';
|
import { usePlayers } from '../../Hooks/usePlayers';
|
||||||
import { Player, Rotation } from '../../Types/Player';
|
import { Player, Rotation } from '../../Types/Player';
|
||||||
import { RotationDivProps } from '../Buttons/CommanderDamage';
|
import { RotationDivProps } from '../Buttons/CommanderDamage';
|
||||||
import { LoseGameButton } from '../Buttons/LoseButton';
|
import { LoseGameButton } from '../Buttons/LoseButton';
|
||||||
import SettingsButton from '../Buttons/SettingsButton';
|
|
||||||
import CommanderDamageBar from '../Counters/CommanderDamageBar';
|
import CommanderDamageBar from '../Counters/CommanderDamageBar';
|
||||||
import ExtraCountersBar from '../Counters/ExtraCountersBar';
|
import ExtraCountersBar from '../Counters/ExtraCountersBar';
|
||||||
import PlayerMenu from '../Player/PlayerMenu';
|
import PlayerMenu from '../Player/PlayerMenu';
|
||||||
@@ -24,7 +24,7 @@ const LifeCounterWrapper = twc.div<RotationDivProps>((props) => [
|
|||||||
const StartingPlayerNoticeWrapper = twc.div`z-[1] flex absolute w-full h-full justify-center items-center pointer-events-none select-none webkit-user-select-none bg-primary-main`;
|
const StartingPlayerNoticeWrapper = twc.div`z-[1] flex absolute w-full h-full justify-center items-center pointer-events-none select-none webkit-user-select-none bg-primary-main`;
|
||||||
|
|
||||||
const PlayerLostWrapper = twc.div<RotationDivProps>((props) => [
|
const PlayerLostWrapper = twc.div<RotationDivProps>((props) => [
|
||||||
'z-[1] flex absolute w-full h-full justify-center items-center pointer-events-none select-none webkit-user-select-none bg-lifeCounter-lostWrapper',
|
'z-[1] flex absolute w-full h-full justify-center items-center pointer-events-none select-none webkit-user-select-none bg-lifeCounter-lostWrapper opacity-75',
|
||||||
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
|
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
|
||||||
? `rotate-[${props.$rotation - 90}deg]`
|
? `rotate-[${props.$rotation - 90}deg]`
|
||||||
: '',
|
: '',
|
||||||
@@ -71,14 +71,51 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
|
|||||||
const [showPlayerMenu, setShowPlayerMenu] = useState(false);
|
const [showPlayerMenu, setShowPlayerMenu] = useState(false);
|
||||||
const [recentDifference, setRecentDifference] = useState(0);
|
const [recentDifference, setRecentDifference] = useState(0);
|
||||||
const [differenceKey, setDifferenceKey] = useState(Date.now());
|
const [differenceKey, setDifferenceKey] = useState(Date.now());
|
||||||
|
const [isLandscape, setIsLandscape] = useState(false);
|
||||||
|
|
||||||
|
const calcRot = player.isSide
|
||||||
|
? player.settings.rotation - 180
|
||||||
|
: player.settings.rotation;
|
||||||
|
|
||||||
|
const rotationAngle = isLandscape ? calcRot : calcRot + 90;
|
||||||
|
|
||||||
|
const handlers = useSwipeable({
|
||||||
|
trackMouse: true,
|
||||||
|
onSwipedDown: () => {
|
||||||
|
console.log(`User DOWN Swiped on player ${player.index}`);
|
||||||
|
setShowPlayerMenu(true);
|
||||||
|
},
|
||||||
|
onSwipedUp: () => {
|
||||||
|
console.log(`User UP Swiped on player ${player.index}`);
|
||||||
|
setShowPlayerMenu(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
swipeDuration: 500,
|
||||||
|
onSwiping: (eventData) => console.log(eventData),
|
||||||
|
rotationAngle,
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
setRecentDifference(0);
|
setRecentDifference(0);
|
||||||
}, 3_000);
|
}, 3_000);
|
||||||
|
|
||||||
return () => clearTimeout(timer);
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
}, [recentDifference]);
|
if (document.body.clientWidth > document.body.clientHeight)
|
||||||
|
setIsLandscape(true);
|
||||||
|
else setIsLandscape(false);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
resizeObserver.observe(document.body);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
// Cleanup: disconnect the ResizeObserver when the component unmounts.
|
||||||
|
resizeObserver.disconnect();
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [recentDifference, document.body.clientHeight, document.body.clientWidth]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (player.showStartingPlayer) {
|
if (player.showStartingPlayer) {
|
||||||
@@ -124,6 +161,7 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
|
|||||||
<LifeCounterWrapper
|
<LifeCounterWrapper
|
||||||
$rotation={player.settings.rotation}
|
$rotation={player.settings.rotation}
|
||||||
style={{ rotate: `${calcRotation}deg` }}
|
style={{ rotate: `${calcRotation}deg` }}
|
||||||
|
{...handlers}
|
||||||
>
|
>
|
||||||
{settings.showStartingPlayer &&
|
{settings.showStartingPlayer &&
|
||||||
player.isStartingPlayer &&
|
player.isStartingPlayer &&
|
||||||
@@ -150,12 +188,6 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
|
|||||||
key={player.index}
|
key={player.index}
|
||||||
handleLifeChange={handleLifeChange}
|
handleLifeChange={handleLifeChange}
|
||||||
/>
|
/>
|
||||||
<SettingsButton
|
|
||||||
onClick={() => {
|
|
||||||
setShowPlayerMenu(!showPlayerMenu);
|
|
||||||
}}
|
|
||||||
rotation={player.settings.rotation}
|
|
||||||
/>
|
|
||||||
{playerCanLose(player) && (
|
{playerCanLose(player) && (
|
||||||
<LoseGameButton
|
<LoseGameButton
|
||||||
rotation={player.settings.rotation}
|
rotation={player.settings.rotation}
|
||||||
@@ -170,9 +202,12 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
|
|||||||
handleLifeChange={handleLifeChange}
|
handleLifeChange={handleLifeChange}
|
||||||
/>
|
/>
|
||||||
<ExtraCountersBar player={player} />
|
<ExtraCountersBar player={player} />
|
||||||
{showPlayerMenu && (
|
|
||||||
<PlayerMenu player={player} setShowPlayerMenu={setShowPlayerMenu} />
|
<PlayerMenu
|
||||||
)}
|
isShown={showPlayerMenu}
|
||||||
|
player={player}
|
||||||
|
setShowPlayerMenu={setShowPlayerMenu}
|
||||||
|
/>
|
||||||
</LifeCounterWrapper>
|
</LifeCounterWrapper>
|
||||||
</LifeCounterContentWrapper>
|
</LifeCounterContentWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { twc } from 'react-twc';
|
|||||||
import { Separator } from './Separator';
|
import { Separator } from './Separator';
|
||||||
import { Paragraph } from './TextComponents';
|
import { Paragraph } from './TextComponents';
|
||||||
|
|
||||||
export const ModalWrapper = twc.div`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[80vw] h-[85vh] bg-background-default p-4 overflow-scroll rounded-2xl border-none text-text-primary`;
|
export const ModalWrapper = twc.div`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-[85vh] bg-background-default p-4 overflow-scroll rounded-2xl border-none text-text-primary w-[95vw] max-w-[548px]`;
|
||||||
|
|
||||||
type InfoModalProps = {
|
type InfoModalProps = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@@ -12,63 +12,77 @@ type InfoModalProps = {
|
|||||||
|
|
||||||
export const InfoModal = ({ isOpen, closeModal }: InfoModalProps) => {
|
export const InfoModal = ({ isOpen, closeModal }: InfoModalProps) => {
|
||||||
return (
|
return (
|
||||||
<Modal open={isOpen} onClose={closeModal}>
|
<Modal
|
||||||
<ModalWrapper>
|
open={isOpen}
|
||||||
<div>
|
onClose={closeModal}
|
||||||
<h2 className="text-2xl text-center mb-4">📋 Usage Guide</h2>
|
style={{ display: 'flex', justifyContent: 'center' }}
|
||||||
<Separator height="1px" />
|
>
|
||||||
<Paragraph className="my-4">
|
<>
|
||||||
There are some controls that you might not know about, so here's a
|
<div className="flex relative w-full max-w-[548px]">
|
||||||
short list of them.
|
<button
|
||||||
</Paragraph>
|
onClick={closeModal}
|
||||||
<h3 className="text-lg font-bold mb-2">Life counter</h3>
|
className="flex absolute top-10 right-0 z-10 w-10 h-10 text-common-white bg-primary-main items-center justify-center rounded-full border-solid border-primary-dark border-2"
|
||||||
<ul className="list-disc ml-6 mb-4">
|
|
||||||
<li>
|
|
||||||
<strong>Tap</strong> on a player's + or - button to add or
|
|
||||||
subtract <strong>1 life</strong>.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<strong>Long press</strong> on a player's + or - button to add or
|
|
||||||
subtract <strong>10 life</strong>.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3 className="text-lg font-bold mb-2">
|
|
||||||
Commander damage and other counters
|
|
||||||
</h3>
|
|
||||||
<ul className="list-disc ml-6 mb-4">
|
|
||||||
<li>
|
|
||||||
<strong>Tap</strong> on the counter to add{' '}
|
|
||||||
<strong>1 counter</strong>.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<strong>Long press</strong> on the counter to subtract{' '}
|
|
||||||
<strong>1 counter</strong>.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3 className="text-lg font-bold mb-2">Other</h3>
|
|
||||||
<Paragraph className="mb-4">
|
|
||||||
When a player is <strong>at or below 0 life</strong>, has taken{' '}
|
|
||||||
<strong>21 or more Commander Damage</strong> or has{' '}
|
|
||||||
<strong>10 or more poison counters</strong>, a button with a skull
|
|
||||||
will appear on that player's card. Tapping it will dim the player's
|
|
||||||
card.
|
|
||||||
</Paragraph>
|
|
||||||
</div>
|
|
||||||
<div className="text-center mt-4">
|
|
||||||
Visit my
|
|
||||||
<a
|
|
||||||
href="https://github.com/Vikeo/LifeTrinket"
|
|
||||||
target="_blank"
|
|
||||||
className="text-text-secondary underline"
|
|
||||||
>
|
>
|
||||||
{' '}
|
X
|
||||||
GitHub{' '}
|
</button>
|
||||||
</a>
|
|
||||||
for more info about this web app.
|
|
||||||
</div>
|
</div>
|
||||||
</ModalWrapper>
|
<ModalWrapper>
|
||||||
|
<div>
|
||||||
|
<h2 className="text-2xl text-center mb-4">📋 Usage Guide</h2>
|
||||||
|
<Separator height="1px" />
|
||||||
|
<Paragraph className="my-4">
|
||||||
|
There are some controls that you might not know about, so here's a
|
||||||
|
short list of them.
|
||||||
|
</Paragraph>
|
||||||
|
<h3 className="text-lg font-bold mb-2">Life counter</h3>
|
||||||
|
<ul className="list-disc ml-6 mb-4">
|
||||||
|
<li>
|
||||||
|
<strong>Tap</strong> on a player's + or - button to add or
|
||||||
|
subtract <strong>1 life</strong>.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Long press</strong> on a player's + or - button to add
|
||||||
|
or subtract <strong>10 life</strong>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3 className="text-lg font-bold mb-2">
|
||||||
|
Commander damage and other counters
|
||||||
|
</h3>
|
||||||
|
<ul className="list-disc ml-6 mb-4">
|
||||||
|
<li>
|
||||||
|
<strong>Tap</strong> on the counter to add{' '}
|
||||||
|
<strong>1 counter</strong>.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Long press</strong> on the counter to subtract{' '}
|
||||||
|
<strong>1 counter</strong>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3 className="text-lg font-bold mb-2">Other</h3>
|
||||||
|
<Paragraph className="mb-4">
|
||||||
|
When a player is <strong>at or below 0 life</strong>, has taken{' '}
|
||||||
|
<strong>21 or more Commander Damage</strong> or has{' '}
|
||||||
|
<strong>10 or more poison counters</strong>, a button with a skull
|
||||||
|
will appear on that player's card. Tapping it will dim the
|
||||||
|
player's card.
|
||||||
|
</Paragraph>
|
||||||
|
</div>
|
||||||
|
<div className="text-center mt-4">
|
||||||
|
Visit my
|
||||||
|
<a
|
||||||
|
href="https://github.com/Vikeo/LifeTrinket"
|
||||||
|
target="_blank"
|
||||||
|
className="text-text-secondary underline"
|
||||||
|
>
|
||||||
|
{' '}
|
||||||
|
GitHub{' '}
|
||||||
|
</a>
|
||||||
|
for more info about this web app.
|
||||||
|
</div>
|
||||||
|
</ModalWrapper>
|
||||||
|
</>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,116 +67,129 @@ export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={isOpen} onClose={closeModal}>
|
<Modal open={isOpen} onClose={closeModal}>
|
||||||
<ModalWrapper>
|
<>
|
||||||
<Container>
|
<div className="flex relative w-full max-w-[548px]">
|
||||||
<h2 className="text-center text-2xl mb-2">⚙️ Settings ⚙️</h2>
|
<button
|
||||||
<Separator height="1px" />
|
onClick={closeModal}
|
||||||
<SettingContainer>
|
className="flex absolute top-10 right-0 z-10 w-10 h-10 text-common-white bg-primary-main items-center justify-center rounded-full border-solid border-primary-dark border-2"
|
||||||
<ToggleContainer>
|
>
|
||||||
<FormLabel>Show Start Player</FormLabel>
|
X
|
||||||
<Switch
|
</button>
|
||||||
checked={settings.showStartingPlayer}
|
</div>
|
||||||
onChange={() => {
|
<ModalWrapper>
|
||||||
setSettings({
|
<Container>
|
||||||
...settings,
|
<h2 className="text-center text-2xl mb-2">⚙️ Settings ⚙️</h2>
|
||||||
showStartingPlayer: !settings.showStartingPlayer,
|
<Separator height="1px" />
|
||||||
});
|
<SettingContainer>
|
||||||
}}
|
<ToggleContainer>
|
||||||
/>
|
<FormLabel>Show Start Player</FormLabel>
|
||||||
</ToggleContainer>
|
<Switch
|
||||||
<Description>
|
checked={settings.showStartingPlayer}
|
||||||
On start or reset of game, will pick a random player who will
|
onChange={() => {
|
||||||
start first if this is enabled.
|
setSettings({
|
||||||
</Description>
|
...settings,
|
||||||
</SettingContainer>
|
showStartingPlayer: !settings.showStartingPlayer,
|
||||||
<SettingContainer>
|
});
|
||||||
<ToggleContainer>
|
}}
|
||||||
<FormLabel>Keep Awake</FormLabel>
|
/>
|
||||||
<Switch
|
</ToggleContainer>
|
||||||
checked={settings.keepAwake}
|
<Description>
|
||||||
onChange={() => {
|
On start or reset of game, will pick a random player who will
|
||||||
setSettings({ ...settings, keepAwake: !settings.keepAwake });
|
start first if this is enabled.
|
||||||
}}
|
</Description>
|
||||||
/>
|
</SettingContainer>
|
||||||
</ToggleContainer>
|
<SettingContainer>
|
||||||
<Description>
|
<ToggleContainer>
|
||||||
Will prevent device from going to sleep while this app is open if
|
<FormLabel>Keep Awake</FormLabel>
|
||||||
this is enabled.
|
<Switch
|
||||||
</Description>
|
checked={settings.keepAwake}
|
||||||
</SettingContainer>
|
onChange={() => {
|
||||||
<SettingContainer>
|
setSettings({
|
||||||
<ToggleContainer>
|
...settings,
|
||||||
<FormLabel>Go fullscreen on start (Android only)</FormLabel>
|
keepAwake: !settings.keepAwake,
|
||||||
<Switch
|
});
|
||||||
checked={settings.goFullscreenOnStart}
|
}}
|
||||||
onChange={() => {
|
/>
|
||||||
setSettings({
|
</ToggleContainer>
|
||||||
...settings,
|
<Description>
|
||||||
goFullscreenOnStart: !settings.goFullscreenOnStart,
|
Will prevent device from going to sleep while this app is open
|
||||||
});
|
if this is enabled.
|
||||||
}}
|
</Description>
|
||||||
/>
|
</SettingContainer>
|
||||||
</ToggleContainer>
|
<SettingContainer>
|
||||||
<Description>
|
<ToggleContainer>
|
||||||
Will enter fullscreen mode when starting a game if this is
|
<FormLabel>Go fullscreen on start (Android only)</FormLabel>
|
||||||
enabled.
|
<Switch
|
||||||
</Description>
|
checked={settings.goFullscreenOnStart}
|
||||||
</SettingContainer>
|
onChange={() => {
|
||||||
{!isPWA && (
|
setSettings({
|
||||||
<>
|
...settings,
|
||||||
<Separator height="1px" />
|
goFullscreenOnStart: !settings.goFullscreenOnStart,
|
||||||
<SettingContainer>
|
});
|
||||||
<ToggleContainer>
|
}}
|
||||||
<Paragraph>
|
/>
|
||||||
<b>Tip:</b> You can{' '}
|
</ToggleContainer>
|
||||||
<b>add this webapp to your home page on iOS</b> or{' '}
|
<Description>
|
||||||
<b>install it on Android</b> to have it act just like a
|
Will enter fullscreen mode when starting a game if this is
|
||||||
normal app!
|
enabled.
|
||||||
</Paragraph>
|
</Description>
|
||||||
</ToggleContainer>
|
</SettingContainer>
|
||||||
<Description className="mt-1">
|
{!isPWA && (
|
||||||
If you do, this app will work offline and the toolbar will be
|
<>
|
||||||
automatically hidden.
|
<Separator height="1px" />
|
||||||
</Description>
|
<SettingContainer>
|
||||||
</SettingContainer>
|
<ToggleContainer>
|
||||||
</>
|
<Paragraph>
|
||||||
)}
|
<b>Tip:</b> You can{' '}
|
||||||
<Separator height="1px" />
|
<b>add this webapp to your home page on iOS</b> or{' '}
|
||||||
<SettingContainer>
|
<b>install it on Android</b> to have it act just like a
|
||||||
<Paragraph>
|
normal app!
|
||||||
{/* @ts-expect-error is defined in vite.config.ts*/}
|
</Paragraph>
|
||||||
Current version: {APP_VERSION}{' '}
|
</ToggleContainer>
|
||||||
{isLatestVersion && (
|
<Description className="mt-1">
|
||||||
<span className="text-sm text-text-secondary">(latest)</span>
|
If you do, this app will work offline and the toolbar will
|
||||||
)}
|
be automatically hidden.
|
||||||
</Paragraph>
|
</Description>
|
||||||
{!isLatestVersion && newVersion && (
|
</SettingContainer>
|
||||||
<Paragraph className="text-text-secondary text-lg text-center">
|
</>
|
||||||
New version ({newVersion}) is available!{' '}
|
|
||||||
</Paragraph>
|
|
||||||
)}
|
)}
|
||||||
</SettingContainer>
|
<Separator height="1px" />
|
||||||
{!isLatestVersion && newVersion && (
|
<SettingContainer>
|
||||||
|
<Paragraph>
|
||||||
|
{/* @ts-expect-error is defined in vite.config.ts*/}
|
||||||
|
Current version: {APP_VERSION}{' '}
|
||||||
|
{isLatestVersion && (
|
||||||
|
<span className="text-sm text-text-secondary">(latest)</span>
|
||||||
|
)}
|
||||||
|
</Paragraph>
|
||||||
|
{!isLatestVersion && newVersion && (
|
||||||
|
<Paragraph className="text-text-secondary text-lg text-center">
|
||||||
|
New version ({newVersion}) is available!{' '}
|
||||||
|
</Paragraph>
|
||||||
|
)}
|
||||||
|
</SettingContainer>
|
||||||
|
{!isLatestVersion && newVersion && (
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
style={{ marginTop: '0.25rem', marginBottom: '0.25rem' }}
|
||||||
|
onClick={() => window?.location?.reload()}
|
||||||
|
>
|
||||||
|
<span>Update</span>
|
||||||
|
<span className="text-xs"> (reload app)</span>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Separator height="1px" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
style={{ marginTop: '0.25rem', marginBottom: '0.25rem' }}
|
onClick={closeModal}
|
||||||
onClick={() => window?.location?.reload()}
|
style={{ marginTop: '0.25rem' }}
|
||||||
>
|
>
|
||||||
<span>Update</span>
|
Save and Close
|
||||||
<span className="text-xs"> (reload app)</span>
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
</Container>
|
||||||
<Separator height="1px" />
|
</ModalWrapper>
|
||||||
|
</>
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
onClick={closeModal}
|
|
||||||
style={{ marginTop: '0.25rem' }}
|
|
||||||
>
|
|
||||||
Save and Close
|
|
||||||
</Button>
|
|
||||||
</Container>
|
|
||||||
</ModalWrapper>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
|
|||||||
import { usePlayers } from '../../Hooks/usePlayers';
|
import { usePlayers } from '../../Hooks/usePlayers';
|
||||||
import { useSafeRotate } from '../../Hooks/useSafeRotate';
|
import { useSafeRotate } from '../../Hooks/useSafeRotate';
|
||||||
import {
|
import {
|
||||||
Cross,
|
|
||||||
Energy,
|
Energy,
|
||||||
Exit,
|
Exit,
|
||||||
Experience,
|
Experience,
|
||||||
@@ -17,10 +16,7 @@ import {
|
|||||||
ResetGame,
|
ResetGame,
|
||||||
} from '../../Icons/generated';
|
} from '../../Icons/generated';
|
||||||
import { Player, Rotation } from '../../Types/Player';
|
import { Player, Rotation } from '../../Types/Player';
|
||||||
import {
|
import { RotationDivProps } from '../Buttons/CommanderDamage';
|
||||||
RotationButtonProps,
|
|
||||||
RotationDivProps,
|
|
||||||
} from '../Buttons/CommanderDamage';
|
|
||||||
|
|
||||||
const CheckboxContainer = twc.div``;
|
const CheckboxContainer = twc.div``;
|
||||||
|
|
||||||
@@ -35,6 +31,7 @@ const PlayerMenuWrapper = twc.div`
|
|||||||
justify-center
|
justify-center
|
||||||
z-[2]
|
z-[2]
|
||||||
webkit-user-select-none
|
webkit-user-select-none
|
||||||
|
transition-all
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BetterRowContainer = twc.div`
|
const BetterRowContainer = twc.div`
|
||||||
@@ -85,21 +82,17 @@ const SettingsContainer = twc.div<RotationDivProps>((props) => [
|
|||||||
: 'flex-row',
|
: 'flex-row',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const CloseButton = twc.button<RotationButtonProps>((props) => [
|
|
||||||
'absolute border-none outline-none cursor-pointer bg-transparent z-[99]',
|
|
||||||
props.$rotation === Rotation.Side
|
|
||||||
? `top-[5%] right-auto left-[5%]`
|
|
||||||
: props.$rotation === Rotation.SideFlipped
|
|
||||||
? 'top-auto left-auto bottom-[5%] right-[5%]'
|
|
||||||
: 'top-[15%] right-[5%]',
|
|
||||||
]);
|
|
||||||
|
|
||||||
type PlayerMenuProps = {
|
type PlayerMenuProps = {
|
||||||
player: Player;
|
player: Player;
|
||||||
setShowPlayerMenu: (showPlayerMenu: boolean) => void;
|
setShowPlayerMenu: (showPlayerMenu: boolean) => void;
|
||||||
|
isShown: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
|
const PlayerMenu = ({
|
||||||
|
player,
|
||||||
|
setShowPlayerMenu,
|
||||||
|
isShown,
|
||||||
|
}: PlayerMenuProps) => {
|
||||||
const settingsContainerRef = useRef<HTMLDivElement | null>(null);
|
const settingsContainerRef = useRef<HTMLDivElement | null>(null);
|
||||||
const dialogRef = useRef<HTMLDialogElement | null>(null);
|
const dialogRef = useRef<HTMLDialogElement | null>(null);
|
||||||
|
|
||||||
@@ -108,9 +101,6 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
|
|||||||
containerRef: settingsContainerRef,
|
containerRef: settingsContainerRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleOnClick = () => {
|
|
||||||
setShowPlayerMenu(false);
|
|
||||||
};
|
|
||||||
const { fullscreen, wakeLock, goToStart } = useGlobalSettings();
|
const { fullscreen, wakeLock, goToStart } = useGlobalSettings();
|
||||||
const { updatePlayer, resetCurrentGame } = usePlayers();
|
const { updatePlayer, resetCurrentGame } = usePlayers();
|
||||||
|
|
||||||
@@ -142,7 +132,6 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
|
|||||||
const buttonFontSize = isSide ? '1.5vmax' : '3vmin';
|
const buttonFontSize = isSide ? '1.5vmax' : '3vmin';
|
||||||
const iconSize = isSide ? '6vmin' : '3vmax';
|
const iconSize = isSide ? '6vmin' : '3vmax';
|
||||||
const extraCountersSize = isSide ? '8vmin' : '4vmax';
|
const extraCountersSize = isSide ? '8vmin' : '4vmax';
|
||||||
const closeButtonSize = isSide ? '6vmin' : '3vmax';
|
|
||||||
|
|
||||||
const calcRotation =
|
const calcRotation =
|
||||||
player.settings.rotation === Rotation.Side
|
player.settings.rotation === Rotation.Side
|
||||||
@@ -156,33 +145,10 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
|
|||||||
//TODO: Fix hacky solution to rotation for SideFlipped
|
//TODO: Fix hacky solution to rotation for SideFlipped
|
||||||
style={{
|
style={{
|
||||||
rotate:
|
rotate:
|
||||||
player.settings.rotation === Rotation.SideFlipped ? '180deg' : '',
|
player.settings.rotation === Rotation.SideFlipped ? `180deg` : '',
|
||||||
|
translate: isShown ? '' : player.isSide ? `-100%` : `0 -100%`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CloseButton
|
|
||||||
$rotation={player.settings.rotation}
|
|
||||||
style={{
|
|
||||||
rotate:
|
|
||||||
player.settings.rotation === Rotation.Side ||
|
|
||||||
player.settings.rotation === Rotation.SideFlipped
|
|
||||||
? `${player.settings.rotation - 180}deg`
|
|
||||||
: '',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
onClick={handleOnClick}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
padding: 0,
|
|
||||||
height: closeButtonSize,
|
|
||||||
width: closeButtonSize,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Cross size={closeButtonSize} />
|
|
||||||
</Button>
|
|
||||||
</CloseButton>
|
|
||||||
|
|
||||||
<SettingsContainer
|
<SettingsContainer
|
||||||
$rotation={player.settings.rotation}
|
$rotation={player.settings.rotation}
|
||||||
style={{
|
style={{
|
||||||
@@ -373,7 +339,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
|
|||||||
</BetterRowContainer>
|
</BetterRowContainer>
|
||||||
<dialog
|
<dialog
|
||||||
ref={dialogRef}
|
ref={dialogRef}
|
||||||
className="z-[9999] min-h-2/4 bg-background-default text-text-primary rounded-2xl border-none absolute top-[10%]"
|
className="z-[9999] min-h-2/4 bg-background-default text-text-primary rounded-2xl border-none absolute bottom-[20%]"
|
||||||
>
|
>
|
||||||
<div className="h-full flex flex-col p-4 gap-2">
|
<div className="h-full flex flex-col p-4 gap-2">
|
||||||
<h1 className="text-center">Reset Game?</h1>
|
<h1 className="text-center">Reset Game?</h1>
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ const Start = () => {
|
|||||||
Life Trinket
|
Life Trinket
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div className="overflow-hidden items-center flex flex-col max-w-[548px] mb-8 px-4">
|
<div className="overflow-hidden items-center flex flex-col max-w-[548px] w-full mb-8 px-4">
|
||||||
<FormControl focused={false} style={{ width: '100%' }}>
|
<FormControl focused={false} style={{ width: '100%' }}>
|
||||||
<FormLabel>Number of Players</FormLabel>
|
<FormLabel>Number of Players</FormLabel>
|
||||||
<SliderWrapper>
|
<SliderWrapper>
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ export const createInitialPlayers = ({
|
|||||||
extraCounters: [],
|
extraCounters: [],
|
||||||
commanderDamage,
|
commanderDamage,
|
||||||
hasLost: false,
|
hasLost: false,
|
||||||
|
isSide: rotation === Rotation.Side || rotation === Rotation.SideFlipped,
|
||||||
};
|
};
|
||||||
|
|
||||||
players.push(player);
|
players.push(player);
|
||||||
|
|||||||
53
src/Hooks/useOrientation.ts
Normal file
53
src/Hooks/useOrientation.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
export interface OrientationState {
|
||||||
|
angle: number;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultState: OrientationState = {
|
||||||
|
angle: 0,
|
||||||
|
type: 'landscape-primary',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function useOrientation(
|
||||||
|
initialState: OrientationState = defaultState
|
||||||
|
) {
|
||||||
|
const [state, setState] = useState(initialState);
|
||||||
|
const [isLandscape, setIsLandscape] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const screen = window.screen;
|
||||||
|
let mounted = true;
|
||||||
|
|
||||||
|
const onChange = () => {
|
||||||
|
if (mounted) {
|
||||||
|
const { orientation } = screen;
|
||||||
|
console.log(orientation);
|
||||||
|
|
||||||
|
if (orientation) {
|
||||||
|
const { angle, type } = orientation;
|
||||||
|
setState({ angle, type });
|
||||||
|
if (type.includes('landscape')) {
|
||||||
|
setIsLandscape(true);
|
||||||
|
} else if (type.includes('portrait')) {
|
||||||
|
setIsLandscape(false);
|
||||||
|
}
|
||||||
|
} else if (window.orientation !== undefined) {
|
||||||
|
setState({
|
||||||
|
angle:
|
||||||
|
typeof window.orientation === 'number' ? window.orientation : 0,
|
||||||
|
type: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
onChange();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
mounted = false;
|
||||||
|
};
|
||||||
|
}, [isLandscape]);
|
||||||
|
|
||||||
|
return { state, isLandscape };
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ export type Player = {
|
|||||||
isStartingPlayer: boolean;
|
isStartingPlayer: boolean;
|
||||||
showStartingPlayer: boolean;
|
showStartingPlayer: boolean;
|
||||||
hasLost: boolean;
|
hasLost: boolean;
|
||||||
|
isSide: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PlayerSettings = {
|
export type PlayerSettings = {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import type { Config } from 'tailwindcss';
|
|||||||
export default {
|
export default {
|
||||||
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
||||||
theme: {
|
theme: {
|
||||||
|
screens: {
|
||||||
|
modalSm: '548px',
|
||||||
|
},
|
||||||
extend: {
|
extend: {
|
||||||
gridTemplateAreas: {
|
gridTemplateAreas: {
|
||||||
onePlayerLandscape: ['player0 player0'],
|
onePlayerLandscape: ['player0 player0'],
|
||||||
@@ -53,10 +56,10 @@ export default {
|
|||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
primary: '#F5F5F5',
|
primary: '#F5F5F5',
|
||||||
secondary: '#b3b39b',
|
secondary: '#76A6A5',
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
disabled: '#5E714C',
|
disabled: '#234A47',
|
||||||
},
|
},
|
||||||
common: {
|
common: {
|
||||||
white: '#F9FFE3',
|
white: '#F9FFE3',
|
||||||
@@ -64,7 +67,7 @@ export default {
|
|||||||
},
|
},
|
||||||
lifeCounter: {
|
lifeCounter: {
|
||||||
text: 'rgba(0, 0, 0, 0.4)',
|
text: 'rgba(0, 0, 0, 0.4)',
|
||||||
lostWrapper: '#00000070',
|
lostWrapper: '#000000',
|
||||||
},
|
},
|
||||||
interface: {
|
interface: {
|
||||||
loseButton: {
|
loseButton: {
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
import { defineConfig } from 'vite';
|
|
||||||
import react from '@vitejs/plugin-react-swc';
|
import react from '@vitejs/plugin-react-swc';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
VitePWA({
|
||||||
|
registerType: 'autoUpdate',
|
||||||
|
workbox: {
|
||||||
|
clientsClaim: true,
|
||||||
|
skipWaiting: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
build: {
|
build: {
|
||||||
minify: 'esbuild',
|
minify: 'esbuild',
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user