mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-15 15:27:59 +00:00
Settings Styling (#10)
* add border radius * fix settings styling a little
This commit is contained in:
@@ -9,6 +9,7 @@ import ExtraCountersBar from '../Counters/ExtraCountersBar';
|
|||||||
import { OutlinedText } from '../Misc/OutlinedText';
|
import { OutlinedText } from '../Misc/OutlinedText';
|
||||||
import PlayerMenu from '../PlayerMenu/PlayerMenu';
|
import PlayerMenu from '../PlayerMenu/PlayerMenu';
|
||||||
import { Skull } from '../../Icons/generated';
|
import { Skull } from '../../Icons/generated';
|
||||||
|
|
||||||
const LifeCounterContentWrapper = styled.div<{
|
const LifeCounterContentWrapper = styled.div<{
|
||||||
backgroundColor: string;
|
backgroundColor: string;
|
||||||
}>`
|
}>`
|
||||||
@@ -24,6 +25,9 @@ const LifeCounterContentWrapper = styled.div<{
|
|||||||
max-width: 100vmax;
|
max-width: 100vmax;
|
||||||
max-height: 100vmin;
|
max-height: 100vmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LifeCounterWrapper = styled.div<{
|
const LifeCounterWrapper = styled.div<{
|
||||||
@@ -186,7 +190,13 @@ export const LoseGameButton = styled.button<{ rotation: Rotation }>`
|
|||||||
top: 12vmin;
|
top: 12vmin;
|
||||||
right: 6vmax;
|
right: 6vmax;
|
||||||
background-color: #43434380;
|
background-color: #43434380;
|
||||||
border-radius: 15px;
|
border-radius: 8px;
|
||||||
|
-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) => {
|
${(props) => {
|
||||||
if (props.rotation === Rotation.SideFlipped) {
|
if (props.rotation === Rotation.SideFlipped) {
|
||||||
@@ -246,8 +256,8 @@ const LifeCounter = ({
|
|||||||
setKey(Date.now());
|
setKey(Date.now());
|
||||||
};
|
};
|
||||||
|
|
||||||
const setGameLost = () => {
|
const toggleGameLost = () => {
|
||||||
const updatedPlayer = { ...player, hasLost: true };
|
const updatedPlayer = { ...player, hasLost: !player.hasLost };
|
||||||
onPlayerChange(updatedPlayer);
|
onPlayerChange(updatedPlayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -289,14 +299,14 @@ const LifeCounter = ({
|
|||||||
const fontSize =
|
const fontSize =
|
||||||
player.settings.rotation === Rotation.SideFlipped ||
|
player.settings.rotation === Rotation.SideFlipped ||
|
||||||
player.settings.rotation === Rotation.Side
|
player.settings.rotation === Rotation.Side
|
||||||
? `${size}vmax`
|
? `clamp(6rem, ${size}vmax, 10rem)`
|
||||||
: `${size}vmin`;
|
: `clamp(6rem, ${size}vmin, 10rem)`;
|
||||||
|
|
||||||
const strokeWidth =
|
const strokeWidth =
|
||||||
player.settings.rotation === Rotation.SideFlipped ||
|
player.settings.rotation === Rotation.SideFlipped ||
|
||||||
player.settings.rotation === Rotation.Side
|
player.settings.rotation === Rotation.Side
|
||||||
? `${size / 20}vmax`
|
? `clamp(0.4rem, ${size / 20}vmax, 12rem)`
|
||||||
: `${size / 20}vmin`;
|
: `clamp(0.4rem, ${size / 20}vmin, 12rem)`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LifeCounterContentWrapper backgroundColor={backgroundColor}>
|
<LifeCounterContentWrapper backgroundColor={backgroundColor}>
|
||||||
@@ -333,7 +343,7 @@ const LifeCounter = ({
|
|||||||
{(player.lifeTotal < 1 || hasCommanderDamageReached21(player)) && (
|
{(player.lifeTotal < 1 || hasCommanderDamageReached21(player)) && (
|
||||||
<LoseGameButton
|
<LoseGameButton
|
||||||
rotation={player.settings.rotation}
|
rotation={player.settings.rotation}
|
||||||
onClick={setGameLost}
|
onClick={toggleGameLost}
|
||||||
>
|
>
|
||||||
<Skull size="5vmin" color="black" opacity={0.5} />
|
<Skull size="5vmin" color="black" opacity={0.5} />
|
||||||
</LoseGameButton>
|
</LoseGameButton>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Settings from './Settings';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
import { Rotation } from '../../Types/Player';
|
import { Rotation } from '../../Types/Player';
|
||||||
|
import { Button } from '@mui/material';
|
||||||
|
|
||||||
const PlayerMenuWrapper = styled.div<{
|
const PlayerMenuWrapper = styled.div<{
|
||||||
rotation: Rotation;
|
rotation: Rotation;
|
||||||
@@ -29,15 +30,17 @@ const PlayerMenuWrapper = styled.div<{
|
|||||||
}};
|
}};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const CloseButton = styled.button<{
|
const CloseButton = styled.div<{
|
||||||
rotation: Rotation;
|
rotation: Rotation;
|
||||||
}>`
|
}>`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5%;
|
top: 5%;
|
||||||
right: 5%;
|
right: 5%;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
user-select: none;
|
background-color: transparent;
|
||||||
color: black;
|
|
||||||
${(props) => {
|
${(props) => {
|
||||||
if (props.rotation === Rotation.Side) {
|
if (props.rotation === Rotation.Side) {
|
||||||
return css`
|
return css`
|
||||||
@@ -79,8 +82,17 @@ const PlayerMenu = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PlayerMenuWrapper rotation={player.settings.rotation}>
|
<PlayerMenuWrapper rotation={player.settings.rotation}>
|
||||||
<CloseButton rotation={player.settings.rotation} onClick={handleOnClick}>
|
<CloseButton rotation={player.settings.rotation}>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
padding: '0 8px',
|
||||||
|
minWidth: '0',
|
||||||
|
}}
|
||||||
|
variant="outlined"
|
||||||
|
onClick={handleOnClick}
|
||||||
|
>
|
||||||
X
|
X
|
||||||
|
</Button>
|
||||||
</CloseButton>
|
</CloseButton>
|
||||||
<Settings
|
<Settings
|
||||||
player={player}
|
player={player}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Checkbox } from '@mui/material';
|
import { Button, Checkbox } from '@mui/material';
|
||||||
import styled, { css } from 'styled-components';
|
import styled, { css } from 'styled-components';
|
||||||
import { Energy, Experience, PartnerTax, Poison } from '../../Icons/generated';
|
import { Energy, Experience, PartnerTax, Poison } from '../../Icons/generated';
|
||||||
import { Player, Rotation } from '../../Types/Player';
|
import { Player, Rotation } from '../../Types/Player';
|
||||||
@@ -15,6 +15,7 @@ const SettingsContainer = styled.div<{
|
|||||||
rotation: Rotation;
|
rotation: Rotation;
|
||||||
}>`
|
}>`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -29,11 +30,6 @@ const SettingsContainer = styled.div<{
|
|||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
/* padding-top: 36px; */
|
|
||||||
`;
|
|
||||||
} else {
|
|
||||||
return css`
|
|
||||||
/* padding-top: 36px; */
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -41,9 +37,9 @@ const SettingsContainer = styled.div<{
|
|||||||
|
|
||||||
const TogglesSection = styled.div<{ rotation: Rotation }>`
|
const TogglesSection = styled.div<{ rotation: Rotation }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: absolute;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|
||||||
${(props) => {
|
${(props) => {
|
||||||
@@ -59,18 +55,22 @@ const TogglesSection = styled.div<{ rotation: Rotation }>`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const ButtonsSections = styled.div<{ rotation: Rotation }>`
|
const ButtonsSections = styled.div<{ rotation: Rotation }>`
|
||||||
|
position: absolute;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
bottom: 16px;
|
||||||
|
|
||||||
${(props) => {
|
${(props) => {
|
||||||
if (
|
if (props.rotation === Rotation.Side) {
|
||||||
props.rotation === Rotation.SideFlipped ||
|
|
||||||
props.rotation === Rotation.Side
|
|
||||||
) {
|
|
||||||
return css`
|
return css`
|
||||||
|
bottom: auto;
|
||||||
|
right: -6rem;
|
||||||
|
rotate: ${props.rotation - 180}deg;
|
||||||
|
`;
|
||||||
|
} else if (props.rotation === Rotation.SideFlipped) {
|
||||||
|
return css`
|
||||||
|
bottom: auto;
|
||||||
|
left: -6rem;
|
||||||
rotate: ${props.rotation - 180}deg;
|
rotate: ${props.rotation - 180}deg;
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -111,12 +111,6 @@ const ColorPicker = styled.input<{
|
|||||||
}}
|
}}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Button = styled.button`
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
color: #000000;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CheckboxContainer = styled.div<{ rotation: Rotation }>`
|
const CheckboxContainer = styled.div<{ rotation: Rotation }>`
|
||||||
${(props) => {
|
${(props) => {
|
||||||
if (
|
if (
|
||||||
@@ -269,11 +263,41 @@ const Settings = ({ player, onChange, resetCurrentGame }: SettingsProps) => {
|
|||||||
/>
|
/>
|
||||||
</CheckboxContainer>
|
</CheckboxContainer>
|
||||||
</TogglesSection>
|
</TogglesSection>
|
||||||
|
|
||||||
<ButtonsSections rotation={player.settings.rotation}>
|
<ButtonsSections rotation={player.settings.rotation}>
|
||||||
<Button onClick={handleNewGame}>Back to Start</Button>
|
<Button
|
||||||
<Button onClick={toggleFullscreen}>Fullscreen</Button>
|
variant="outlined"
|
||||||
<Button onClick={handleWakeLock}>
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
fontSize: '0.6rem',
|
||||||
|
padding: '0 4px 0 4px',
|
||||||
|
}}
|
||||||
|
onClick={handleNewGame}
|
||||||
|
>
|
||||||
|
Back to Start
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
fontSize: '0.6rem',
|
||||||
|
padding: '0 4px 0 4px',
|
||||||
|
}}
|
||||||
|
onClick={toggleFullscreen}
|
||||||
|
>
|
||||||
|
Fullscreen
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
fontSize: '0.6rem',
|
||||||
|
padding: '0 4px 0 4px',
|
||||||
|
}}
|
||||||
|
onClick={handleWakeLock}
|
||||||
|
>
|
||||||
{released === false ? 'Release' : 'Request'} nosleep
|
{released === false ? 'Release' : 'Request'} nosleep
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonsSections>
|
</ButtonsSections>
|
||||||
|
|||||||
Reference in New Issue
Block a user