✨ Add icons next to selects label in Home
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ------------------------------------------------------ React --------------------------------------------------------
|
// ------------------------------------------------------ React --------------------------------------------------------
|
||||||
import { useEffect, useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------- Context & Stockage --------------------------------------------------
|
// ----------------------------------------------- Context & Stockage --------------------------------------------------
|
||||||
@@ -13,6 +13,8 @@ import { gameStateAtom } from '../../contexts/gameState';
|
|||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ----------------------------------------------------- Styles --------------------------------------------------------
|
// ----------------------------------------------------- Styles --------------------------------------------------------
|
||||||
|
import Size from '../../assets/size';
|
||||||
|
import Difficulty from '../../assets/difficulty';
|
||||||
import './styles.scss';
|
import './styles.scss';
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -57,7 +59,10 @@ const Home = () => {
|
|||||||
|
|
||||||
<div className='settingsContainer'>
|
<div className='settingsContainer'>
|
||||||
<div className='selectorBox'>
|
<div className='selectorBox'>
|
||||||
<p className='settingLabel'>Taille de la grille</p>
|
<p className='settingLabel'>
|
||||||
|
<Size />
|
||||||
|
Taille de la grille
|
||||||
|
</p>
|
||||||
<select
|
<select
|
||||||
ref={sizeRef}
|
ref={sizeRef}
|
||||||
name='gridSize'
|
name='gridSize'
|
||||||
@@ -71,7 +76,10 @@ const Home = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='selectorBox'>
|
<div className='selectorBox'>
|
||||||
<p className='settingLabel'>Difficulté</p>
|
<p className='settingLabel'>
|
||||||
|
<Difficulty />
|
||||||
|
Difficulté
|
||||||
|
</p>
|
||||||
<select
|
<select
|
||||||
ref={difficultyRef}
|
ref={difficultyRef}
|
||||||
name='difficulty'
|
name='difficulty'
|
||||||
|
|||||||
@@ -30,8 +30,16 @@
|
|||||||
gap: 20px;
|
gap: 20px;
|
||||||
|
|
||||||
& > .settingLabel {
|
& > .settingLabel {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
color: #f39440;
|
color: #f39440;
|
||||||
|
|
||||||
|
& > svg {
|
||||||
|
width: 1.2em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .select {
|
& > .select {
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ const LeaderBoard = () => {
|
|||||||
const [gameState, setGameState] = useRecoilState(gameStateAtom);
|
const [gameState, setGameState] = useRecoilState(gameStateAtom);
|
||||||
const [data, setData] = useState<LeaderBoardItem[]>([]);
|
const [data, setData] = useState<LeaderBoardItem[]>([]);
|
||||||
|
|
||||||
const [, updateLeaderboard] = useState({});
|
|
||||||
const forceUpdate = useCallback(() => updateLeaderboard({}), []);
|
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const storeData = await store.getItem<LeaderBoardItem[]>(`${gameState.difficulty}:${gameState.gridSize}`);
|
const storeData = await store.getItem<LeaderBoardItem[]>(`${gameState.difficulty}:${gameState.gridSize}`);
|
||||||
|
|
||||||
@@ -53,7 +50,7 @@ const LeaderBoard = () => {
|
|||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
}, [data.length]);
|
}, [data.length, getData]);
|
||||||
|
|
||||||
const clearAllLeaderboards = async () => {
|
const clearAllLeaderboards = async () => {
|
||||||
const keys = await store.keys();
|
const keys = await store.keys();
|
||||||
|
|||||||
Reference in New Issue
Block a user