add orderbook flash to settings

This commit is contained in:
saml33 2022-09-26 20:46:16 +10:00
parent d25d088e09
commit 513280ee80
9 changed files with 75 additions and 31 deletions

View File

@ -6,6 +6,8 @@ import { useRouter } from 'next/router'
import ButtonGroup from '../components/forms/ButtonGroup'
import useLocalStorageState from '../hooks/useLocalStorageState'
import dayjs from 'dayjs'
import { ORDERBOOK_FLASH_KEY } from 'utils/constants'
import Switch from '@components/forms/Switch'
require('dayjs/locale/en')
require('dayjs/locale/es')
@ -15,13 +17,15 @@ require('dayjs/locale/zh-tw')
export async function getStaticProps({ locale }: { locale: string }) {
return {
props: {
...(await serverSideTranslations(locale, ['common', 'profile', 'trade'])),
...(await serverSideTranslations(locale, [
'common',
'profile',
'settings',
])),
},
}
}
const THEMES = ['Light', 'Dark', 'Mango']
export const LANGS = [
{ locale: 'en', name: 'english', description: 'english' },
{ locale: 'es', name: 'spanish', description: 'spanish' },
@ -39,6 +43,11 @@ const Settings: NextPage = () => {
const [savedLanguage, setSavedLanguage] = useLocalStorageState('language', '')
const router = useRouter()
const { pathname, asPath, query } = router
const [showOrderbookFlash, setShowOrderbookFlash] = useLocalStorageState(
ORDERBOOK_FLASH_KEY,
true
)
const THEMES = [t('settings:light'), t('settings:dark'), t('settings:mango')]
const handleLangChange = (l: string) => {
setSavedLanguage(l)
@ -50,9 +59,9 @@ const Settings: NextPage = () => {
<div className="p-8 pb-20 md:pb-16 lg:p-10">
<div className="grid grid-cols-12">
<div className="col-span-12 border-b border-th-bkg-3 lg:col-span-8 lg:col-start-3">
<h2 className="mb-4 text-base">Display</h2>
<h2 className="mb-4 text-base">{t('settings:display')}</h2>
<div className="flex flex-col border-t border-th-bkg-3 p-4 md:flex-row md:items-center md:justify-between">
<p className="mb-2 lg:mb-0">{t('theme')}</p>
<p className="mb-2 lg:mb-0">{t('settings:theme')}</p>
<div className="w-full min-w-[220px] md:w-auto">
<ButtonGroup
activeValue={theme}
@ -63,17 +72,24 @@ const Settings: NextPage = () => {
</div>
</div>
<div className="flex flex-col border-t border-th-bkg-3 p-4 md:flex-row md:items-center md:justify-between">
<p className="mb-2 lg:mb-0">{t('language')}</p>
<p className="mb-2 lg:mb-0">{t('settings:language')}</p>
<div className="w-full min-w-[330px] md:w-auto">
<ButtonGroup
activeValue={savedLanguage}
onChange={(l) => handleLangChange(l)}
values={LANGS.map((val) => val.locale)}
names={LANGS.map((val) => t(val.name))}
names={LANGS.map((val) => t(`settings:${val.name}`))}
large
/>
</div>
</div>
<div className="flex flex-col border-t border-th-bkg-3 p-4 md:flex-row md:items-center md:justify-between">
<p className="mb-2 lg:mb-0">{t('settings:orderbook-flash')}</p>
<Switch
checked={showOrderbookFlash}
onChange={(checked) => setShowOrderbookFlash(checked)}
/>
</div>
</div>
</div>
</div>

View File

@ -22,8 +22,6 @@
"borrow-rate": "Borrow Rate (APR)",
"borrow-value": "Borrow Value",
"buy": "Buy",
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"close-account": "Close Account",
"close-account-desc": "Are you sure? Closing your account is irreversible.",
"closing-account": "Closing your account...",
@ -41,7 +39,6 @@
"disconnect": "Disconnect",
"edit-account": "Edit Account",
"edit-profile-image": "Edit Profile Image",
"english": "English",
"fee": "Fee",
"fees": "Fees",
"free-collateral": "Free Collateral",
@ -51,7 +48,6 @@
"insufficient-sol": "Solana requires 0.00757 SOL rent to create a Mango Account. This will be returned if you close your account.",
"interest-earned": "Interest Earned",
"interest-earned-paid": "Interest Earned",
"language": "Language",
"learn": "Learn",
"leverage": "Leverage",
"liability-weight": "Liability Weight",
@ -77,11 +73,9 @@
"settings": "Settings",
"show-zero-balances": "Show Zero Balances",
"size": "Size",
"spanish": "Español",
"spread": "Spread",
"stats": "Stats",
"swap": "Swap",
"theme": "Theme",
"time": "Time",
"token": "Token",
"tokens": "Tokens",

View File

@ -0,0 +1,13 @@
{
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"dark": "Dark",
"display": "Display",
"english": "English",
"language": "Language",
"light": "Light",
"mango": "Mango",
"orderbook-flash": "Orderbook Flash",
"spanish": "Español",
"theme": "Theme"
}

View File

@ -22,8 +22,6 @@
"borrow-rate": "Borrow Rate (APR)",
"borrow-value": "Borrow Value",
"buy": "Buy",
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"close-account": "Close Account",
"close-account-desc": "Are you sure? Closing your account is irreversible.",
"closing-account": "Closing your account...",
@ -41,7 +39,6 @@
"disconnect": "Disconnect",
"edit-account": "Edit Account",
"edit-profile-image": "Edit Profile Image",
"english": "English",
"fee": "Fee",
"fees": "Fees",
"free-collateral": "Free Collateral",
@ -51,7 +48,6 @@
"insufficient-sol": "Solana requires 0.00757 SOL rent to create a Mango Account. This will be returned if you close your account.",
"interest-earned": "Interest Earned",
"interest-earned-paid": "Interest Earned",
"language": "Language",
"learn": "Learn",
"leverage": "Leverage",
"liability-weight": "Liability Weight",
@ -77,11 +73,9 @@
"settings": "Settings",
"show-zero-balances": "Show Zero Balances",
"size": "Size",
"spanish": "Español",
"spread": "Spread",
"stats": "Stats",
"swap": "Swap",
"theme": "Theme",
"time": "Time",
"token": "Token",
"tokens": "Tokens",

View File

@ -0,0 +1,13 @@
{
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"dark": "Dark",
"display": "Display",
"english": "English",
"language": "Language",
"light": "Light",
"mango": "Mango",
"orderbook-flash": "Orderbook Flash",
"spanish": "Español",
"theme": "Theme"
}

View File

@ -22,8 +22,6 @@
"borrow-rate": "Borrow Rate (APR)",
"borrow-value": "Borrow Value",
"buy": "Buy",
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"close-account": "Close Account",
"close-account-desc": "Are you sure? Closing your account is irreversible.",
"closing-account": "Closing your account...",
@ -41,7 +39,6 @@
"disconnect": "Disconnect",
"edit-account": "Edit Account",
"edit-profile-image": "Edit Profile Image",
"english": "English",
"fee": "Fee",
"fees": "Fees",
"free-collateral": "Free Collateral",
@ -51,7 +48,6 @@
"insufficient-sol": "Solana requires 0.00757 SOL rent to create a Mango Account. This will be returned if you close your account.",
"interest-earned": "Interest Earned",
"interest-earned-paid": "Interest Earned",
"language": "Language",
"learn": "Learn",
"leverage": "Leverage",
"liability-weight": "Liability Weight",
@ -77,11 +73,9 @@
"settings": "Settings",
"show-zero-balances": "Show Zero Balances",
"size": "Size",
"spanish": "Español",
"spread": "Spread",
"stats": "Stats",
"swap": "Swap",
"theme": "Theme",
"time": "Time",
"token": "Token",
"tokens": "Tokens",

View File

@ -0,0 +1,13 @@
{
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"dark": "Dark",
"display": "Display",
"english": "English",
"language": "Language",
"light": "Light",
"mango": "Mango",
"orderbook-flash": "Orderbook Flash",
"spanish": "Español",
"theme": "Theme"
}

View File

@ -22,8 +22,6 @@
"borrow-rate": "Borrow Rate (APR)",
"borrow-value": "Borrow Value",
"buy": "Buy",
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"close-account": "Close Account",
"close-account-desc": "Are you sure? Closing your account is irreversible.",
"closing-account": "Closing your account...",
@ -41,7 +39,6 @@
"disconnect": "Disconnect",
"edit-account": "Edit Account",
"edit-profile-image": "Edit Profile Image",
"english": "English",
"fee": "Fee",
"fees": "Fees",
"free-collateral": "Free Collateral",
@ -51,7 +48,6 @@
"insufficient-sol": "Solana requires 0.00757 SOL rent to create a Mango Account. This will be returned if you close your account.",
"interest-earned": "Interest Earned",
"interest-earned-paid": "Interest Earned",
"language": "Language",
"learn": "Learn",
"leverage": "Leverage",
"liability-weight": "Liability Weight",
@ -77,11 +73,9 @@
"settings": "Settings",
"show-zero-balances": "Show Zero Balances",
"size": "Size",
"spanish": "Español",
"spread": "Spread",
"stats": "Stats",
"swap": "Swap",
"theme": "Theme",
"time": "Time",
"token": "Token",
"tokens": "Tokens",

View File

@ -0,0 +1,13 @@
{
"chinese": "简体中文",
"chinese-traditional": "繁體中文",
"dark": "Dark",
"display": "Display",
"english": "English",
"language": "Language",
"light": "Light",
"mango": "Mango",
"orderbook-flash": "Orderbook Flash",
"spanish": "Español",
"theme": "Theme"
}