-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings modal with language, day/night mode and accent MVP (#145)
Initial draft settings modal with language, day/night mode and accent Styling will be improved upon by completing issue #155 Closes #151
- Loading branch information
1 parent
dc92dcc
commit a02bf21
Showing
8 changed files
with
212 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
import { vars } from 'degen'; | ||
|
||
export const select = style({ | ||
background: 'transparent', | ||
color: vars.colors.accent, | ||
padding: '3px 7px', | ||
borderColor: vars.colors.accent, | ||
borderRadius: vars.radii['large'], | ||
outline: 'none', | ||
cursor: 'pointer', | ||
textTransform: 'capitalize' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React, { useState } from 'react'; | ||
import { Box, Button, Stack, Text, useTheme } from 'degen'; | ||
|
||
import * as styles from './SettingsModal.css'; | ||
import { Accent, Mode } from 'degen/dist/types/tokens'; | ||
import { accents, modes } from 'helpers/theme-utils'; | ||
import { Language, languages } from 'helpers/languageUtils'; | ||
import { accentLocalKey, languageLocalKey, modeLocalKey } from 'constants/local-storage'; | ||
|
||
const SettingsModal = () => { | ||
const { accent, setAccent, mode, setMode } = useTheme(); | ||
const [language, setLanguage] = useState<Language>(Language.EN_US); | ||
|
||
const locallyStore = (key: string, value: string) => localStorage.setItem(key, value); | ||
|
||
const setLanguageState = (lang: Language) => { | ||
setLanguage(lang); | ||
locallyStore(languageLocalKey, lang); | ||
}; | ||
|
||
const setModeState = (mode: Mode) => { | ||
setMode(mode); | ||
locallyStore(modeLocalKey, mode); | ||
}; | ||
|
||
const setAccentState = (accent: Accent) => { | ||
setAccent(accent); | ||
locallyStore(accentLocalKey, accent); | ||
}; | ||
|
||
return ( | ||
<Box width="96"> | ||
<Box borderBottomWidth="0.375" paddingX="6" paddingY="4"> | ||
<Text variant="large" color="textPrimary" weight="bold" align="center"> | ||
Settings | ||
</Text> | ||
</Box> | ||
<Box padding="6"> | ||
<Stack space="6"> | ||
<Stack direction="horizontal" justify="space-between"> | ||
<Text variant="small" color="textSecondary"> | ||
Language | ||
</Text> | ||
<Box> | ||
<select | ||
name="language" | ||
value={language} | ||
className={styles.select} | ||
onChange={(event) => | ||
setLanguageState(event.target.value as Language) | ||
} | ||
> | ||
{languages.map((languageValue, index) => | ||
<option value={languageValue} key={index}>{languageValue}</option> | ||
)} | ||
</select> | ||
</Box> | ||
</Stack> | ||
<Stack direction="horizontal" justify="space-between"> | ||
<Text variant="small" color="textSecondary"> | ||
Mode | ||
</Text> | ||
<Box> | ||
<select | ||
name="mode" | ||
value={mode} | ||
className={styles.select} | ||
onChange={(event) => | ||
setModeState(event.target.value as Mode) | ||
} | ||
> | ||
{modes.map((modeValue, index) => | ||
<option value={modeValue} key={index}>{modeValue}</option> | ||
)} | ||
</select> | ||
</Box> | ||
</Stack> | ||
<Stack direction="horizontal" justify="space-between"> | ||
<Text variant="small" color="textSecondary"> | ||
Color Scheme | ||
</Text> | ||
<Box> | ||
<select | ||
name="accent" | ||
value={accent} | ||
className={styles.select} | ||
onChange={(event) => | ||
setAccentState(event.target.value as Accent) | ||
} | ||
> | ||
{accents.map((accentValue, index) => | ||
<option value={accentValue} key={index}>{accentValue}</option> | ||
)} | ||
</select> | ||
</Box> | ||
</Stack> | ||
</Stack> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default SettingsModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const languageLocalKey = 'language'; | ||
export const modeLocalKey = 'mode'; | ||
export const accentLocalKey = 'accent'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum Language { | ||
EN_US = 'English (US)' | ||
} | ||
|
||
export const languages: Language[] = Object.values(Language); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters