Skip to content

Commit

Permalink
feat: dark theme and UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Esya committed May 2, 2021
1 parent c810319 commit 0716223
Show file tree
Hide file tree
Showing 37 changed files with 546 additions and 339 deletions.
5 changes: 2 additions & 3 deletions src/app/__tests__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ exports[`<App /> should render and match the snapshot 1`] = `
/>
</Helmet>
<Box
background="background-back"
direction="row-responsive"
fill={true}
>
<Navigation />
<Box
flex={true}
>
<Styled(Main)
background="light-2"
>
<Styled(Main)>
<Toolbar />
<TransitionGroup
childFactory={[Function]}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/MnemonicGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let noSelect: React.CSSProperties = {

function MnemonicWord(props: WordProp) {
return (
<Box background="light-1" margin="xsmall" direction="row" pad="xsmall">
<Box background="background-contrast" margin="xsmall" direction="row" pad="xsmall">
<Box pad={{ right: 'small' }}>
<Text style={noSelect}>{props.id}.</Text>
</Box>
Expand Down
25 changes: 15 additions & 10 deletions src/app/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { NavLink, useHistory, useLocation } from 'react-router-dom'
import { ThemeSwitcher } from '../ThemeSwitcher'

interface SidebarButtonProps extends ButtonType {
secure?: boolean
route?: string
label: string
}

const SidebarButton = ({ secure, icon, label, route, ...rest }: SidebarButtonProps) => {
export const SidebarButton = ({ secure, icon, label, route, ...rest }: SidebarButtonProps) => {
const status = useSelector(selectStatus)
const size = useContext(ResponsiveContext)
const location = useLocation()
Expand All @@ -41,7 +42,7 @@ const SidebarButton = ({ secure, icon, label, route, ...rest }: SidebarButtonPro
<Box
pad={{ vertical: 'small', right: 'medium' }}
margin="none"
background={isActive ? 'brand' : 'neutral-2'}
background={isActive ? 'background-oasis-blue' : 'component-sidebar'}
round={{ size: 'medium', corner: 'right' }}
>
{label}
Expand All @@ -52,7 +53,8 @@ const SidebarButton = ({ secure, icon, label, route, ...rest }: SidebarButtonPro
<Tip content={isMediumSize ? tooltip : undefined} dropProps={{ align: { left: 'right' } }} plain={true}>
<Box
pad={{ vertical: 'small', left: isMediumSize ? 'none' : 'medium' }}
background={isActive ? 'brand' : undefined}
background={isActive ? 'background-oasis-blue' : undefined}
responsive={false}
>
<Button
a11yTitle={label}
Expand Down Expand Up @@ -100,7 +102,7 @@ const SidebarHeader = (props: SidebarHeaderProps) => {
direction="row"
margin={{ bottom: size !== 'small' ? 'medium' : undefined }}
pad="medium"
alignSelf={size !== 'medium' ? undefined : 'center'}
alignSelf={size === 'large' ? undefined : 'center'}
>
<Avatar src={src} size={sizeLogo[size]} />
{size !== 'medium' && <Text>Oasis Wallet</Text>}
Expand All @@ -124,9 +126,10 @@ const SidebarFooter = (props: SidebarFooterProps) => {
}

return (
<Nav gap="medium">
<Nav gap="small">
<ThemeSwitcher />
<SidebarButton icon={<Logout />} label={t('menu.closeWallet')} secure={true} onClick={() => logout()} />
<Box pad={{ horizontal: 'small' }} align="center">
<Box pad={{ horizontal: 'small', top: 'small' }} align="center">
<Menu
hoverIndicator={false}
dropProps={{ align: { bottom: 'bottom', left: 'left' } }}
Expand All @@ -135,7 +138,7 @@ const SidebarFooter = (props: SidebarFooterProps) => {
{ label: 'English', onClick: () => setLanguage('en') },
]}
>
<Box direction="row" round="4px" border={{ color: 'light-2' }}>
<Box direction="row" round="4px" border={{ size: '1px' }}>
<Box pad="small">
<Language />
</Box>
Expand Down Expand Up @@ -189,11 +192,13 @@ export function Sidebar() {

return (
<GSidebar
background="neutral-2"
background="component-sidebar"
header={<SidebarHeader size={size} />}
footer={<SidebarFooter size={size} />}
pad={{ left: 'none', right: 'none', vertical: 'medium' }}
gap="small"
width={size === 'medium' ? undefined : '220px'}
border={{ side: 'end' }}
// direction={size === 'small' ? 'row' : undefined}
// height={size === 'small' ? '64px' : undefined}
>
Expand All @@ -218,11 +223,11 @@ export function Navigation() {
return (
<>
{size === 'small' && (
<Box background="neutral-2" height="64px" fill="horizontal" direction="row" justify="between">
<Box background="component-sidebar" height="64px" fill="horizontal" direction="row">
<Button onClick={() => toggleSidebar()} icon={<MenuIcon />} focusIndicator={false} />
<Box justify="center">
<SidebarHeader size="small" />
</Box>
<Button onClick={() => toggleSidebar()} icon={<MenuIcon />} focusIndicator={false} />
</Box>
)}
{size === 'small' && sidebarVisible && (
Expand Down
41 changes: 41 additions & 0 deletions src/app/components/ThemeSwitcher/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
*
* ThemeSwitcher
*
*/
import { Moon, Sun } from 'grommet-icons/icons'
import React, { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { useThemeSlice } from 'styles/theme/slice'
import { selectTheme } from 'styles/theme/slice/selectors'

import { SidebarButton } from '../Sidebar'

interface Props {}

export const ThemeSwitcher = memo((props: Props) => {
const { t } = useTranslation()
const themeActions = useThemeSlice().actions
const theme = useSelector(selectTheme)
const dispatch = useDispatch()

const modes = {
light: {
icon: <Moon />,
label: t('theme.darkMode', 'Dark mode'),
},
dark: {
icon: <Sun />,
label: t('theme.ligthMode', 'Light mode'),
},
}

const currentMode = modes[theme]
const switchTheme = () => {
const newTheme = theme === 'dark' ? 'light' : 'dark'
dispatch(themeActions.changeTheme(newTheme))
}

return <SidebarButton icon={currentMode.icon} label={currentMode.label} onClick={switchTheme} />
})
13 changes: 9 additions & 4 deletions src/app/components/Toolbar/Features/AccountSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,28 @@ export const AccountSelector = memo((props: Props) => {
onClickOutside={props.closeHandler}
onEsc={props.closeHandler}
animation="slide"
background="light-2"
background="background-front"
modal
>
<Box background="light-2" pad="small" margin="medium" width={size === 'small' ? 'auto' : '660px'}>
<Box pad={{ vertical: 'small' }} margin="medium" width={size === 'small' ? 'auto' : '700px'}>
<Heading size="1" margin={{ vertical: 'small' }}>
{t('toolbar.wallets.switchOtherWallet', 'Switch to another wallet')}
</Heading>
<Box
gap="small"
pad={{ vertical: 'medium' }}
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height={{ max: '400px' }}
>
{accounts}
</Box>
<Box align="end" pad={{ top: 'medium' }}>
<Button primary style={{ borderRadius: '4px' }} label="Close" onClick={props.closeHandler} />
<Button
primary
style={{ borderRadius: '4px' }}
label={t('toolbar.wallets.close', 'Close')}
onClick={props.closeHandler}
/>
</Box>
</Box>
</Layer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
*/
import { ShortAddress } from 'app/components/ShortAddress'
import { selectAddress } from 'app/state/wallet/selectors'
import { Box, Button, Text } from 'grommet'
import { Box, Button, ResponsiveContext, Text } from 'grommet'
import { List } from 'grommet-icons/icons'
import React, { memo, useState } from 'react'
import React, { memo, useContext, useState } from 'react'
import { useSelector } from 'react-redux'

import { AccountSelector } from '../AccountSelector'

interface Props {}

export const AccountSelectorButton = memo((props: Props) => {
const size = useContext(ResponsiveContext)
const [layerVisibility, setLayerVisibility] = useState(false)
const address = useSelector(selectAddress)

Expand All @@ -23,9 +24,11 @@ export const AccountSelectorButton = memo((props: Props) => {
<Button onClick={() => setLayerVisibility(true)}>
<Box direction="row" gap="small" pad="small" responsive={false}>
<List />
<Text>
<ShortAddress address={address} />
</Text>
{size !== 'small' && (
<Text>
<ShortAddress address={address} />
</Text>
)}
</Box>
</Button>
{layerVisibility && <AccountSelector closeHandler={() => setLayerVisibility(false)} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ exports[`<NetworkSelector /> should match snapshot 1`] = `
line-height: 24px;
}
@media only screen and (max-width:768px) {
.c1 {
padding: 6px;
}
}
@media only screen and (max-width:768px) {
.c3 {
width: 6px;
}
}
<button
aria-label="Open Menu"
class="c0"
Expand Down
10 changes: 6 additions & 4 deletions src/app/components/Toolbar/Features/NetworkSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
* NetworkSelector
*
*/
import { Menu, Box, Text } from 'grommet'
import { Menu, Box, Text, ResponsiveContext } from 'grommet'
import { Network } from 'grommet-icons/icons'
import React, { memo } from 'react'
import React, { memo, useContext } from 'react'

