forked from external-repos/LifeTrinket
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5386d08a4 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "life-trinket",
|
"name": "life-trinket",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.9",
|
"version": "0.7.0",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18",
|
"node": ">=18",
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -264,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) && (
|
||||||
|
|||||||
Reference in New Issue
Block a user