diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-03-18 13:29:58 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-03-18 13:29:58 +0900 |
| commit | a408226509eedec52fbb24dbb91be0d85838afcb (patch) | |
| tree | f5cf28987f04344786eff9706120e1acdce0ae0c /src/client | |
| parent | Update black.json5 (diff) | |
| download | sharkey-a408226509eedec52fbb24dbb91be0d85838afcb.tar.gz sharkey-a408226509eedec52fbb24dbb91be0d85838afcb.tar.bz2 sharkey-a408226509eedec52fbb24dbb91be0d85838afcb.zip | |
Refactor
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/init.ts | 4 | ||||
| -rw-r--r-- | src/client/app/theme.ts | 60 | ||||
| -rw-r--r-- | src/client/themes/cafe.json5 (renamed from src/client/theme/cafe.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/colorful.json5 (renamed from src/client/theme/colorful.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/dark.json5 (renamed from src/client/theme/dark.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/future.json5 (renamed from src/client/theme/black.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/gray.json5 (renamed from src/client/theme/gray.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/gruvbox-dark.json5 (renamed from src/client/theme/gruvbox-dark.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/halloween.json5 (renamed from src/client/theme/halloween.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/japanese-sushi-set.json5 (renamed from src/client/theme/japanese-sushi-set.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/lavender.json5 (renamed from src/client/theme/pink.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/light.json5 (renamed from src/client/theme/light.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/mauve.json5 (renamed from src/client/theme/mauve.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/monokai.json5 (renamed from src/client/theme/monokai.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/rainy.json5 (renamed from src/client/theme/rainy.json5) | 0 | ||||
| -rw-r--r-- | src/client/themes/tweet-deck.json5 (renamed from src/client/theme/tweet-deck.json5) | 0 |
16 files changed, 32 insertions, 32 deletions
diff --git a/src/client/app/init.ts b/src/client/app/init.ts index 0575992358..4b9f341612 100644 --- a/src/client/app/init.ts +++ b/src/client/app/init.ts @@ -16,11 +16,11 @@ import App from './app.vue'; import checkForUpdate from './common/scripts/check-for-update'; import MiOS from './mios'; import { version, codename, lang, locale } from './config'; -import { builtinThemes, applyTheme, blackTheme } from './theme'; +import { builtinThemes, applyTheme, futureTheme } from './theme'; import Dialog from './common/views/components/dialog.vue'; if (localStorage.getItem('theme') == null) { - applyTheme(blackTheme); + applyTheme(futureTheme); } //#region FontAwesome diff --git a/src/client/app/theme.ts b/src/client/app/theme.ts index ba5eabad2f..0f05f9e64b 100644 --- a/src/client/app/theme.ts +++ b/src/client/app/theme.ts @@ -10,26 +10,26 @@ export type Theme = { props: { [key: string]: string }; }; -export const lightTheme: Theme = require('../theme/light.json5'); -export const darkTheme: Theme = require('../theme/dark.json5'); -export const pinkTheme: Theme = require('../theme/pink.json5'); -export const blackTheme: Theme = require('../theme/black.json5'); -export const halloweenTheme: Theme = require('../theme/halloween.json5'); -export const cafeTheme: Theme = require('../theme/cafe.json5'); -export const japaneseSushiSetTheme: Theme = require('../theme/japanese-sushi-set.json5'); -export const gruvboxDarkTheme: Theme = require('../theme/gruvbox-dark.json5'); -export const monokaiTheme: Theme = require('../theme/monokai.json5'); -export const colorfulTheme: Theme = require('../theme/colorful.json5'); -export const rainyTheme: Theme = require('../theme/rainy.json5'); -export const mauveTheme: Theme = require('../theme/mauve.json5'); -export const grayTheme: Theme = require('../theme/gray.json5'); -export const tweetDeckTheme: Theme = require('../theme/tweet-deck.json5'); +export const lightTheme: Theme = require('../themes/light.json5'); +export const darkTheme: Theme = require('../themes/dark.json5'); +export const lavenderTheme: Theme = require('../themes/lavender.json5'); +export const futureTheme: Theme = require('../themes/future.json5'); +export const halloweenTheme: Theme = require('../themes/halloween.json5'); +export const cafeTheme: Theme = require('../themes/cafe.json5'); +export const japaneseSushiSetTheme: Theme = require('../themes/japanese-sushi-set.json5'); +export const gruvboxDarkTheme: Theme = require('../themes/gruvbox-dark.json5'); +export const monokaiTheme: Theme = require('../themes/monokai.json5'); +export const colorfulTheme: Theme = require('../themes/colorful.json5'); +export const rainyTheme: Theme = require('../themes/rainy.json5'); +export const mauveTheme: Theme = require('../themes/mauve.json5'); +export const grayTheme: Theme = require('../themes/gray.json5'); +export const tweetDeckTheme: Theme = require('../themes/tweet-deck.json5'); export const builtinThemes = [ lightTheme, darkTheme, - pinkTheme, - blackTheme, + lavenderTheme, + futureTheme, halloweenTheme, cafeTheme, japaneseSushiSetTheme, @@ -42,41 +42,41 @@ export const builtinThemes = [ tweetDeckTheme, ]; -export function applyTheme(theme: Theme, persisted = true) { - document.documentElement.classList.add('changing-theme'); +export function applyTheme(themes: Theme, persisted = true) { + document.documentElement.classList.add('changing-themes'); setTimeout(() => { - document.documentElement.classList.remove('changing-theme'); + document.documentElement.classList.remove('changing-themes'); }, 1000); // Deep copy - const _theme = JSON.parse(JSON.stringify(theme)); + const _themes = JSON.parse(JSON.stringify(themes)); - if (_theme.base) { - const base = [lightTheme, darkTheme].find(x => x.id == _theme.base); - _theme.vars = Object.assign({}, base.vars, _theme.vars); - _theme.props = Object.assign({}, base.props, _theme.props); + if (_themes.base) { + const base = [lightTheme, darkTheme].find(x => x.id == _themes.base); + _themes.vars = Object.assign({}, base.vars, _themes.vars); + _themes.props = Object.assign({}, base.props, _themes.props); } - const props = compile(_theme); + const props = compile(_themes); for (const [k, v] of Object.entries(props)) { document.documentElement.style.setProperty(`--${k}`, v.toString()); } if (persisted) { - localStorage.setItem('theme', JSON.stringify(props)); + localStorage.setItem('themes', JSON.stringify(props)); } } -function compile(theme: Theme): { [key: string]: string } { +function compile(themes: Theme): { [key: string]: string } { function getColor(code: string): tinycolor.Instance { // ref if (code[0] == '@') { - return getColor(theme.props[code.substr(1)]); + return getColor(themes.props[code.substr(1)]); } if (code[0] == '$') { - return getColor(theme.vars[code.substr(1)]); + return getColor(themes.vars[code.substr(1)]); } // func @@ -98,7 +98,7 @@ function compile(theme: Theme): { [key: string]: string } { const props = {}; - for (const [k, v] of Object.entries(theme.props)) { + for (const [k, v] of Object.entries(themes.props)) { props[k] = genValue(getColor(v)); } diff --git a/src/client/theme/cafe.json5 b/src/client/themes/cafe.json5 index 084f69299c..084f69299c 100644 --- a/src/client/theme/cafe.json5 +++ b/src/client/themes/cafe.json5 diff --git a/src/client/theme/colorful.json5 b/src/client/themes/colorful.json5 index 5b7441e1cf..5b7441e1cf 100644 --- a/src/client/theme/colorful.json5 +++ b/src/client/themes/colorful.json5 diff --git a/src/client/theme/dark.json5 b/src/client/themes/dark.json5 index 13c55999e5..13c55999e5 100644 --- a/src/client/theme/dark.json5 +++ b/src/client/themes/dark.json5 diff --git a/src/client/theme/black.json5 b/src/client/themes/future.json5 index 7b36d4e50e..7b36d4e50e 100644 --- a/src/client/theme/black.json5 +++ b/src/client/themes/future.json5 diff --git a/src/client/theme/gray.json5 b/src/client/themes/gray.json5 index 59494f278a..59494f278a 100644 --- a/src/client/theme/gray.json5 +++ b/src/client/themes/gray.json5 diff --git a/src/client/theme/gruvbox-dark.json5 b/src/client/themes/gruvbox-dark.json5 index 2d03153190..2d03153190 100644 --- a/src/client/theme/gruvbox-dark.json5 +++ b/src/client/themes/gruvbox-dark.json5 diff --git a/src/client/theme/halloween.json5 b/src/client/themes/halloween.json5 index 608105903a..608105903a 100644 --- a/src/client/theme/halloween.json5 +++ b/src/client/themes/halloween.json5 diff --git a/src/client/theme/japanese-sushi-set.json5 b/src/client/themes/japanese-sushi-set.json5 index 94edecca52..94edecca52 100644 --- a/src/client/theme/japanese-sushi-set.json5 +++ b/src/client/themes/japanese-sushi-set.json5 diff --git a/src/client/theme/pink.json5 b/src/client/themes/lavender.json5 index e3078ad516..e3078ad516 100644 --- a/src/client/theme/pink.json5 +++ b/src/client/themes/lavender.json5 diff --git a/src/client/theme/light.json5 b/src/client/themes/light.json5 index 65bd3b1216..65bd3b1216 100644 --- a/src/client/theme/light.json5 +++ b/src/client/themes/light.json5 diff --git a/src/client/theme/mauve.json5 b/src/client/themes/mauve.json5 index b2ec28b445..b2ec28b445 100644 --- a/src/client/theme/mauve.json5 +++ b/src/client/themes/mauve.json5 diff --git a/src/client/theme/monokai.json5 b/src/client/themes/monokai.json5 index 1ecd68730e..1ecd68730e 100644 --- a/src/client/theme/monokai.json5 +++ b/src/client/themes/monokai.json5 diff --git a/src/client/theme/rainy.json5 b/src/client/themes/rainy.json5 index 26ff3a6c86..26ff3a6c86 100644 --- a/src/client/theme/rainy.json5 +++ b/src/client/themes/rainy.json5 diff --git a/src/client/theme/tweet-deck.json5 b/src/client/themes/tweet-deck.json5 index aac9e3d009..aac9e3d009 100644 --- a/src/client/theme/tweet-deck.json5 +++ b/src/client/themes/tweet-deck.json5 |