@@ -11,7 +11,6 @@ import ResponsiveSetCard from "../components/ResponsiveSetCard";
1111import { SettingsContext } from "../context" ;
1212import useDimensions from "../hooks/useDimensions" ;
1313import useKeydown from "../hooks/useKeydown" ;
14- import useStorage from "../hooks/useStorage" ;
1514import { generateCards , standardLayouts } from "../util" ;
1615
1716const gamePadding = 8 ;
@@ -27,15 +26,14 @@ function Game({
2726 answer,
2827 lastSet,
2928} ) {
30- const [ layoutOrientation , setLayoutOrientation ] = useStorage (
31- "layout" ,
32- "portrait" ,
33- ) ;
34- const [ cardOrientation , setCardOrientation ] = useStorage (
35- "orientation" ,
36- "vertical" ,
37- ) ;
38- const { keyboardLayout, volume } = useContext ( SettingsContext ) ;
29+ const {
30+ keyboardLayout,
31+ volume,
32+ layoutOrientation,
33+ toggleLayoutOrientation,
34+ cardOrientation,
35+ toggleCardOrientation,
36+ } = useContext ( SettingsContext ) ;
3937 const keyboardLayoutDesc = standardLayouts [ keyboardLayout ] ;
4038 const isHorizontal = cardOrientation === "horizontal" ;
4139 const isLandscape = layoutOrientation === "landscape" ;
@@ -177,11 +175,11 @@ function Game({
177175 ) {
178176 event . preventDefault ( ) ;
179177 if ( volume === "on" ) playLayout ( ) ;
180- setCardOrientation ( isHorizontal ? "vertical" : "horizontal" ) ;
178+ toggleCardOrientation ( ) ;
181179 } else if ( key . toLowerCase ( ) === keyboardLayoutDesc . layoutChangeKey ) {
182180 event . preventDefault ( ) ;
183181 if ( volume === "on" ) playLayout ( ) ;
184- setLayoutOrientation ( isLandscape ? "portrait" : "landscape" ) ;
182+ toggleLayoutOrientation ( ) ;
185183 }
186184 }
187185 } ) ;
0 commit comments