1- import { Box , Heading , Text } from '@chakra-ui/react' ;
1+ import { Box , ButtonGroup , Heading , Icon , Text } from '@chakra-ui/react' ;
22import * as React from 'react' ;
3- import { FONT_DETAILS } from '../constants' ;
4- import { HtmlNavigator , ReaderState } from '../types' ;
3+ import { DEFAULT_SETTINGS , FONT_DETAILS } from '../constants' ;
4+ import { HtmlNavigator , ReaderSettings , ReaderState } from '../types' ;
5+ import Button from './Button' ;
56import useColorModeValue from './hooks/useColorModeValue' ;
6- import { Day , Night , Sepia } from './icons' ;
7+ import { Day , Night , Reset , Sepia , ZoomIn , ZoomOut } from './icons' ;
78import Tabs from './Tabs' ;
89import { ColorModeToggleButton } from './ToggleButton' ;
910import ToggleGroup from './ToggleGroup' ;
@@ -30,7 +31,13 @@ export default function HtmlSettings(
3031 if ( ! readerState . settings ) return null ;
3132 const { colorMode, fontFamily } = readerState . settings ;
3233
33- const { setFontFamily, setColorMode } = navigator ;
34+ const {
35+ decreaseFontSize,
36+ increaseFontSize,
37+ resetSettings,
38+ setFontFamily,
39+ setColorMode,
40+ } = navigator ;
3441
3542 return (
3643 < >
@@ -66,6 +73,7 @@ export default function HtmlSettings(
6673 display = "flex"
6774 flexDirection = "column"
6875 p = { 4 }
76+ gap = { 4 }
6977 >
7078 < Heading
7179 as = "h3"
@@ -116,7 +124,86 @@ export default function HtmlSettings(
116124 textColor = "ui.black"
117125 />
118126 </ ToggleGroup >
127+ < ButtonGroup display = "flex" spacing = { 4 } >
128+ < Button
129+ onClick = { resetSettings }
130+ aria-label = "Reset settings"
131+ bgColor = "ui.white"
132+ width = "150px"
133+ >
134+ < Icon
135+ as = { Reset }
136+ w = { 18 }
137+ h = { 18 }
138+ mr = { 1.5 }
139+ sx = { {
140+ path : { stroke : 'ui.typography.body' } ,
141+ } }
142+ />
143+ Reset all
144+ </ Button >
145+ < Button
146+ onClick = { decreaseFontSize }
147+ aria-label = "Increase text"
148+ bgColor = "ui.white"
149+ width = "150px"
150+ sx = { {
151+ _active : {
152+ bgColor : checkedButtonBgColor ,
153+ } ,
154+ } }
155+ >
156+ < Icon
157+ as = { ZoomIn }
158+ w = { 18 }
159+ h = { 18 }
160+ mr = { 1.5 }
161+ sx = { {
162+ path : { stroke : 'ui.typography.body' } ,
163+ } }
164+ />
165+ Increase text
166+ </ Button >
167+ < Button
168+ onClick = { increaseFontSize }
169+ aria-label = "decrease text"
170+ bgColor = "ui.white"
171+ width = "150px"
172+ sx = { {
173+ _active : {
174+ bgColor : checkedButtonBgColor ,
175+ } ,
176+ } }
177+ >
178+ < Icon
179+ as = { ZoomOut }
180+ w = { 18 }
181+ h = { 18 }
182+ mr = { 1.5 }
183+ sx = { {
184+ path : { stroke : 'ui.typography.body' } ,
185+ } }
186+ />
187+ Decrease text
188+ </ Button >
189+ </ ButtonGroup >
119190 </ Box >
120191 </ >
121192 ) ;
122193}
194+
195+ // Returns true if the reader's settings match the default settings
196+ const areSettingsDefault = ( readerSettings : ReaderSettings ) => {
197+ if ( ! readerSettings ) {
198+ return false ;
199+ }
200+
201+ let setting : keyof ReaderSettings ;
202+
203+ for ( setting in DEFAULT_SETTINGS ) {
204+ if ( readerSettings [ setting ] !== DEFAULT_SETTINGS [ setting ] ) {
205+ return false ;
206+ }
207+ }
208+ return true ;
209+ } ;
0 commit comments