Skip to content

Commit

Permalink
Add disabled state for level selector
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbours committed Oct 8, 2023
1 parent d9a5b5d commit 73a0e5c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
21 changes: 19 additions & 2 deletions front/app/Menu/LevelItem.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Levels, QueueInfo } from '@benjaminbours/composite-core';
import React from 'react';
import { QueueInfoText } from './QueueInfo';
import classNames from 'classnames';

interface IProps {
id: Levels;
name: string;
img: string;
disabled: boolean;
onClick: (level: Levels) => void;
queueInfo?: QueueInfo;
}
Expand All @@ -16,12 +18,27 @@ export default function LevelItem({
img,
onClick,
queueInfo,
disabled,
}: IProps) {
const cssClass = classNames({
'level-item': true,
'level-item--disabled': disabled,
});
return (
<div className="level-item" onClick={() => onClick(id)}>
<div
className={cssClass}
onClick={() => {
if (!disabled) {
onClick(id);
}
}}
>
<img src={img} alt={`screenshot of the level ${name}`} />
<div className="queue-space" />
<h3>{name}</h3>
<div className="level-item__center">
<h3>{name}</h3>
{disabled && <p>Coming soong</p>}
</div>
<div className="queue-space">
{queueInfo && (
<QueueInfoText side="light" value={queueInfo.light} />
Expand Down
3 changes: 3 additions & 0 deletions front/app/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,19 @@ export function Menu({ setMainState, mainState }: Props) {
id: Levels.CRACK_THE_DOOR,
name: 'Crack the door',
img: '/crack_the_door.png',
disabled: false,
},
{
id: Levels.LEARN_TO_FLY,
name: 'Learn to fly',
img: '/learn_to_fly.png',
disabled: true,
},
{
id: Levels.THE_HIGH_SPHERES,
name: 'The hight spheres',
img: '/the_hight_spheres.png',
disabled: true,
},
],
[],
Expand Down
21 changes: 18 additions & 3 deletions front/app/styles/levelScene.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
height: 200px;
display: flex;
align-items: center;
color: white;

&::after {
content: '';
Expand Down Expand Up @@ -56,15 +57,18 @@
}
}

p,
h3 {
position: relative;
flex: 2;
z-index: 10;
color: white;
text-transform: uppercase;
letter-spacing: 5px;
font-size: 24px;
font-weight: 100;
}

h3 {
flex: 2;
font-size: 24px;
width: 100%;
text-align: center;
padding: 0 10px;
Expand Down Expand Up @@ -102,4 +106,15 @@
}
}
}

&--disabled {
cursor: not-allowed;
}
}

.level-item__center {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

0 comments on commit 73a0e5c

Please sign in to comment.