File tree Expand file tree Collapse file tree 4 files changed +66
-9
lines changed
Expand file tree Collapse file tree 4 files changed +66
-9
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { FooterPanel } from "../FooterPanel";
44import { Hat } from "../Hat" ;
55import { Minesweeper } from "../core" ;
66import { Options } from "../Options" ;
7+ import {
8+ ZOOM_MIN ,
9+ ZOOM_MAX ,
10+ ZOOM_DEFAULT
11+ } from '../constants' ;
712import "./styles.css" ;
813
914function preventZoom ( event ) {
@@ -35,7 +40,13 @@ export default class App extends React.Component {
3540 toggleOptions = ( ) =>
3641 this . setState ( ( { showOptions } ) => ( { showOptions : ! showOptions } ) ) ;
3742
38- handleZoomChange = zoom => zoom && this . setState ( { zoom } ) ;
43+ handleZoomChange = zoom => zoom && zoom > 0 && this . setState ( {
44+ zoom : zoom > ZOOM_MAX
45+ ? ZOOM_MAX
46+ : zoom < ZOOM_MIN
47+ ? ZOOM_MIN
48+ : zoom
49+ } ) ;
3950
4051 newGame = ( arena , mines ) => this . game . configure ( arena , mines ) ;
4152
Original file line number Diff line number Diff line change 11import React from "react" ;
22import { Button , ControlsPanel , Switcher } from "@tarantool.io/ui-kit" ;
33import b_ from 'b_' ;
4+ import { ZOOM_STEP } from '../constants' ;
45import "./styles.css" ;
56
67const b = b_ . lock ( 'FooterPanel' ) ;
78
8- export const FooterPanel = ( { flaggingMode, zoom, onFlaggingSwitch, onZoomChange } ) => (
9+ export const FooterPanel = ( {
10+ flaggingMode,
11+ zoom,
12+ onFlaggingSwitch,
13+ onZoomChange
14+ } ) => (
915 < ControlsPanel
1016 className = { b ( ) }
1117 controls = { [
12- < Button className = { b ( 'zoomButton' ) } text = '+' size = 'xs' onClick = { ( ) => onZoomChange ( zoom + 0.5 ) } /> ,
13- < Button className = { b ( 'zoomButton' ) } text = '-' size = 'xs' onClick = { ( ) => onZoomChange ( zoom - 0.5 ) } /> ,
14- < Switcher onChange = { onFlaggingSwitch } title = "Flag" checked = { flaggingMode } > Flag</ Switcher >
18+ < Button
19+ key = '+'
20+ className = { b ( 'zoomButton' ) }
21+ text = '+'
22+ size = 'xs'
23+ onClick = { ( ) => onZoomChange ( zoom + ZOOM_STEP ) }
24+ /> ,
25+ < Button
26+ key = '-'
27+ className = { b ( 'zoomButton' ) }
28+ text = '-'
29+ size = 'xs'
30+ onClick = { ( ) => onZoomChange ( zoom - ZOOM_STEP ) }
31+ /> ,
32+ < Switcher
33+ key = 'f'
34+ onChange = { onFlaggingSwitch }
35+ title = 'Flag'
36+ checked = { flaggingMode }
37+ >
38+ Flag
39+ </ Switcher >
1540 ] }
1641 />
1742) ;
Original file line number Diff line number Diff line change @@ -20,13 +20,30 @@ export const Hat = ({
2020 className = { b ( ) }
2121 thin
2222 controls = { [
23- < Text className = { b ( 'output' ) } title = 'Mines counter' > 💣{ minesLeftCount } </ Text > ,
24- < Text className = { b ( 'output' ) } title = 'Timer' > ⏱{ timerValue === null ? 0 : Math . round ( timerValue / 1000 ) } </ Text > ,
25- < Button onClick = { onResetClick } title = 'New game (Space)' intent = { gameState === 'playing' ? 'secondary' : 'primary' } >
23+ < Text
24+ key = 'c'
25+ className = { b ( 'output' ) }
26+ title = 'Mines counter'
27+ >
28+ 💣{ minesLeftCount }
29+ </ Text > ,
30+ < Text
31+ key = 't'
32+ className = { b ( 'output' ) }
33+ title = 'Timer'
34+ >
35+ ⏱{ timerValue === null ? 0 : Math . round ( timerValue / 1000 ) }
36+ </ Text > ,
37+ < Button
38+ key = 'n'
39+ onClick = { onResetClick }
40+ title = 'New game (Space)'
41+ intent = { gameState === 'playing' ? 'secondary' : 'primary' }
42+ >
2643 { gameState === "playing" ? "🙂" : gameState === "won" ? "😎" : "😵" }
2744 New game
2845 </ Button > ,
29- < Button onClick = { onOptionsClick } title = "Options" > Options</ Button >
46+ < Button key = 'o' onClick = { onOptionsClick } title = "Options" > Options</ Button >
3047 ] }
3148 />
3249) ;
Original file line number Diff line number Diff line change 1+ export const ZOOM_MIN = 0.25 ;
2+ export const ZOOM_MAX = 4 ;
3+ export const ZOOM_STEP = 0.25 ;
4+ export const ZOOM_DEFAULT = 1 ;
You can’t perform that action at this time.
0 commit comments