Compare commits

..

4 Commits

Author SHA1 Message Date
Viktor Rådberg
e5386d08a4 fix settings cog color 2024-03-17 19:01:15 +01:00
Viktor Rådberg
d6cd678e9f fix random interval wrapper showing if enabled but show player is disabled 2024-03-17 18:41:58 +01:00
Viktor Rådberg
334b46db6e bump 2024-03-16 22:29:25 +01:00
Viktor Rådberg
e03ecc6f51 Merge pull request #33 from Vikeo/random-player-interval
random player interval
2024-03-16 22:28:49 +01:00
3 changed files with 28 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "life-trinket", "name": "life-trinket",
"private": true, "private": true,
"version": "0.6.7", "version": "0.7.0",
"type": "commonjs", "type": "commonjs",
"engines": { "engines": {
"node": ">=18", "node": ">=18",

View File

@@ -1,10 +1,12 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { useSwipeable } from 'react-swipeable'; import { useSwipeable } from 'react-swipeable';
import { twc } from 'react-twc'; import { twc } from 'react-twc';
import { baseColors } from '../../../tailwind.config';
import { useGlobalSettings } from '../../Hooks/useGlobalSettings'; import { useGlobalSettings } from '../../Hooks/useGlobalSettings';
import { usePlayers } from '../../Hooks/usePlayers'; import { usePlayers } from '../../Hooks/usePlayers';
import { Cog } from '../../Icons/generated'; import { Cog } from '../../Icons/generated';
import { Player, Rotation } from '../../Types/Player'; import { Player, Rotation } from '../../Types/Player';
import { checkContrast } from '../../Utils/checkContrast';
import { import {
RotationButtonProps, RotationButtonProps,
RotationDivProps, RotationDivProps,
@@ -15,7 +17,6 @@ import ExtraCountersBar from '../Counters/ExtraCountersBar';
import { Paragraph } from '../Misc/TextComponents'; import { Paragraph } from '../Misc/TextComponents';
import PlayerMenu from '../Players/PlayerMenu'; import PlayerMenu from '../Players/PlayerMenu';
import Health from './Health'; import Health from './Health';
import { baseColors } from '../../../tailwind.config';
const SettingsButtonTwc = 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', 'absolute flex-grow border-none outline-none cursor-pointer bg-transparent z-[1] select-none webkit-user-select-none',
@@ -27,16 +28,33 @@ const SettingsButtonTwc = twc.button<RotationButtonProps>((props) => [
type SettingsButtonProps = { type SettingsButtonProps = {
onClick: () => void; onClick: () => void;
rotation: Rotation; rotation: Rotation;
color: string;
}; };
const SettingsButton = ({ onClick, rotation }: SettingsButtonProps) => { const SettingsButton = ({ onClick, rotation, color }: SettingsButtonProps) => {
const [iconColor, setIconColor] = useState<'dark' | 'light'>('dark');
useEffect(() => {
const contrast = checkContrast(color, '#00000080');
if (contrast === 'Fail') {
setIconColor('light');
} else {
setIconColor('dark');
}
}, [color]);
return ( return (
<SettingsButtonTwc <SettingsButtonTwc
onClick={onClick} onClick={onClick}
$rotation={rotation} $rotation={rotation}
aria-label={`Settings`} aria-label={`Settings`}
> >
<Cog size="5vmin" color="black" opacity="0.3" /> <Cog
size="5vmin"
data-contrast={iconColor}
className="data-[contrast=dark]:text-icons-dark data-[contrast=light]:text-icons-light"
/>
</SettingsButtonTwc> </SettingsButtonTwc>
); );
}; };
@@ -243,7 +261,8 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
{player.hasLost && ( {player.hasLost && (
<PlayerLostWrapper $rotation={player.settings.rotation} /> <PlayerLostWrapper $rotation={player.settings.rotation} />
)} )}
{settings.useRandomStartingPlayerInterval && {settings.showStartingPlayer &&
settings.useRandomStartingPlayerInterval &&
!stopPlayerRandomization && !stopPlayerRandomization &&
!playing && ( !playing && (
<div <div
@@ -263,6 +282,7 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
setShowPlayerMenu(!showPlayerMenu); setShowPlayerMenu(!showPlayerMenu);
}} }}
rotation={player.settings.rotation} rotation={player.settings.rotation}
color={player.color}
/> />
)} )}
{playerCanLose(player) && ( {playerCanLose(player) && (

View File

@@ -42,6 +42,7 @@ export const Players = (players: PlayerType[], gridClasses: string) => {
useEffect(() => { useEffect(() => {
if ( if (
settings.showStartingPlayer &&
settings.useRandomStartingPlayerInterval && settings.useRandomStartingPlayerInterval &&
!stopPlayerRandomization && !stopPlayerRandomization &&
!playing !playing
@@ -102,7 +103,8 @@ export const Players = (players: PlayerType[], gridClasses: string) => {
return ( return (
<PlayersWrapper> <PlayersWrapper>
{settings.useRandomStartingPlayerInterval && {settings.showStartingPlayer &&
settings.useRandomStartingPlayerInterval &&
!stopPlayerRandomization && !stopPlayerRandomization &&
!playing && ( !playing && (
<div <div