Skip to content

Commit

Permalink
Refactor StyledSquare component to use padding for height and improve…
Browse files Browse the repository at this point in the history
… child element positioning
  • Loading branch information
athrvk committed Dec 12, 2024
1 parent 207b442 commit 81a37d7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/components/Game/Square.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import styled from 'styled-components';

const StyledSquare = styled.button`
width: 100%;
height: 100%;
height: 0;
padding-top: 100%;
position: relative;
aspect-ratio: 1;
border: ${(props) => props.isWinning ? "4px" : "2px"} solid ${({ theme }) => theme.colors.border};
background: none;
Expand All @@ -15,7 +17,15 @@ const StyledSquare = styled.button`
props.theme.colors.primary :
props.theme.colors.secondary
};
transform: ${props => props.isWinning ? 'scale(1.05)' : 'scale(1)'};
& > * {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
&:hover:not(:disabled) {
&:hover:not(:disabled) {
background-color: ${({ theme }) => theme.colors.hover};
Expand Down

0 comments on commit 81a37d7

Please sign in to comment.