finish up tailwind

This commit is contained in:
Viktor Rådberg
2024-01-13 14:50:36 +01:00
parent 3cd982c643
commit 4f231ba6f4
19 changed files with 274 additions and 581 deletions

View File

@@ -1,9 +1,9 @@
import { useRef, useState } from 'react';
import { TwcComponentProps, twc } from 'react-twc';
import { decrementTimeoutMs } from '../../Data/constants';
import { usePlayers } from '../../Hooks/usePlayers';
import { Player, Rotation } from '../../Types/Player';
import { OutlinedText } from '../Misc/OutlinedText';
import { TwcComponentProps, twc } from 'react-twc';
export type RotationDivProps = TwcComponentProps<'div'> & {
$rotation?: number;

View File

@@ -1,8 +1,8 @@
import { ReactNode, useRef, useState } from 'react';
import { twc } from 'react-twc';
import { decrementTimeoutMs } from '../../Data/constants';
import { CounterType, Rotation } from '../../Types/Player';
import { OutlinedText } from '../Misc/OutlinedText';
import { twc } from 'react-twc';
import { RotationDivProps } from './CommanderDamage';
const ExtraCounterContainer = twc.div`
@@ -13,7 +13,7 @@ const ExtraCounterContainer = twc.div`
flex-grow
`;
const StyledExtraCounterButton = twc.button`
const ExtraCounterButton = twc.button`
flex
justify-center
items-center
@@ -103,7 +103,7 @@ const ExtraCounter = ({
return (
<ExtraCounterContainer>
<StyledExtraCounterButton
<ExtraCounterButton
onPointerDown={handleDownInput}
onPointerUp={handleUpInput}
onPointerLeave={handleLeaveInput}
@@ -124,7 +124,7 @@ const ExtraCounter = ({
</OutlinedText>
</TextContainer>
</IconContainer>
</StyledExtraCounterButton>
</ExtraCounterButton>
</ExtraCounterContainer>
);
};

View File

@@ -1,7 +1,6 @@
import { useRef, useState } from 'react';
import { lifeLongPressMultiplier } from '../../Data/constants';
import { TwcComponentProps, twc } from 'react-twc';
import { lifeLongPressMultiplier } from '../../Data/constants';
import { Rotation } from '../../Types/Player';
type RotationButtonProps = TwcComponentProps<'div'> & {
@@ -9,7 +8,7 @@ type RotationButtonProps = TwcComponentProps<'div'> & {
$rotation?: number;
};
const StyledLifeCounterButton = twc.button`
const LifeCounterButtonTwc = twc.button`
h-full
w-full
flex
@@ -92,7 +91,7 @@ const LifeCounterButton = ({
: '12vmin';
return (
<StyledLifeCounterButton
<LifeCounterButtonTwc
onPointerDown={handleDownInput}
onPointerUp={handleUpInput}
onPointerLeave={handleLeaveInput}
@@ -108,7 +107,7 @@ const LifeCounterButton = ({
>
{operation === 'add' ? '\u002B' : '\u2212'}
</TextContainer>
</StyledLifeCounterButton>
</LifeCounterButtonTwc>
);
};

View File

@@ -7,9 +7,9 @@ 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',
props.$rotation === Rotation.SideFlipped
? `right-auto top-[15%] left-[27%] rotate-[${props.$rotation}deg]`
? `right-auto top-[15%] left-[27%]`
: props.$rotation === Rotation.Side
? `right-auto top-[15%] left-[27%] rotate-[${props.$rotation - 180}deg]`
? `right-auto top-[15%] left-[27%]`
: 'right-[15%] top-1/4',
]);
@@ -19,8 +19,20 @@ type LoseButtonProps = {
};
export const LoseGameButton = ({ rotation, onClick }: LoseButtonProps) => {
const calcRotation =
rotation === Rotation.SideFlipped
? rotation
: rotation === Rotation.Side
? rotation - 180
: rotation;
return (
<LoseButton $rotation={rotation} onClick={onClick} aria-label={`Lose Game`}>
<LoseButton
$rotation={rotation}
onClick={onClick}
aria-label={`Lose Game`}
style={{ rotate: `${calcRotation}deg` }}
>
<Skull size="5vmin" color="black" opacity={0.5} />
</LoseButton>
);

View File

@@ -3,7 +3,7 @@ import { Cog } from '../../Icons/generated';
import { Rotation } from '../../Types/Player';
import { RotationButtonProps } from './CommanderDamage';
const StyledSettingsButton = twc.button<RotationButtonProps>((props) => [
const SettingsButtonTwc = twc.button<RotationButtonProps>((props) => [
'absolute flex-grow border-none outline-none cursor-pointer bg-transparent z-[1] select-none webkit-user-select-none',
props.$rotation === Rotation.Side || props.$rotation === Rotation.SideFlipped
? `right-auto top-[1vmax] left-[27%]`
@@ -17,13 +17,13 @@ type SettingsButtonProps = {
const SettingsButton = ({ onClick, rotation }: SettingsButtonProps) => {
return (
<StyledSettingsButton
<SettingsButtonTwc
onClick={onClick}
$rotation={rotation}
aria-label={`Settings`}
>
<Cog size="5vmin" color="black" opacity="0.3" />
</StyledSettingsButton>
</SettingsButtonTwc>
);
};

View File

@@ -1,137 +1,36 @@
import { useEffect, useState } from 'react';
import styled, { css, keyframes } from 'styled-components';
import { theme } from '../../Data/theme';
import { twc } from 'react-twc';
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
import { usePlayers } from '../../Hooks/usePlayers';
import { Player, Rotation } from '../../Types/Player';
import { RotationDivProps } from '../Buttons/CommanderDamage';
import { LoseGameButton } from '../Buttons/LoseButton';
import SettingsButton from '../Buttons/SettingsButton';
import CommanderDamageBar from '../Counters/CommanderDamageBar';
import ExtraCountersBar from '../Counters/ExtraCountersBar';
import PlayerMenu from '../Player/PlayerMenu';
import Health from './Health';
import { usePlayers } from '../../Hooks/usePlayers';
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
const LifeCounterContentWrapper = styled.div<{
$backgroundColor: string;
}>`
position: relative;
display: flex;
flex-grow: 1;
flex-direction: column;
align-items: center;
height: 100%;
width: 100%;
background-color: ${(props) => props.$backgroundColor || 'antiquewhite'};
@media (orientation: landscape) {
max-width: 100vmax;
max-height: 100vmin;
}
const LifeCounterContentWrapper = twc.div`
relative flex flex-grow flex-col items-center w-full h-full overflow-hidden`;
overflow: hidden;
`;
const LifeCounterWrapper = twc.div<RotationDivProps>((props) => [
'relative flex items-center w-full h-full z-[1]',
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
? `flex-row`
: `flex-col`,
]);
const LifeCounterWrapper = styled.div<{
$rotation: Rotation;
}>`
position: relative;
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
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`;
z-index: 1;
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',
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
? `rotate-[${props.$rotation - 90}deg]`
: '',
]);
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
flex-direction: row;
rotate: ${props.$rotation - 90}deg;
`;
}
return css`
flex-direction: column;
rotate: ${props.$rotation}deg;
`;
}}
`;
const PlayerNoticeWrapper = styled.div<{
$rotation: Rotation;
$backgroundColor: string;
}>`
z-index: 1;
display: flex;
position: absolute;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background: ${(props) => props.$backgroundColor};
pointer-events: none;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
user-select: none;
-moz-user-select: -moz-none;
-webkit-user-select: none;
-ms-user-select: none;
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
rotate: ${props.$rotation - 90}deg;
`;
}
}}
`;
const DynamicText = styled.div<{ $rotation: Rotation }>`
font-size: 8vmin;
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
rotate: ${props.$rotation - 180}deg;
`;
}
}}
`;
const fadeOut = keyframes`
0% {
opacity: 1;
}
33% {
opacity: 0.6;
}
100% {
opacity: 0;
}
`;
export const RecentDifference = styled.span`
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
text-shadow: none;
background-color: rgba(255, 255, 255, 0.6);
font-variant-numeric: tabular-nums;
border-radius: 50%;
padding: 5px 10px;
font-size: 8vmin;
color: #333333;
animation: ${fadeOut} 3s 1s ease-out forwards;
`;
const DynamicText = twc.div`text-[8vmin]`;
const hasCommanderDamageReached21 = (player: Player) => {
const commanderDamageTotals = player.commanderDamage.map(
@@ -208,27 +107,38 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
updatePlayer(updatedPlayer);
};
const calcRotation =
player.settings.rotation === Rotation.SideFlipped ||
player.settings.rotation === Rotation.Side
? player.settings.rotation - 90
: player.settings.rotation;
const calcTextRotation =
player.settings.rotation === Rotation.SideFlipped ||
player.settings.rotation === Rotation.Side
? player.settings.rotation - 180
: player.settings.rotation;
return (
<LifeCounterContentWrapper $backgroundColor={player.color}>
<LifeCounterWrapper $rotation={player.settings.rotation}>
<LifeCounterContentWrapper style={{ background: player.color }}>
<LifeCounterWrapper
$rotation={player.settings.rotation}
style={{ rotate: `${calcRotation}deg` }}
>
{settings.showStartingPlayer &&
player.isStartingPlayer &&
player.showStartingPlayer && (
<PlayerNoticeWrapper
$rotation={player.settings.rotation}
$backgroundColor={theme.palette.primary.main}
<StartingPlayerNoticeWrapper
style={{ rotate: `${calcRotation}deg` }}
>
<DynamicText $rotation={player.settings.rotation}>
<DynamicText style={{ rotate: `${calcTextRotation}deg` }}>
You start!
</DynamicText>
</PlayerNoticeWrapper>
</StartingPlayerNoticeWrapper>
)}
{player.hasLost && (
<PlayerNoticeWrapper
$rotation={player.settings.rotation}
$backgroundColor={'#00000070'}
/>
<PlayerLostWrapper $rotation={player.settings.rotation} />
)}
<CommanderDamageBar
opponents={opponents}
@@ -256,11 +166,10 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
handleLifeChange={handleLifeChange}
/>
<ExtraCountersBar player={player} />
{showPlayerMenu && (
<PlayerMenu player={player} setShowPlayerMenu={setShowPlayerMenu} />
)}
</LifeCounterWrapper>
{showPlayerMenu && (
<PlayerMenu player={player} setShowPlayerMenu={setShowPlayerMenu} />
)}
</LifeCounterContentWrapper>
);
};

View File

@@ -1,21 +1,8 @@
import { Modal } from '@mui/material';
import { theme } from '../../Data/theme';
import styled from 'styled-components';
import { twc } from 'react-twc';
export const ModalWrapper = styled.div`
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80vw;
height: 85vh;
background-color: ${theme.palette.background.default};
padding: 1rem;
overflow: scroll;
border-radius: 1rem;
color: ${theme.palette.text.primary};
border: none;
`;
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`;
type InfoModalProps = {
isOpen: boolean;

View File

@@ -1,58 +1,30 @@
import styled, { css } from 'styled-components';
import { theme } from '../../Data/theme';
import { Rotation } from '../../Types/Player';
const Container = styled.div`
display: flex;
position: relative;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
`;
import { twc } from 'react-twc';
//TODO Create provider for this
import tailwindConfig from './../../../tailwind.config';
import resolveConfig from 'tailwindcss/resolveConfig';
const CenteredText = styled.div<{
strokeWidth?: string;
strokeColor?: string;
fillColor?: string;
fontSize?: string;
fontWeight?: string;
$rotation?: Rotation;
}>`
position: absolute;
font-weight: ${(props) => props.fontWeight || ''};
font-variant-numeric: tabular-nums;
user-select: none;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
-moz-user-select: -moz-none;
-webkit-user-select: none;
-ms-user-select: none;
const fullConfig = resolveConfig(tailwindConfig);
color: ${(props) => props.fillColor || theme.palette.common.black};
font-size: ${(props) => props.fontSize || '6vmin'};
-webkit-text-stroke: ${(props) => props.strokeWidth || '1vmin'}${(props) => props.strokeColor || theme.palette.common.white};
-webkit-text-fill-color: ${(props) =>
props.fillColor || theme.palette.common.black};
const Container = twc.div`
flex
relative
w-full
h-full
items-center
justify-center
`;
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
rotate: 270deg;
`;
}
}}
`;
const CenteredText = twc.div`absolute select-none text-common-black text-[6vmin] stroke-common-white
webkit-user-select-none tabular-nums`;
const CenteredTextOutline = styled.span`
position: absolute;
left: 0;
-webkit-text-stroke: 0;
pointer-events: none;
`;
const CenteredTextOutline = twc.span`
absolute
left-0
stroke-none
pointer-events-none
`;
type OutlinedTextProps = {
children?: React.ReactNode;
@@ -73,18 +45,33 @@ export const OutlinedText: React.FC<OutlinedTextProps> = ({
fillColor,
rotation,
}) => {
const calcRotation =
rotation === Rotation.Side
? rotation - 180
: rotation === Rotation.SideFlipped
? rotation
: 0;
return (
<Container>
<CenteredText
fontSize={fontSize}
fontWeight={fontWeight}
strokeWidth={strokeWidth}
strokeColor={strokeColor}
fillColor={fillColor}
$rotation={rotation}
style={{
fontSize,
fontWeight,
strokeWidth: strokeWidth || '1vmin',
color: fillColor || fullConfig.theme.colors.common.black,
WebkitTextStroke: `${strokeWidth || '1vmin'} ${
strokeColor || fullConfig.theme.colors.common.white
}`,
WebkitTextFillColor:
fillColor || fullConfig.theme.colors.common.black,
rotate: `${calcRotation}deg`,
}}
>
{children}
<CenteredTextOutline aria-hidden>{children}</CenteredTextOutline>
<CenteredTextOutline aria-hidden style={{ WebkitTextStroke: 0 }}>
{children}
</CenteredTextOutline>
</CenteredText>
</Container>
);

View File

@@ -1,13 +1,3 @@
import styled from 'styled-components';
import { Spacer } from './Spacer';
const SeparatorContainer = styled.div<{ width?: string; height?: string }>`
width: ${(props) => props.width};
height: ${(props) => props.height};
background-color: #00000025;
border-radius: 50px;
`;
export const Separator = ({
width = '100%',
height = '100%',
@@ -16,10 +6,9 @@ export const Separator = ({
height?: string;
}) => {
return (
<>
<Spacer height="0.5rem" />
<SeparatorContainer width={width} height={height} />
<Spacer height="0.5rem" />
</>
<div
className={`bg-common-black bg-opacity-30 rounded-full mt-2 mb-2`}
style={{ width, height }}
/>
);
};

View File

@@ -1,38 +1,17 @@
import { Button, FormLabel, Modal, Switch } from '@mui/material';
import { ModalWrapper } from './InfoModal';
import styled from 'styled-components';
import { twc } from 'react-twc';
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
import { theme } from '../../Data/theme';
import { ModalWrapper } from './InfoModal';
import { Separator } from './Separator';
import { Paragraph } from './TextComponents';
const SettingContainer = styled.div`
width: 100%;
display: flex;
flex-direction: column;
`;
const SettingContainer = twc.div`w-full flex flex-col`;
const ToggleContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
`;
const ToggleContainer = twc.div`flex flex-row justify-between items-center`;
const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
`;
const Container = twc.div`flex flex-col items-center w-full`;
const Description = styled.p`
margin-top: -0.25rem;
margin-right: 3.5rem;
font-size: 0.8rem;
text-align: left;
color: ${theme.palette.text.secondary};
`;
const Description = twc.p`mr-16 text-xs text-left text-text-secondary`;
type SettingsModalProps = {
isOpen: boolean;
@@ -100,7 +79,7 @@ export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
</SettingContainer>
{!isPWA && (
<>
<Separator height="2px" />
<Separator height="1px" />
<SettingContainer>
<ToggleContainer>
<Paragraph>
@@ -110,19 +89,19 @@ export const SettingsModal = ({ isOpen, closeModal }: SettingsModalProps) => {
normal app!
</Paragraph>
</ToggleContainer>
<Description>
<Description className="mt-1">
If you do, this app will work offline and the toolbar will be
automatically hidden.
</Description>
</SettingContainer>
</>
)}
<Separator height="2px" />
<Separator height="1px" />
<SettingContainer>
{/* @ts-expect-error is defined in vite.config.ts*/}
<Paragraph>Version: {APP_VERSION}</Paragraph>
</SettingContainer>
<Separator height="2px" />
<Separator height="1px" />
<Button variant="contained" onClick={closeModal}>
Save and Close

View File

@@ -1,6 +0,0 @@
import styled from 'styled-components';
export const Spacer = styled.div<{ width?: string; height?: string }>`
width: ${(props) => props.width};
height: ${(props) => props.height};
`;

View File

@@ -1,43 +1,30 @@
import { Button, Drawer } from '@mui/material';
import { useState } from 'react';
import styled from 'styled-components';
import { theme } from '../../Data/theme';
import { BuyMeCoffee, KoFi } from '../../Icons/generated/Support';
import { Paragraph } from './TextComponents';
import LittleGuy from '../../Icons/generated/LittleGuy';
import { useAnalytics } from '../../Hooks/useAnalytics';
import { twc } from 'react-twc';
// import { ButtonBase } from '@mui/material';
const SupportContainer = twc.div`flex flex-col items-center justify-center gap-4 mt-4 mb-4`;
const SupportContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
margin: 16px 0;
`;
const SupportButton = styled.button`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border: none;
background-color: transparent;
cursor: pointer;
padding: 0;
margin: 0;
background-color: ${theme.palette.primary.main};
border-radius: 4px;
margin: 0 1rem;
padding: 0 1rem;
transition: background-color 0.2s ease-in-out;
box-shadow: 1px 2px 4px 0px rgba(0, 0, 0, 0.3);
&:hover {
background-color: ${theme.palette.primary.dark};
}
`;
const SupportButton = twc.button`
flex
flex-row
items-center
justify-left
border-none
cursor-pointer
bg-primary-main
rounded-md
w-10/12
mx-4
px-4
py-2
transition-colors duration-200 ease-in-out
shadow-[1px_2px_4px_0px_rgba(0,0,0,0.3)]
hover:bg-primary-dark
`;
export const SupportMe = () => {
const analytics = useAnalytics();
@@ -87,13 +74,7 @@ export const SupportMe = () => {
<LittleGuy
height={'4rem'}
width={'2.5rem'}
style={{
pointerEvents: 'none',
position: 'absolute',
top: '2.5rem',
right: '0',
color: theme.palette.text.primary,
}}
className="pointer-events-none absolute top-10 right-0 text-text-primary"
/>
<Drawer
@@ -104,22 +85,12 @@ export const SupportMe = () => {
>
<SupportContainer>
<SupportButton onClick={handleOpenBuyMeCoffee}>
<BuyMeCoffee
height={'1.5rem'}
width={'1.5rem'}
style={{ marginRight: '0.5rem' }}
/>
<Paragraph style={{ fontSize: '0.7rem' }}>Buy him a tea</Paragraph>
<BuyMeCoffee height="1.5rem" width="1.5rem" className="mr-2" />
<Paragraph className="text-xs">Buy him a tea</Paragraph>
</SupportButton>
<SupportButton onClick={handleOpenKoFi}>
<KoFi
height={'1.5rem'}
width={'1.5rem'}
style={{ marginRight: '0.5rem' }}
/>
<Paragraph style={{ fontSize: '0.7rem' }}>
Buy him a ko-fi
</Paragraph>
<KoFi height="1.5rem" width="1.5rem" className="mr-2" />
<Paragraph className="text-xs">Buy him a ko-fi</Paragraph>
</SupportButton>
</SupportContainer>
</Drawer>

View File

@@ -1,11 +1,6 @@
import styled from 'styled-components';
import { theme } from '../../Data/theme';
import { twc } from 'react-twc';
export const Paragraph = styled.p`
color: ${theme.palette.text.primary};
`;
export const Paragraph = twc.p`text-text-primary;`;
// eslint-disable-next-line react-refresh/only-export-components
export const H1 = styled.h1`
color: ${theme.palette.text.primary};
`;
export const H1 = twc.h1`text-text-primary;`;

View File

@@ -1,168 +1,96 @@
import { Button, Checkbox } from '@mui/material';
import styled, { css } from 'styled-components';
import { Player, Rotation } from '../../Types/Player';
import { useRef } from 'react';
import { twc } from 'react-twc';
import { theme } from '../../Data/theme';
import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
import { usePlayers } from '../../Hooks/usePlayers';
import { useSafeRotate } from '../../Hooks/useSafeRotate';
import {
PartnerTax,
Poison,
Cross,
Energy,
Experience,
Exit,
Experience,
FullscreenOff,
FullscreenOn,
Cross,
PartnerTax,
Poison,
ResetGame,
} from '../../Icons/generated';
import { useRef } from 'react';
import { Spacer } from '../Misc/Spacer';
import { useSafeRotate } from '../../Hooks/useSafeRotate';
import { Player, Rotation } from '../../Types/Player';
import {
RotationButtonProps,
RotationDivProps,
} from '../Buttons/CommanderDamage';
const SettingsContainer = styled.div<{
$rotation: Rotation;
}>`
display: flex;
flex-direction: row;
flex-wrap: wrap;
height: 100%;
width: 100%;
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
flex-direction: column-reverse;
height: 100%;
width: 100%;
`;
}
}}
${(props) => {
if (props.$rotation === Rotation.Side) {
return css`
rotate: ${props.$rotation - 180}deg;
`;
} else if (props.$rotation === Rotation.SideFlipped) {
return css`
rotate: ${props.$rotation - 180}deg;
`;
}
}}
const BetterRowContainer = twc.div`
flex
flex-col
flex-grow
w-full
h-full
justify-end
items-stretch
`;
const BetterRowContainer = styled.div`
display: flex;
flex-direction: column;
flex-grow: 1;
width: 100%;
height: 100%;
justify-content: end;
align-items: stretch;
const TogglesSection = twc.div`
flex
relative
flex-row
gap-2
justify-evenly
`;
const TogglesSection = styled.div`
display: flex;
position: relative;
flex-direction: row;
gap: 0.5rem;
justify-content: space-evenly;
const ButtonsSections = twc.div`
flex
max-w-full
gap-4
justify-between
p-[3%]
items-center
`;
const ButtonsSections = styled.div`
display: flex;
max-width: 100%;
gap: 1rem;
justify-content: space-between;
padding: 3% 3%;
align-items: center;
const ColorPicker = twc.input`
absolute
top-[5%]
left-[5%]
h-[8vmax]
w-[8vmax]
border-none
outline-none
cursor-pointer
bg-transparent
user-select-nonetext-common-white
`;
const ColorPicker = styled.input`
position: absolute;
top: 5%;
left: 5%;
height: 8vmax;
width: 8vmax;
border: none;
outline: none;
cursor: pointer;
background-color: transparent;
user-select: none;
color: #ffffff;
const SettingsContainer = twc.div<RotationDivProps>((props) => [
'flex flex-wrap h-full w-full',
props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side
? 'flex-col'
: 'flex-row',
]);
const CheckboxContainer = twc.div``;
const PlayerMenuWrapper = twc.div`
flex
flex-col
absolute
w-full
h-full
bg-background-settings
items-center
justify-center
z-[2]
`;
const CheckboxContainer = styled.div<{ $rotation: Rotation }>`
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return css`
/* rotate: ${props.$rotation - 180}deg; */
`;
}
}}
`;
const PlayerMenuWrapper = styled.div<{
$rotation: Rotation;
}>`
display: flex;
flex-direction: column;
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(20, 20, 20, 0.9);
align-items: center;
justify-content: center;
z-index: 2;
${(props) => {
if (
props.$rotation === Rotation.SideFlipped ||
props.$rotation === Rotation.Side
) {
return;
}
return css`
rotate: ${props.$rotation}deg;
`;
}};
`;
const CloseButton = styled.div<{
$rotation: Rotation;
}>`
position: absolute;
top: 15%;
right: 5%;
z-index: 9999;
border: none;
outline: none;
cursor: pointer;
background-color: transparent;
${(props) => {
if (props.$rotation === Rotation.Side) {
return css`
rotate: ${props.$rotation - 180}deg;
top: 5%;
right: auto;
left: 5%;
`;
} else if (props.$rotation === Rotation.SideFlipped) {
return css`
rotate: ${props.$rotation - 180}deg;
top: auto;
left: auto;
bottom: 5%;
right: 5%;
`;
}
}}
`;
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 = {
player: Player;
@@ -214,9 +142,31 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
const extraCountersSize = isSide ? '8vmin' : '4vmax';
const closeButtonSize = isSide ? '6vmin' : '3vmax';
const calcRotation =
player.settings.rotation === Rotation.Side
? `${player.settings.rotation - 180}deg`
: player.settings.rotation === Rotation.SideFlipped
? `${player.settings.rotation - 180}deg`
: '';
return (
<PlayerMenuWrapper $rotation={player.settings.rotation}>
<CloseButton $rotation={player.settings.rotation}>
<PlayerMenuWrapper
//TODO: Fix hacky solution to rotation for SideFlipped
style={{
rotate:
player.settings.rotation === Rotation.SideFlipped ? '180deg' : '',
}}
>
<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}
@@ -230,8 +180,12 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
<Cross size={closeButtonSize} />
</Button>
</CloseButton>
<SettingsContainer
$rotation={player.settings.rotation}
style={{
rotate: calcRotation,
}}
ref={settingsContainerRef}
>
<ColorPicker
@@ -244,7 +198,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
<BetterRowContainer>
<TogglesSection>
{player.settings.useCommanderDamage && (
<CheckboxContainer $rotation={player.settings.rotation}>
<CheckboxContainer>
<Checkbox
name="usePartner"
checked={player.settings.usePartner}
@@ -272,7 +226,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
</CheckboxContainer>
)}
<CheckboxContainer $rotation={player.settings.rotation}>
<CheckboxContainer>
<Checkbox
name="usePoison"
checked={player.settings.usePoison}
@@ -299,7 +253,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
/>
</CheckboxContainer>
<CheckboxContainer $rotation={player.settings.rotation}>
<CheckboxContainer>
<Checkbox
name="useEnergy"
checked={player.settings.useEnergy}
@@ -326,7 +280,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
/>
</CheckboxContainer>
<CheckboxContainer $rotation={player.settings.rotation}>
<CheckboxContainer>
<Checkbox
name="useExperience"
checked={player.settings.useExperience}
@@ -353,8 +307,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
/>
</CheckboxContainer>
</TogglesSection>
<Spacer height="1rem" />
<ButtonsSections>
<ButtonsSections className="mt-4">
<Button
variant="text"
style={{
@@ -366,7 +319,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
>
<Exit size={iconSize} style={{ rotate: '180deg' }} />
</Button>
<CheckboxContainer $rotation={player.settings.rotation}>
<CheckboxContainer>
<Checkbox
name="fullscreen"
checked={document.fullscreenElement ? true : false}
@@ -418,15 +371,7 @@ const PlayerMenu = ({ player, setShowPlayerMenu }: PlayerMenuProps) => {
</BetterRowContainer>
<dialog
ref={dialogRef}
style={{
zIndex: 9999,
background: theme.palette.background.default,
color: theme.palette.text.primary,
borderRadius: '1rem',
border: 'none',
position: 'absolute',
top: '10%',
}}
className="z-[9999] bg-background-default text-text-primary rounded-2xl border-none absolute top-[10%]"
>
<h1>Reset Game?</h1>
<div style={{ display: 'flex', justifyContent: 'space-evenly' }}>

View File

@@ -1,6 +1,7 @@
import { Button, FormControl, FormLabel, Switch } from '@mui/material';
import Slider from '@mui/material/Slider';
import { useEffect, useState } from 'react';
import { twc } from 'react-twc';
import { createInitialPlayers } from '../../../Data/getInitialPlayers';
import { theme } from '../../../Data/theme';
import { useAnalytics } from '../../../Hooks/useAnalytics';
@@ -14,14 +15,12 @@ import {
} from '../../../Types/Settings';
import { InfoModal } from '../../Misc/InfoModal';
import { SettingsModal } from '../../Misc/SettingsModal';
import { Spacer } from '../../Misc/Spacer';
import { SupportMe } from '../../Misc/SupportMe';
import { LayoutOptions } from './LayoutOptions';
import { twc } from 'react-twc';
const MainWrapper = twc.div`w-[100dvw] h-fit pb-14 overflow-hidden items-center flex flex-col`;
const StartButtonFooter = twc.div`fixed bottom-4 -translate-y-1/2 z-1`;
const StartButtonFooter = twc.div`fixed bottom-4 z-1`;
const ToggleButtonsWrapper = twc.div`flex flex-row justify-between items-center`;
@@ -194,8 +193,7 @@ const Start = () => {
});
}}
/>
<Spacer height="0.7rem" />
<FormLabel>Starting Health</FormLabel>
<FormLabel className="mt-[0.7rem]">Starting Health</FormLabel>
<Slider
title="Starting Health"
max={60}
@@ -213,9 +211,8 @@ const Start = () => {
})
}
/>
<Spacer height="1rem" />
<ToggleButtonsWrapper>
<ToggleButtonsWrapper className="mt-4">
<ToggleContainer>
<FormLabel>Commander</FormLabel>
<Switch