Skip to content

Commit

Permalink
Added UI adaptation for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Sep 29, 2023
1 parent 4604442 commit b5cb023
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/const/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const INTERFACE_SCALE = {
min: 0.7,
max: 1.0,
};

export const INTERFACE_MOBILE_BREAKPOINT = '(max-height: 400px)';
8 changes: 4 additions & 4 deletions src/game/scenes/screen/interface/builder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ export const Builder: React.FC = () => {
case TutorialStep.BUILD_GENERATOR: {
return setHint({
variant: BuildingVariant.GENERATOR,
text: 'Build generator to get resources',
text: 'Build generator\nto get resources',
});
}
case TutorialStep.BUILD_RADAR: {
return setHint({
variant: BuildingVariant.RADAR,
text: 'Build radar to uncover enemies',
text: 'Build radar\nto uncover enemies',
});
}
case TutorialStep.BUILD_TOWER_FIRE: {
return setHint({
variant: BuildingVariant.TOWER_FIRE,
text: 'Build tower to attack enemies',
text: 'Build tower\nto attack enemies',
});
}
case TutorialStep.BUILD_AMMUNITION: {
return setHint({
variant: BuildingVariant.AMMUNITION,
text: 'Build ammunition to reload towers',
text: 'Build ammunition\nto reload towers',
});
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/game/scenes/screen/interface/builder/preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { GameScene } from '~type/game';
import { IWorld } from '~type/world';
import { BuildingVariant } from '~type/world/entities/building';

import { Container, Number, Preview } from './styles';
import {
Container, Number, Preview, Newest,
} from './styles';

type Props = {
number: number
Expand Down
11 changes: 8 additions & 3 deletions src/game/scenes/screen/interface/builder/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import styled from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';

export const Wrapper = styled.div`
pointer-events: all;
display: grid;
grid-template-columns: 1fr;
grid-gap: 10px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
grid-gap: 2px;
}
`;

export const Info = styled.div`
Expand All @@ -16,9 +24,6 @@ export const Variant = styled.div`
position: relative;
display: flex;
align-items: center;
&:not(:last-child) {
margin-bottom: 10px;
}
&:hover {
[role=hint] {
display: none;
Expand Down
5 changes: 5 additions & 0 deletions src/game/scenes/screen/interface/player-hud/avatar/styles.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import styled from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';
import { InterfaceBackgroundColor } from '~type/interface';

export const Container = styled.div`
width: 80px;
height: 80px;
background: ${InterfaceBackgroundColor.BLACK_TRANSPARENT_50};
border-radius: 5px 5px 0 0;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
width: 70px;
height: 70px;
}
`;

export const Image = styled.img`
Expand Down
4 changes: 4 additions & 0 deletions src/game/scenes/screen/interface/player-hud/health/styles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import styled from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';
import { InterfaceBackgroundColor, InterfaceFont } from '~type/interface';

export const Container = styled.div`
background: #000;
width: 80px;
position: relative;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
width: 70px;
}
`;

export const Progress = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const Skills: React.FC = () => {

return (
<Wrapper>
<Button onClick={onClickButton} view={isOpened ? 'active' : undefined} size='fixed'>
<Button onClick={onClickButton} view={isOpened ? 'active' : undefined}>
SKILLS
</Button>
{isOpened && <UpgradesList onClose={onClose} />}
Expand Down
10 changes: 10 additions & 0 deletions src/game/scenes/screen/interface/player-hud/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import styled from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';

export const Wrapper = styled.div`
display: flex;
`;
Expand All @@ -8,8 +10,16 @@ export const Group = styled.div`
&:not(:last-child) {
margin-right: 16px;
}
@media ${INTERFACE_MOBILE_BREAKPOINT} {
&:not(:last-child) {
margin-right: 12px;
}
}
`;

export const Space = styled.div`
height: 6px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
height: 4px;
}
`;
5 changes: 5 additions & 0 deletions src/game/scenes/screen/interface/styles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import styled, { css } from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';

export const Wrapper = styled.div`
width: 100%;
height: 100%;
padding: 32px;
display: flex;
justify-content: space-between;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
padding: 16px;
}
`;

export const Grid = styled.div`
Expand Down
14 changes: 14 additions & 0 deletions src/game/scenes/screen/interface/wave/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled, { css, keyframes } from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';
import {
InterfaceFont,
InterfaceTextColor,
Expand All @@ -25,6 +26,9 @@ export const Container = styled.div`
padding: 10px 15px 10px 10px;
background: ${InterfaceBackgroundColor.BLACK_TRANSPARENT_75};
border-radius: 5px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
padding: 7px 11px 7px 7px;
}
`;

export const CurrentNumber = styled.div<{
Expand All @@ -46,6 +50,11 @@ export const CurrentNumber = styled.div<{
return InterfaceBackgroundColor.SUCCESS;
}};
box-shadow: 0 20px 0 ${InterfaceBackgroundColor.WHITE_TRANSPARENT_15} inset;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
font-size: 22px;
line-height: 22px;
padding: 4px 13px 8px 13px;
}
`;

export const State = styled.div`
Expand All @@ -57,6 +66,11 @@ export const Label = styled.div`
line-height: 11px;
opacity: 0.5;
margin-top: -2px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
font-size: 8px;
line-height: 8px;
opacity: 0.75;
}
`;

export const Value = styled.div<{
Expand Down
14 changes: 14 additions & 0 deletions src/game/scenes/system/interface/amount/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';
import { InterfaceFont, InterfaceBackgroundColor } from '~type/interface';

export const Placeholder = styled.div`
Expand Down Expand Up @@ -42,10 +43,17 @@ export const IconContainer = styled.div`
justify-content: center;
width: 32px;
height: 32px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
width: 28px;
height: 28px;
}
`;

export const Icon = styled.img`
width: 16px;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
width: 14px;
}
`;

export const Value = styled.div`
Expand All @@ -57,4 +65,10 @@ export const Value = styled.div`
display: flex;
align-items: center;
flex: 1;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
height: 28px;
font-size: 15px;
line-height: 15px;
padding: 0 9px 0 6px;
}
`;
2 changes: 1 addition & 1 deletion src/game/scenes/system/interface/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { Container } from './styles';

type Props = {
size?: 'fixed' | 'small' | 'medium' | 'large'
size?: 'small' | 'medium' | 'large'
view?: 'active' | 'primary' | 'confirm' | 'decline'
disabled?: boolean
onClick: (event: React.MouseEvent<HTMLDivElement>) => void
Expand Down
20 changes: 12 additions & 8 deletions src/game/scenes/system/interface/button/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled, { css } from 'styled-components';

import { INTERFACE_MOBILE_BREAKPOINT } from '~const/interface';
import { InterfaceFont, InterfaceBackgroundColor } from '~type/interface';

export const Container = styled.div<{
Expand Down Expand Up @@ -44,12 +45,6 @@ export const Container = styled.div<{
}}
${(props) => {
switch (props.$size) {
case 'fixed': return css`
text-align: center;
font-size: 10px;
line-height: 24px;
width: 80px;
`;
case 'large': return css`
font-size: 22px;
line-height: 22px;
Expand All @@ -60,12 +55,21 @@ export const Container = styled.div<{
line-height: 18px;
padding: 10px 18px 11px 18px;
`;
case 'small':
default: return css`
case 'small': return css`
font-size: 11px;
line-height: 11px;
padding: 7px 10px 8px 10px;
`;
default: return css`
font-size: 10px;
line-height: 10px;
text-align: center;
padding: 6px 0 7px 0;
@media ${INTERFACE_MOBILE_BREAKPOINT} {
font-size: 8px;
line-height: 8px;
}
`;
}
}}
${(props) => (props.$disabled ? css`
Expand Down
4 changes: 2 additions & 2 deletions src/game/scenes/system/interface/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const Modal: React.FC<Props> = ({ children, onConfirm, onClose }) => (
<Container>
<Content>{children}</Content>
<Buttons>
<Button view='confirm' onClick={onConfirm}>Yes</Button>
<Button view='decline' onClick={onClose}>No</Button>
<Button view='confirm' size='small' onClick={onConfirm}>Yes</Button>
<Button view='decline' size='small' onClick={onClose}>No</Button>
</Buttons>
</Container>
);

0 comments on commit b5cb023

Please sign in to comment.