From 42d293ee60c671ba424671d49072fc6c880d44b0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 19 Jul 2021 11:36:35 +0900 Subject: Classic UI --- src/client/components/launch-pad.vue | 4 +- src/client/components/ui/container.vue | 2 + src/client/components/widgets.vue | 1 + src/client/menu.ts | 169 ++++++++++++++++++++ src/client/pages/settings/index.vue | 4 +- src/client/pages/settings/menu.vue | 118 ++++++++++++++ src/client/pages/settings/sidebar.vue | 114 -------------- src/client/scripts/sticky-sidebar.ts | 16 +- src/client/sidebar.ts | 169 -------------------- src/client/store.ts | 5 +- src/client/style.scss | 2 +- src/client/ui/_common_/sidebar.vue | 8 +- src/client/ui/chat/index.vue | 4 +- src/client/ui/deck.vue | 4 +- src/client/ui/default.header.vue | 274 +++++++++++++++++++++++++++++++++ src/client/ui/default.sidebar.vue | 8 +- src/client/ui/default.vue | 55 +++++-- src/client/ui/default.widgets.vue | 16 +- src/client/ui/desktop.vue | 4 +- src/client/ui/universal.vue | 4 +- 20 files changed, 652 insertions(+), 329 deletions(-) create mode 100644 src/client/menu.ts create mode 100644 src/client/pages/settings/menu.vue delete mode 100644 src/client/pages/settings/sidebar.vue delete mode 100644 src/client/sidebar.ts create mode 100644 src/client/ui/default.header.vue (limited to 'src') diff --git a/src/client/components/launch-pad.vue b/src/client/components/launch-pad.vue index 58b74bdaee..6f97d4d3aa 100644 --- a/src/client/components/launch-pad.vue +++ b/src/client/components/launch-pad.vue @@ -36,7 +36,7 @@ diff --git a/src/client/pages/settings/sidebar.vue b/src/client/pages/settings/sidebar.vue deleted file mode 100644 index d91cae42f4..0000000000 --- a/src/client/pages/settings/sidebar.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - diff --git a/src/client/scripts/sticky-sidebar.ts b/src/client/scripts/sticky-sidebar.ts index 18670bc037..c67b8f37ac 100644 --- a/src/client/scripts/sticky-sidebar.ts +++ b/src/client/scripts/sticky-sidebar.ts @@ -7,8 +7,9 @@ export class StickySidebar { private isTop = false; private isBottom = false; private offsetTop: number; + private globalHeaderHeight: number = 59; - constructor(container: StickySidebar['container'], marginTop = 0) { + constructor(container: StickySidebar['container'], marginTop = 0, globalHeaderHeight = 0) { this.container = container; this.el = this.container.children[0] as HTMLElement; this.el.style.position = 'sticky'; @@ -16,30 +17,31 @@ export class StickySidebar { this.container.prepend(this.spacer); this.marginTop = marginTop; this.offsetTop = this.container.getBoundingClientRect().top; + this.globalHeaderHeight = globalHeaderHeight; } public calc(scrollTop: number) { if (scrollTop > this.lastScrollTop) { // downscroll - const overflow = Math.max(0, (this.el.clientHeight + this.marginTop) - window.innerHeight); + const overflow = Math.max(0, this.globalHeaderHeight + (this.el.clientHeight + this.marginTop) - window.innerHeight); this.el.style.bottom = null; - this.el.style.top = `${-overflow + this.marginTop}px`; + this.el.style.top = `${-overflow + this.marginTop + this.globalHeaderHeight}px`; this.isBottom = (scrollTop + window.innerHeight) >= (this.el.offsetTop + this.el.clientHeight); if (this.isTop) { this.isTop = false; - this.spacer.style.marginTop = `${Math.max(0, this.lastScrollTop + this.marginTop - this.offsetTop)}px`; + this.spacer.style.marginTop = `${Math.max(0, this.globalHeaderHeight + this.lastScrollTop + this.marginTop - this.offsetTop)}px`; } } else { // upscroll - const overflow = (this.el.clientHeight + this.marginTop) - window.innerHeight; + const overflow = this.globalHeaderHeight + (this.el.clientHeight + this.marginTop) - window.innerHeight; this.el.style.top = null; this.el.style.bottom = `${-overflow}px`; - this.isTop = scrollTop <= this.el.offsetTop; + this.isTop = scrollTop + this.marginTop + this.globalHeaderHeight <= this.el.offsetTop; if (this.isBottom) { this.isBottom = false; - this.spacer.style.marginTop = `${this.lastScrollTop + this.marginTop - this.offsetTop - overflow}px`; + this.spacer.style.marginTop = `${this.globalHeaderHeight + this.lastScrollTop + this.marginTop - this.offsetTop - overflow}px`; } } diff --git a/src/client/sidebar.ts b/src/client/sidebar.ts deleted file mode 100644 index 7686da10b2..0000000000 --- a/src/client/sidebar.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { computed } from 'vue'; -import { search } from '@client/scripts/search'; -import * as os from '@client/os'; -import { i18n } from '@client/i18n'; -import { $i } from './account'; -import { unisonReload } from '@client/scripts/unison-reload'; - -export const sidebarDef = { - notifications: { - title: 'notifications', - icon: 'fas fa-bell', - show: computed(() => $i != null), - indicated: computed(() => $i != null && $i.hasUnreadNotification), - to: '/my/notifications', - }, - messaging: { - title: 'messaging', - icon: 'fas fa-comments', - show: computed(() => $i != null), - indicated: computed(() => $i != null && $i.hasUnreadMessagingMessage), - to: '/my/messaging', - }, - drive: { - title: 'drive', - icon: 'fas fa-cloud', - show: computed(() => $i != null), - to: '/my/drive', - }, - followRequests: { - title: 'followRequests', - icon: 'fas fa-user-clock', - show: computed(() => $i != null && $i.isLocked), - indicated: computed(() => $i != null && $i.hasPendingReceivedFollowRequest), - to: '/my/follow-requests', - }, - featured: { - title: 'featured', - icon: 'fas fa-fire-alt', - to: '/featured', - }, - explore: { - title: 'explore', - icon: 'fas fa-hashtag', - to: '/explore', - }, - announcements: { - title: 'announcements', - icon: 'fas fa-broadcast-tower', - indicated: computed(() => $i != null && $i.hasUnreadAnnouncement), - to: '/announcements', - }, - search: { - title: 'search', - icon: 'fas fa-search', - action: () => search(), - }, - lists: { - title: 'lists', - icon: 'fas fa-list-ul', - show: computed(() => $i != null), - to: '/my/lists', - }, - groups: { - title: 'groups', - icon: 'fas fa-users', - show: computed(() => $i != null), - to: '/my/groups', - }, - antennas: { - title: 'antennas', - icon: 'fas fa-satellite', - show: computed(() => $i != null), - to: '/my/antennas', - }, - mentions: { - title: 'mentions', - icon: 'fas fa-at', - show: computed(() => $i != null), - indicated: computed(() => $i != null && $i.hasUnreadMentions), - to: '/my/mentions', - }, - messages: { - title: 'directNotes', - icon: 'fas fa-envelope', - show: computed(() => $i != null), - indicated: computed(() => $i != null && $i.hasUnreadSpecifiedNotes), - to: '/my/messages', - }, - favorites: { - title: 'favorites', - icon: 'fas fa-star', - show: computed(() => $i != null), - to: '/my/favorites', - }, - pages: { - title: 'pages', - icon: 'fas fa-file-alt', - to: '/pages', - }, - gallery: { - title: 'gallery', - icon: 'fas fa-icons', - to: '/gallery', - }, - clips: { - title: 'clip', - icon: 'fas fa-paperclip', - show: computed(() => $i != null), - to: '/my/clips', - }, - channels: { - title: 'channel', - icon: 'fas fa-satellite-dish', - to: '/channels', - }, - games: { - title: 'games', - icon: 'fas fa-gamepad', - to: '/games/reversi', - }, - scratchpad: { - title: 'scratchpad', - icon: 'fas fa-terminal', - to: '/scratchpad', - }, - rooms: { - title: 'rooms', - icon: 'fas fa-door-closed', - show: computed(() => $i != null), - to: computed(() => `/@${$i.username}/room`), - }, - ui: { - title: 'switchUi', - icon: 'fas fa-columns', - action: (ev) => { - os.modalMenu([{ - text: i18n.locale.default, - action: () => { - localStorage.setItem('ui', 'default'); - unisonReload(); - } - }, { - text: i18n.locale.deck, - action: () => { - localStorage.setItem('ui', 'deck'); - unisonReload(); - } - }, { - text: 'pope', - action: () => { - localStorage.setItem('ui', 'pope'); - unisonReload(); - } - }, { - text: 'Chat (β)', - action: () => { - localStorage.setItem('ui', 'chat'); - unisonReload(); - } - }, { - text: i18n.locale.desktop + ' (β)', - action: () => { - localStorage.setItem('ui', 'desktop'); - unisonReload(); - } - }], ev.currentTarget || ev.target); - }, - }, -}; diff --git a/src/client/store.ts b/src/client/store.ts index 07ea1868a6..04f9e83c61 100644 --- a/src/client/store.ts +++ b/src/client/store.ts @@ -90,6 +90,7 @@ export const defaultStore = markRaw(new Storage('base', { default: [] as { name: string; id: string; + place: string; data: Record; }[] }, @@ -185,9 +186,9 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false }, - sidebarDisplay: { + menuDisplay: { where: 'device', - default: 'full' as 'full' | 'icon' + default: 'sideFull' as 'sideFull' | 'sideIcon' | 'top' }, reportError: { where: 'device', diff --git a/src/client/style.scss b/src/client/style.scss index dc419bd872..578e7543c7 100644 --- a/src/client/style.scss +++ b/src/client/style.scss @@ -161,7 +161,7 @@ hr { background: none; border: none; cursor: pointer; - color: var(--fg); + color: inherit; touch-action: manipulation; tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent; diff --git a/src/client/ui/_common_/sidebar.vue b/src/client/ui/_common_/sidebar.vue index df11877147..073907cde9 100644 --- a/src/client/ui/_common_/sidebar.vue +++ b/src/client/ui/_common_/sidebar.vue @@ -49,7 +49,7 @@ import { defineComponent } from 'vue'; import { host } from '@client/config'; import { search } from '@client/scripts/search'; import * as os from '@client/os'; -import { sidebarDef } from '@client/sidebar'; +import { menuDef } from '@client/menu'; import { getAccounts, addAccount, login } from '@client/account'; export default defineComponent({ @@ -67,7 +67,7 @@ export default defineComponent({ showing: false, accounts: [], connection: null, - menuDef: sidebarDef, + menuDef: menuDef, iconOnly: false, hidden: this.defaultHidden, }; @@ -92,7 +92,7 @@ export default defineComponent({ this.showing = false; }, - '$store.reactiveState.sidebarDisplay.value'() { + '$store.reactiveState.menuDisplay.value'() { this.calcViewState(); }, @@ -116,7 +116,7 @@ export default defineComponent({ methods: { calcViewState() { - this.iconOnly = (window.innerWidth <= 1279) || (this.$store.state.sidebarDisplay === 'icon'); + this.iconOnly = (window.innerWidth <= 1279) || (this.$store.state.menuDisplay === 'sideIcon'); if (!this.defaultHidden) { this.hidden = (window.innerWidth <= 650); } diff --git a/src/client/ui/chat/index.vue b/src/client/ui/chat/index.vue index c28436ed5c..d45369e8b0 100644 --- a/src/client/ui/chat/index.vue +++ b/src/client/ui/chat/index.vue @@ -142,7 +142,7 @@ import XTimeline from './timeline.vue'; import XHeaderClock from './header-clock.vue'; import * as os from '@client/os'; import { router } from '@client/router'; -import { sidebarDef } from '@client/sidebar'; +import { menuDef } from '@client/menu'; import { search } from '@client/scripts/search'; import copyToClipboard from '@client/scripts/copy-to-clipboard'; import { store } from './store'; @@ -190,7 +190,7 @@ export default defineComponent({ followedChannels: null, featuredChannels: null, currentChannel: null, - menuDef: sidebarDef, + menuDef: menuDef, sideViewOpening: false, instanceName, }; diff --git a/src/client/ui/deck.vue b/src/client/ui/deck.vue index 935445a54d..4b0189ba77 100644 --- a/src/client/ui/deck.vue +++ b/src/client/ui/deck.vue @@ -37,7 +37,7 @@ import DeckColumnCore from '@client/ui/deck/column-core.vue'; import XSidebar from '@client/ui/_common_/sidebar.vue'; import { getScrollContainer } from '@client/scripts/scroll'; import * as os from '@client/os'; -import { sidebarDef } from '@client/sidebar'; +import { menuDef } from '@client/menu'; import XCommon from './_common_/common.vue'; import { deckStore, addColumn, loadDeck } from './deck/deck-store'; @@ -60,7 +60,7 @@ export default defineComponent({ return { deckStore, host: host, - menuDef: sidebarDef, + menuDef: menuDef, wallpaper: localStorage.getItem('wallpaper') != null, }; }, diff --git a/src/client/ui/default.header.vue b/src/client/ui/default.header.vue new file mode 100644 index 0000000000..a67883020f --- /dev/null +++ b/src/client/ui/default.header.vue @@ -0,0 +1,274 @@ + + + + + diff --git a/src/client/ui/default.sidebar.vue b/src/client/ui/default.sidebar.vue index c7e2d30c7a..2e0336878d 100644 --- a/src/client/ui/default.sidebar.vue +++ b/src/client/ui/default.sidebar.vue @@ -45,7 +45,7 @@ import { defineComponent } from 'vue'; import { host } from '@client/config'; import { search } from '@client/scripts/search'; import * as os from '@client/os'; -import { sidebarDef } from '@client/sidebar'; +import { menuDef } from '@client/menu'; import { getAccounts, addAccount, login } from '@client/account'; import MkButton from '@client/components/ui/button.vue'; import { StickySidebar } from '@client/scripts/sticky-sidebar'; @@ -62,7 +62,7 @@ export default defineComponent({ host: host, accounts: [], connection: null, - menuDef: sidebarDef, + menuDef: menuDef, iconOnly: false, settingsWindowed: false, }; @@ -83,7 +83,7 @@ export default defineComponent({ }, watch: { - '$store.reactiveState.sidebarDisplay.value'() { + '$store.reactiveState.menuDisplay.value'() { this.calcViewState(); }, @@ -108,7 +108,7 @@ export default defineComponent({ methods: { calcViewState() { - this.iconOnly = (window.innerWidth <= 1400) || (this.$store.state.sidebarDisplay === 'icon'); + this.iconOnly = (window.innerWidth <= 1400) || (this.$store.state.menuDisplay === 'sideIcon'); this.settingsWindowed = (window.innerWidth > 1400); }, diff --git a/src/client/ui/default.vue b/src/client/ui/default.vue index 3c87bf7ab4..f18685d78c 100644 --- a/src/client/ui/default.vue +++ b/src/client/ui/default.vue @@ -1,9 +1,16 @@