From 1013914cdfc2c1c72e0d87e2043a33b6ecf8746d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20R=C3=A5dberg?= Date: Sun, 7 Jan 2024 00:15:37 +0100 Subject: [PATCH] commander damage tailwind --- src/Components/Buttons/CommanderDamage.tsx | 135 ++++++--------------- yarn.lock | 16 +-- 2 files changed, 43 insertions(+), 108 deletions(-) diff --git a/src/Components/Buttons/CommanderDamage.tsx b/src/Components/Buttons/CommanderDamage.tsx index 337dce1..2aff440 100644 --- a/src/Components/Buttons/CommanderDamage.tsx +++ b/src/Components/Buttons/CommanderDamage.tsx @@ -1,110 +1,45 @@ -import styled from 'styled-components'; -import { css } from 'styled-components'; -import { Player, Rotation } from '../../Types/Player'; import { useRef, useState } from 'react'; -import { OutlinedText } from '../Misc/OutlinedText'; 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'; -const CommanderDamageContainer = styled.div<{ - $rotation: number; -}>` - display: flex; - flex-direction: row; - flex-grow: 1; - width: 100%; +type RotationDivProps = TwcComponentProps<'div'> & { + $rotation?: number; +}; - ${(props) => { - if ( - props.$rotation === Rotation.SideFlipped || - props.$rotation === Rotation.Side - ) { - return css` - flex-direction: column; - `; - } - }} -`; +type RotationButtonProps = TwcComponentProps<'button'> & { + $rotation?: number; +}; -const CommanderDamageButton = styled.button<{ - $backgroundColor?: string; - $rotation: number; -}>` - display: flex; - flex-grow: 1; - border: none; - height: 10vmin; - width: 50%; - outline: none; - cursor: pointer; - background-color: ${(props) => props.$backgroundColor || 'antiquewhite'}; - margin: 0; - 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; - padding: 0; - ${(props) => { - if ( - props.$rotation === Rotation.SideFlipped || - props.$rotation === Rotation.Side - ) { - return css` - width: 6vmax; - height: auto; - `; - } - }} -`; +const CommanderDamageContainer = twc.div((props) => [ + 'flex flex-row flex-grow w-full', + props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side + ? 'flex-col' + : '', +]); -const CommanderDamageTextContainer = styled.div<{ - $rotation: number; -}>` - position: relative; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - font-variant-numeric: tabular-nums; - pointer-events: none; - 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 CommanderDamageButton = twc.button((props) => [ + 'flex flex-grow border-none h-[10vmin] w-1/2 outline-none cursor-pointer m-0 p-0', + props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side + ? 'w-[6vmax] h-auto' + : '', +]); - ${(props) => { - if ( - props.$rotation === Rotation.SideFlipped || - props.$rotation === Rotation.Side - ) { - return css` - rotate: 270deg; - `; - } - }} -`; +const CommanderDamageTextContainer = twc.div((props) => [ + 'relative top-1/2 left-1/2 tabular-nums pointer-events-none select-none', + props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side + ? 'rotate-[270deg]' + : '', +]); -const PartnerDamageSeperator = styled.div<{ - $rotation: number; -}>` - width: 1px; - background-color: rgba(0, 0, 0, 1); - - ${(props) => { - if ( - props.$rotation === Rotation.SideFlipped || - props.$rotation === Rotation.Side - ) { - return css` - width: auto; - height: 1px; - `; - } - }} -`; +const PartnerDamageSeperator = twc.div((props) => [ + 'w-px bg-black', + props.$rotation === Rotation.SideFlipped || props.$rotation === Rotation.Side + ? 'w-[5.999vmax] h-px' + : '', +]); type CommanderDamageButtonComponentProps = { player: Player; @@ -214,8 +149,8 @@ export const CommanderDamage = ({ onContextMenu={(e: React.MouseEvent) => { e.preventDefault(); }} - $backgroundColor={opponent.color} aria-label={`Commander damage. Player ${player.index}, opponent ${opponent.index}`} + style={{ background: opponent.color }} > { e.preventDefault(); }} - $backgroundColor={opponent.color} aria-label={`Partner Commander damage. Player ${player.index}, opponent ${opponent.index}`} + style={{ background: opponent.color }} >