Skip to content
23 changes: 17 additions & 6 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Router from './Router'
import GlobalStyle from './GlobalStyle'
import { ThemeProvider } from 'styled-components'
import { defaultTheme } from '../lib/styled/themes/default'
import { darkTheme } from '../lib/styled/themes/dark'
import { lightTheme } from '../lib/styled/themes/light'
import { sepiaTheme } from '../lib/styled/themes/sepia'
import { StyledAppContainer } from './styled'
import ContextMenu from './ContextMenu'
import Dialog from './Dialog/Dialog'
Expand All @@ -23,8 +26,7 @@ const App = () => {
useEffect(() => {
initialize()
}, [initialize])
const { toggleClosed } = usePreferences()

const { toggleClosed, preferences } = usePreferences()
const keyboardHandler = useMemo(() => {
return (event: KeyboardEvent) => {
switch (event.key) {
Expand All @@ -36,7 +38,6 @@ const App = () => {
}
}, [toggleClosed])
useGlobalKeyDownHandler(keyboardHandler)

const { generalStatus, setGeneralStatus } = useGeneralStatus()
const updateSideBarWidth = useCallback(
(leftWidth: number) => {
Expand All @@ -46,9 +47,8 @@ const App = () => {
},
[setGeneralStatus]
)

return (
<ThemeProvider theme={defaultTheme}>
<ThemeProvider theme={selectTheme(preferences['general.theme'])}>
<StyledAppContainer
onDrop={(event: React.DragEvent) => {
event.preventDefault()
Expand All @@ -74,5 +74,16 @@ const App = () => {
</ThemeProvider>
)
}

function selectTheme(theme: string) {
switch (theme) {
case 'dark':
return darkTheme
case 'light':
return lightTheme
case 'sepia':
return sepiaTheme
default:
return defaultTheme
}
}
export default App
5 changes: 3 additions & 2 deletions src/components/NotePage/NoteList/NoteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Icon from '../../atoms/Icon'
import {
borderBottom,
inputStyle,
uiTextColor
iconColor
} from '../../../lib/styled/styleFunctions'

export const StyledNoteListContainer = styled.div`
Expand Down Expand Up @@ -48,6 +48,7 @@ export const StyledNoteListContainer = styled.div`
font-size: 20px;
z-index: 0;
pointer-events: none;
${iconColor}
}
.input {
position: relative;
Expand All @@ -64,7 +65,7 @@ export const StyledNoteListContainer = styled.div`
font-size: 24px;
background: transparent;
border: none;
${uiTextColor}
${iconColor}
}
`

Expand Down
2 changes: 1 addition & 1 deletion src/components/PreferencesModal/EditorTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const EditorTab = () => {
value={fontSize}
onChange={updateFontSize}
/>{' '}
px
&emsp;px
</SectionControl>
</Section>
<Section>
Expand Down
4 changes: 1 addition & 3 deletions src/components/PreferencesModal/GeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ const GeneralTab = () => {
<option value='auto'>{t('preferences.auto')}</option>
<option value='light'>{t('preferences.light')}</option>
<option value='dark'>{t('preferences.dark')}</option>
<option value='solarized-dark'>
{t('preferences.solarizedDark')}
</option>
<option value='sepia'>{t('preferences.sepia')}</option>
</SectionSelect>
</SectionControl>
</Section>
Expand Down
2 changes: 2 additions & 0 deletions src/components/PreferencesModal/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const SectionControl = styled.div`
export const SectionSelect = styled.select`
${selectStyle}
padding: 0 16px;
width: 200px;
height: 40px;
border-radius: 2px;

Expand Down Expand Up @@ -79,6 +80,7 @@ export const SectionSecondaryButton = styled.button`
export const SectionInput = styled.input`
${inputStyle}
padding: 0 16px;
width: 200px;
height: 40px;
border-radius: 2px;
`
Expand Down
10 changes: 7 additions & 3 deletions src/components/SideNavigator/ControlButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import styled from '../../lib/styled'
import Icon from '../atoms/Icon'
import { uiTextColor } from '../../lib/styled/styleFunctions'
import { sideBarTextColor, sideBarSecondaryTextColor } from '../../lib/styled/styleFunctions'

const StyledButton = styled.button`
width: 30px;
Expand All @@ -13,9 +13,13 @@ const StyledButton = styled.button`
top: 2px;
font-size: 20px;
cursor: pointer;
${uiTextColor}
&:focus {
${sideBarSecondaryTextColor}
&:hover, &:active, &:focus {
box-shadow: none;
${sideBarTextColor}
}
svg {
vertical-align: middle;
}
`

Expand Down
12 changes: 6 additions & 6 deletions src/components/SideNavigator/SideNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { useDialog, DialogIconTypes } from '../../lib/dialog'
import { useContextMenu, MenuTypes } from '../../lib/contextMenu'
import { usePreferences } from '../../lib/preferences'
import {
backgroundColor,
iconColor,
textColor,
sideBarBackgroundColor,
sideBarTextColor,
sideBarSecondaryTextColor,
uiTextColor
} from '../../lib/styled/styleFunctions'
import SideNavigatorItem from './SideNavigatorItem'
Expand All @@ -35,14 +35,14 @@ const Description = styled.nav`
margin-left: 5px;
margin-bottom: 10px;
font-size: 18px;
color: ${textColor};
${sideBarTextColor}
`

const StyledSideNavContainer = styled.nav`
display: flex;
flex-direction: column;
height: 100%;
${backgroundColor}
${sideBarBackgroundColor}
.topControl {
height: 50px;
display: flex;
Expand All @@ -54,7 +54,7 @@ const StyledSideNavContainer = styled.nav`
height: 50px;
background-color: transparent;
border: none;
${iconColor}
${sideBarSecondaryTextColor}
font-size: 24px;
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/SideNavigator/SideNavigatorItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import styled from '../../lib/styled'
import Icon from '../atoms/Icon'
import { mdiChevronDown, mdiChevronRight } from '@mdi/js'
import {
uiTextColor,
sideBarTextColor,
sideBarSecondaryTextColor,
activeBackgroundColor
} from '../../lib/styled/styleFunctions'
import MdiIcon from '@mdi/react'
Expand Down Expand Up @@ -40,7 +41,7 @@ const FoldButton = styled.button`
margin-right: 3px;
border-radius: 2px;
top: 2px;
${uiTextColor}
${sideBarSecondaryTextColor}
&:focus {
box-shadow: none;
}
Expand All @@ -54,16 +55,17 @@ const ClickableContainer = styled.button`
align-items: center;
width: 100%;

color: ${({ theme }) => theme.uiTextColor};
${sideBarTextColor}
&:hover,
&:focus,
&:active,
&.active {
color: ${({ theme }) => theme.activeUiTextColor};
${sideBarTextColor}
}

.icon {
margin-right: 4px;
${sideBarSecondaryTextColor}
}
`

Expand Down
2 changes: 1 addition & 1 deletion src/lib/i18n/enUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
'preferences.auto': 'Auto',
'preferences.light': 'Light',
'preferences.dark': 'Dark',
'preferences.solarizedDark': 'Solarized Dark',
'preferences.sepia': 'Sepia',
'preferences.noteSorting': 'Note Sorting',
'preferences.dateUpdated': 'Date Updated',
'preferences.dateCreated': 'Date Created',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
'preferences.auto': '自動',
'preferences.light': 'ライト',
'preferences.dark': 'ダーク',
'preferences.solarizedDark': 'Solarized Dark',
'preferences.sepia': 'セピア',
'preferences.noteSorting': 'ノート整列',
'preferences.dateUpdated': 'アプデート順',
'preferences.dateCreated': '生成順',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/preferences/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { User } from '../accounts'

export type GeneralThemeOptions = 'auto' | 'light' | 'dark' | 'solarized-dark'
export type GeneralThemeOptions = 'auto' | 'light' | 'dark' | 'sepia'
export type GeneralLanguageOptions = 'en-US' | 'ja'
export type GeneralNoteSortingOptions =
| 'date-updated'
Expand Down
13 changes: 11 additions & 2 deletions src/lib/styled/styleFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const secondaryBackgroundColor = ({ theme }: StyledProps) =>
export const activeBackgroundColor = ({ theme }: StyledProps) =>
`background-color: ${theme.activeBackgroundColor};`

export const sideBarBackgroundColor = ({ theme }: StyledProps) =>
`background-color: ${theme.sideBarBackgroundColor};`

export const iconColor = ({ theme }: StyledProps) => `color: ${theme.iconColor};
&:hover,
&:focus {
Expand Down Expand Up @@ -46,6 +49,12 @@ transition: 200ms color;
color: ${theme.disabledUiTextColor};
}`

export const sideBarTextColor = ({ theme }: StyledProps) =>
`color: ${theme.sideBarTextColor};`

export const sideBarSecondaryTextColor = ({ theme }: StyledProps) =>
`color: ${theme.sideBarSecondaryTextColor};`

export const borderColor = ({ theme }: StyledProps) =>
`border-color: ${theme.borderColor};`

Expand Down Expand Up @@ -79,7 +88,7 @@ color: ${theme.textColor};

export const primaryButtonStyle = ({ theme }: StyledProps) => `border: none;
background-color: ${theme.primaryColor};
color: ${theme.textColor};
color: ${theme.primaryButtonLabelColor};
font-size: 13px;
&:focus {
box-shadow: 0 0 0 2px ${theme.primaryColor};
Expand All @@ -88,7 +97,7 @@ font-size: 13px;

export const secondaryButtonStyle = ({ theme }: StyledProps) => `border: none;
background-color: ${theme.inputBackground};
color: ${theme.textColor};
color: ${theme.secondaryButtonLabelColor};
font-size: 13px;
&:focus {
box-shadow: 0 0 0 2px ${theme.primaryColor};
Expand Down
58 changes: 58 additions & 0 deletions src/lib/styled/themes/dark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { BaseTheme } from './types'

const base1Color = '#2c2d30'
const base2Color = '#1e2022'
const primaryColor = '#03C588'

const dark26Color = 'rgba(0,0,0,0.26)'
const light70Color = 'rgba(255,255,255,0.7)'
const light30Color = 'rgba(255,255,255,0.3)'
const light12Color = 'rgba(255,255,255,0.12)'
const light100Color = '#FFF'

export const darkTheme: BaseTheme = {
colors: {
text: light70Color,
deemedText: light30Color,
inverseText: light100Color,
background: light100Color,
alternativeBackground: light12Color,
active: primaryColor,
border: dark26Color
},
fontSize: 15,
fontFamily: `-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Fira sans', Roboto, Helvetica,
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`,

// General
textColor: light100Color,
uiTextColor: light70Color,
activeUiTextColor: light100Color,
disabledUiTextColor: light30Color,

primaryColor: primaryColor,
borderColor: dark26Color,
iconColor: light30Color,
activeIconColor: light70Color,
backgroundColor: base1Color,
secondaryBackgroundColor: base2Color,
activeBackgroundColor: base2Color,
shadow: '0 3px 5px rgba(0,0,0,0.1)',

scrollBarTrackColor: base2Color,
scrollBarThumbColor: light12Color,

// SideBar
sideBarBackgroundColor: base1Color,
sideBarTextColor: light70Color,
sideBarSecondaryTextColor: light30Color,

// Button
primaryButtonLabelColor: light100Color,
primaryButtonBackgroundColor: primaryColor,
secondaryButtonLabelColor: light100Color,
secondaryButtonBackgroundColor: 'transparent',

// Input
inputBackground: light12Color
}
Loading