From 904114740b2f87743c332e029a4c6817ebb9e17d Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 26 Sep 2018 20:19:35 +0900 Subject: [PATCH] wip --- package.json | 2 + src/client/app/app.styl | 8 +- src/client/app/common/scripts/theme.ts | 67 +++++++--------- .../common/views/components/autocomplete.vue | 6 +- .../views/components/connect-failed.vue | 12 +-- .../app/common/views/components/forkit.vue | 6 +- .../components/games/reversi/reversi.game.vue | 10 +-- .../games/reversi/reversi.index.vue | 4 +- .../components/games/reversi/reversi.room.vue | 4 +- .../components/games/reversi/reversi.vue | 2 +- .../app/common/views/components/menu.vue | 10 +-- .../views/components/messaging-room.form.vue | 10 +-- .../components/messaging-room.message.vue | 4 +- .../views/components/messaging-room.vue | 10 +-- .../app/common/views/components/messaging.vue | 10 +-- .../common/views/components/note-header.vue | 2 +- .../common/views/components/poll-editor.vue | 22 ++--- .../app/common/views/components/poll.vue | 4 +- .../views/components/reaction-picker.vue | 6 +- .../app/common/views/components/signin.vue | 2 +- .../app/common/views/components/signup.vue | 2 +- .../app/common/views/components/switch.vue | 16 ++-- .../app/common/views/components/ui/button.vue | 16 ++-- .../app/common/views/components/ui/card.vue | 2 +- .../app/common/views/components/ui/form.vue | 2 +- .../views/components/ui/form/button.vue | 28 +++---- .../common/views/components/ui/form/radio.vue | 8 +- .../app/common/views/components/ui/input.vue | 6 +- .../app/common/views/components/ui/radio.vue | 6 +- .../app/common/views/components/ui/select.vue | 6 +- .../app/common/views/components/ui/switch.vue | 8 +- .../common/views/components/ui/textarea.vue | 6 +- .../app/common/views/components/uploader.vue | 30 +++---- .../views/components/visibility-chooser.vue | 6 +- src/client/app/common/views/pages/follow.vue | 22 ++--- .../app/common/views/widgets/analog-clock.vue | 2 +- .../app/common/views/widgets/calendar.vue | 4 +- src/client/app/common/views/widgets/memo.vue | 10 +-- src/client/app/desktop/ui.styl | 36 ++++----- .../app/desktop/views/components/calendar.vue | 10 +-- .../app/desktop/views/components/charts.vue | 4 +- .../choose-file-from-drive-window.vue | 32 ++++---- .../choose-folder-from-drive-window.vue | 20 ++--- .../views/components/context-menu.menu.vue | 12 +-- .../desktop/views/components/crop-window.vue | 24 +++--- .../app/desktop/views/components/dialog.vue | 10 +-- .../desktop/views/components/drive.file.vue | 12 +-- .../desktop/views/components/drive.folder.vue | 14 ++-- .../app/desktop/views/components/drive.vue | 8 +- .../views/components/follow-button.vue | 18 ++--- .../app/desktop/views/components/home.vue | 10 +-- .../desktop/views/components/input-dialog.vue | 30 +++---- .../desktop/views/components/note-detail.vue | 2 +- .../desktop/views/components/notes.note.vue | 8 +- .../app/desktop/views/components/notes.vue | 4 +- .../desktop/views/components/post-form.vue | 80 +++++++++---------- .../views/components/progress-dialog.vue | 22 ++--- .../desktop/views/components/renote-form.vue | 4 +- .../app/desktop/views/components/settings.vue | 4 +- .../views/components/timeline.core.vue | 2 +- .../app/desktop/views/components/timeline.vue | 12 +-- .../views/components/ui.header.account.vue | 12 +-- .../views/components/ui.header.nav.vue | 6 +- .../components/ui.header.notifications.vue | 4 +- .../views/components/ui.header.post.vue | 10 +-- .../views/components/ui.header.search.vue | 4 +- .../desktop/views/components/user-preview.vue | 4 +- .../desktop/views/components/users-list.vue | 6 +- .../app/desktop/views/components/window.vue | 6 +- .../views/pages/admin/admin.announcements.vue | 2 +- .../views/pages/admin/admin.dashboard.vue | 4 +- .../views/pages/admin/admin.hashtags.vue | 2 +- .../views/pages/admin/admin.suspend-user.vue | 2 +- .../pages/admin/admin.unsuspend-user.vue | 2 +- .../views/pages/admin/admin.unverify-user.vue | 2 +- .../views/pages/admin/admin.verify-user.vue | 2 +- .../app/desktop/views/pages/admin/admin.vue | 4 +- .../desktop/views/pages/deck/deck.column.vue | 8 +- .../desktop/views/pages/deck/deck.note.vue | 8 +- .../desktop/views/pages/deck/deck.notes.vue | 2 +- .../app/desktop/views/pages/deck/deck.vue | 2 +- .../views/pages/deck/deck.widgets-column.vue | 2 +- .../app/desktop/views/pages/selectdrive.vue | 32 ++++---- .../app/desktop/views/pages/stats/stats.vue | 4 +- .../desktop/views/pages/user/user.header.vue | 4 +- .../views/pages/user/user.timeline.vue | 6 +- .../app/desktop/views/pages/welcome.vue | 6 +- .../app/desktop/views/widgets/post-form.vue | 10 +-- .../app/mobile/views/components/dialog.vue | 10 +-- .../mobile/views/components/drive.file.vue | 4 +- .../mobile/views/components/follow-button.vue | 22 ++--- .../mobile/views/components/mute-button.vue | 24 +++--- .../mobile/views/components/note-detail.vue | 4 +- .../app/mobile/views/components/note.vue | 8 +- .../app/mobile/views/components/notes.vue | 2 +- .../app/mobile/views/components/post-form.vue | 6 +- .../app/mobile/views/components/ui.header.vue | 6 +- .../app/mobile/views/components/ui.nav.vue | 10 +-- .../mobile/views/components/users-list.vue | 6 +- .../app/mobile/views/pages/favorites.vue | 2 +- src/client/app/mobile/views/pages/home.vue | 12 +-- .../app/mobile/views/pages/notifications.vue | 2 +- .../views/pages/received-follow-requests.vue | 2 +- .../app/mobile/views/pages/user-list.vue | 2 +- .../app/mobile/views/pages/user-lists.vue | 2 +- src/client/app/mobile/views/pages/user.vue | 6 +- src/client/const.styl | 4 - src/client/style.styl | 14 ++-- src/client/theme/dark.json | 1 + src/client/theme/light.json | 1 + 110 files changed, 529 insertions(+), 536 deletions(-) delete mode 100644 src/client/const.styl diff --git a/package.json b/package.json index 1b786d1a38..a3e3b56be4 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "@types/single-line-log": "1.1.0", "@types/speakeasy": "2.0.2", "@types/systeminformation": "3.23.0", + "@types/tinycolor2": "1.4.1", "@types/tmp": "0.0.33", "@types/uuid": "3.4.4", "@types/webpack": "4.4.12", @@ -194,6 +195,7 @@ "systeminformation": "3.45.6", "syuilo-password-strength": "0.0.1", "textarea-caret": "3.1.0", + "tinycolor2": "1.4.1", "tmp": "0.0.33", "ts-loader": "4.4.1", "ts-node": "7.0.1", diff --git a/src/client/app/app.styl b/src/client/app/app.styl index 3911f83a61..2f0095944c 100644 --- a/src/client/app/app.styl +++ b/src/client/app/app.styl @@ -27,7 +27,7 @@ body z-index 65536 .bar - background $theme-color + background var(--primary) position fixed z-index 65537 @@ -44,7 +44,7 @@ body right 0px width 100px height 100% - box-shadow 0 0 10px $theme-color, 0 0 5px $theme-color + box-shadow 0 0 10px var(--primary), 0 0 5px var(--primary) opacity 1 transform rotate(3deg) translate(0px, -4px) @@ -64,8 +64,8 @@ body box-sizing border-box border solid 2px transparent - border-top-color $theme-color - border-left-color $theme-color + border-top-color var(--primary) + border-left-color var(--primary) border-radius 50% animation progress-spinner 400ms linear infinite diff --git a/src/client/app/common/scripts/theme.ts b/src/client/app/common/scripts/theme.ts index 7fbac7f574..2cad547c01 100644 --- a/src/client/app/common/scripts/theme.ts +++ b/src/client/app/common/scripts/theme.ts @@ -1,3 +1,5 @@ +import * as tinycolor from 'tinycolor2'; + export default function(theme: { [key: string]: string }) { const props = compile(theme); @@ -10,56 +12,47 @@ export default function(theme: { [key: string]: string }) { } function compile(theme: { [key: string]: string }): { [key: string]: string } { - function getRgba(code: string): number[] { + function getColor(code: string): tinycolor.Instance { // ref if (code[0] == '@') { - return getRgba(theme[code.substr(1)]); + return getColor(theme[code.substr(1)]); } - let m; - - //#region #RGB - m = code.match(/^#([0-9a-f]{3})$/i); - if (m) { - return [ - parseInt(m[1].charAt(0), 16) * 0x11, - parseInt(m[1].charAt(1), 16) * 0x11, - parseInt(m[1].charAt(2), 16) * 0x11, - 255 - ]; - } - //#endregion - - //#region #RRGGBB - m = code.match(/^#([0-9a-f]{6})$/i); - if (m) { - return [ - parseInt(m[1].substr(0, 2), 16), - parseInt(m[1].substr(2, 2), 16), - parseInt(m[1].substr(4, 2), 16), - 255 - ]; - } - //#endregion - - return [0, 0, 0, 255]; + return tinycolor(code); } const props = {}; Object.entries(theme).forEach(([k, v]) => { if (k == 'meta') return; - const [r, g, b, a] = getRgba(v); - props[k] = genValue(r, g, b, a); - props[`${k}-r`] = r; - props[`${k}-g`] = g; - props[`${k}-b`] = b; - props[`${k}-a`] = a; + const c = getColor(v); + props[k] = genValue(c); + props[`${k}-r`] = c.toRgb().r; + props[`${k}-g`] = c.toRgb().g; + props[`${k}-b`] = c.toRgb().b; + props[`${k}-a`] = c.toRgb().a; }); + const primary = getColor(props['primary']); + + for (let i = 1; i < 10; i++) { + const color = primary.clone().setAlpha(i / 10); + props['primaryAlpha0' + i] = genValue(color); + } + + for (let i = 1; i < 100; i++) { + const color = primary.clone().lighten(i); + props['primaryLighten' + i] = genValue(color); + } + + for (let i = 1; i < 100; i++) { + const color = primary.clone().darken(i); + props['primaryDarken' + i] = genValue(color); + } + return props; } -function genValue(r: number, g: number, b: number, a: number): string { - return a != 255 ? `rgba(${r}, ${g}, ${b}, ${a})` : `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`; +function genValue(c: tinycolor.Instance): string { + return c.toRgbString(); } diff --git a/src/client/app/common/views/components/autocomplete.vue b/src/client/app/common/views/components/autocomplete.vue index ea05afd6dc..99a87520a4 100644 --- a/src/client/app/common/views/components/autocomplete.vue +++ b/src/client/app/common/views/components/autocomplete.vue @@ -259,7 +259,7 @@ export default Vue.extend({ diff --git a/src/client/app/desktop/views/components/notes.vue b/src/client/app/desktop/views/components/notes.vue index e6267ed204..2e3ffd171b 100644 --- a/src/client/app/desktop/views/components/notes.vue +++ b/src/client/app/desktop/views/components/notes.vue @@ -216,7 +216,7 @@ export default Vue.extend({ diff --git a/src/client/app/desktop/views/components/ui.header.search.vue b/src/client/app/desktop/views/components/ui.header.search.vue index 9a36e52fcc..d5794dc882 100644 --- a/src/client/app/desktop/views/components/ui.header.search.vue +++ b/src/client/app/desktop/views/components/ui.header.search.vue @@ -28,7 +28,7 @@ export default Vue.extend({ diff --git a/src/client/app/mobile/views/components/dialog.vue b/src/client/app/mobile/views/components/dialog.vue index 6a0d74c752..fff44a28c3 100644 --- a/src/client/app/mobile/views/components/dialog.vue +++ b/src/client/app/mobile/views/components/dialog.vue @@ -91,7 +91,7 @@ export default Vue.extend({ diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue index 68be9f8ac4..6daf375ed2 100644 --- a/src/client/app/mobile/views/components/note-detail.vue +++ b/src/client/app/mobile/views/components/note-detail.vue @@ -223,7 +223,7 @@ export default Vue.extend({ diff --git a/src/client/app/mobile/views/pages/notifications.vue b/src/client/app/mobile/views/pages/notifications.vue index bddcd457bb..ce33332faf 100644 --- a/src/client/app/mobile/views/pages/notifications.vue +++ b/src/client/app/mobile/views/pages/notifications.vue @@ -34,7 +34,7 @@ export default Vue.extend({