interface Props {}

export const NetworkSelector = memo((props: Props) => {
const size = useContext(ResponsiveContext)

return (
<Menu
dropProps={{
Expand All @@ -22,9 +24,9 @@ export const NetworkSelector = memo((props: Props) => {
]}
fill
>
<Box direction="row" gap="small" pad="small">
<Box direction="row" gap="small" pad="small" responsive={false}>
<Network />
<Text>Testnet</Text>
{size !== 'small' && <Text>Testnet</Text>}
</Box>
</Menu>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exports[`<SearchAddress /> should match snapshot 1`] = `
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
border: solid 2px #DADADA;
border: solid 1px rgba(0,0,0,0.33);
min-width: 0;
min-height: 0;
-webkit-flex-direction: row;
Expand All @@ -62,10 +62,21 @@ exports[`<SearchAddress /> should match snapshot 1`] = `
}
.c3 {
margin: 36px;
font-size: 18px;
line-height: 24px;
color: #DADADA;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
box-sizing: border-box;
max-width: 100%;
margin-left: 36px;
min-width: 0;
min-height: 0;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}
.c6 {
Expand Down Expand Up @@ -176,7 +187,13 @@ exports[`<SearchAddress /> should match snapshot 1`] = `
@media only screen and (max-width:768px) {
.c0 {
border: solid 2px #DADADA;
border: solid 1px rgba(0,0,0,0.33);
}
}
@media only screen and (max-width:768px) {
.c3 {
margin-left: 36px;
}
}
Expand All @@ -190,11 +207,12 @@ exports[`<SearchAddress /> should match snapshot 1`] = `
<div
class="c2"
>
<span
<div
class="c3"
style="text-overflow: ellipsis;"
>
toolbar.search.placeholder
</span>
</div>
</div>
<div
class="c4"
Expand Down
11 changes: 8 additions & 3 deletions src/app/components/Toolbar/Features/SearchAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const SearchAddress = memo((props: Props) => {
<Form onSubmit={() => goToAddress()}>
<Box
round="30px"
border={{ size: '2px', color: 'light-4' }}
border={{ size: '1px' }}
fill="vertical"
justify="center"
align="center"
Expand All @@ -60,9 +60,14 @@ export const SearchAddress = memo((props: Props) => {
updatePayload(e.target.value)
}}
placeholder={
<Text margin="36px" color="light-4">
<Box
margin={{ left: '36px' }}
max-height="30px"
style={{ textOverflow: 'ellipsis' }}
flex="shrink"
>
{t('toolbar.search.placeholder', 'Search for an account or a validator')}
</Text>
</Box>
}
/>
{searchPayload && <Button icon={<FormClose />} onClick={() => updatePayload('')} />}
Expand Down
Loading

0 comments on commit 0716223

Please sign in to comment.