diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-10-17 20:12:00 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-17 20:12:00 +0900 |
| commit | 7199e6f4e0b3a2c2bc198e689c3e0cd0d0f0354a (patch) | |
| tree | 2263a06acec7fa21882366bae26d1a983ce21135 /src/client/ui | |
| parent | CW の input でも投稿ショートカットが動作するように (#6690) (diff) | |
| download | sharkey-7199e6f4e0b3a2c2bc198e689c3e0cd0d0f0354a.tar.gz sharkey-7199e6f4e0b3a2c2bc198e689c3e0cd0d0f0354a.tar.bz2 sharkey-7199e6f4e0b3a2c2bc198e689c3e0cd0d0f0354a.zip | |
Migrate to Vue3 (#6587)
* Update reaction.vue
* fix bug
* wip
* wip
* wjio
* wip
* Revert "wip"
This reverts commit e427f2160adf4e8a4147006e25a89854edab0033.
* wip
* wip
* wip
* Update init.ts
* Update drive-window.vue
* wip
* wip
* Use PascalCase for components
* Use PascalCase for components
* update dep
* wip
* wip
* wip
* Update init.ts
* wip
* Update paging.ts
* Update test.vue
* watch deep
* wip
* lint
* wip
* wip
* wip
* wip
* wiop
* wip
* Update webpack.config.ts
* alllow null poll
* wip
* wip
* wip
* wiop
* UI redesign & refactor (#6714)
* wip
* wip
* wip
* wip
* wip
* Update drive.vue
* Update word-mute.vue
* wip
* wip
* wip
* clean up
* wip
* Update default.vue
* wip
* Update notes.vue
* Update mfm.ts
* Update index.home.vue
* Update post-form.vue
* Update post-form-attaches.vue
* wip
* Update post-form.vue
* Update sidebar.vue
* wip
* wip
* Update index.vue
* wip
* Update default.vue
* Update index.vue
* Update index.vue
* wip
* Update post-form-attaches.vue
* Update note.vue
* wip
* clean up
* Update notes.vue
* wip
* wip
* Update ja-JP.yml
* wip
* wip
* Update index.vue
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update default.vue
* wip
* Update _dark.json5
* wip
* wip
* wip
* clean up
* wip
* wip
* Update index.vue
* Update test.vue
* wip
* wip
* fix
* wip
* wip
* wip
* wip
* clena yop
* wip
* wip
* Update store.ts
* Update messaging-room.vue
* Update default.widgets.vue
* fix
* wip
* wip
* Update modal.vue
* wip
* Update os.ts
* Update os.ts
* Update deck.vue
* Update init.ts
* wip
* Update ja-JP.yml
* v-sizeは単にwindowのresizeを監視するだけで良いかもしれない
* Update modal.vue
* wip
* Update tooltip.ts
* wip
* wip
* wip
* wip
* wip
* Update image-viewer.vue
* wip
* wip
* Update style.scss
* Update style.scss
* Update visitor.vue
* wip
* Update init.ts
* Update init.ts
* wip
* wip
* Update visitor.vue
* Update visitor.vue
* Update visitor.vue
* Update visitor.vue
* wip
* wip
* Update modal.vue
* Update header.vue
* Update menu.vue
* Update about.vue
* Update about-misskey.vue
* wip
* wip
* Update visitor.vue
* Update tooltip.ts
* wip
* Update drive.vue
* wip
* Update style.scss
* Update header.vue
* wip
* wip
* Update users.user.vue
* Update announcements.vue
* wip
* wip
* wip
* Update emojis.vue
* wip
* Update emojis.vue
* Update style.scss
* Update users.vue
* wip
* Update style.scss
* wip
* Update welcome.entrance.vue
* Update radio.vue
* Update size.ts
* Update emoji-edit-dialog.vue
* wip
* Update emojis.vue
* wip
* Update emojis.vue
* Update emojis.vue
* Update emojis.vue
* wip
* wip
* wip
* wip
* Update file-dialog.vue
* wip
* wip
* Update token-generate-window.vue
* Update notification-setting-window.vue
* wip
* wip
* Update _error_.vue
* Update ja-JP.yml
* wip
* wip
* Update store.ts
* Update emojis.vue
* Update emojis.vue
* Update emojis.vue
* Update announcements.vue
* Update store.ts
* wip
* Update page-editor.vue
* wip
* wip
* Update modal.vue
* wip
* Update select-file.ts
* Update timeline.vue
* Update emojis.vue
* Update os.ts
* wip
* Update user-select.vue
* Update mfm.ts
* Update get-file-info.ts
* Update drive.vue
* Update init.ts
* Update mfm.ts
* wip
* wip
* Update window.vue
* Update note.vue
* wip
* wip
* Update user-info.vue
* wip
* wip
* wip
* wip
* wip
* Update header.vue
* Update header.vue
* wip
* Update explore.vue
* wip
* wip
* wip
* Update webpack.config.ts
* wip
* wip
* wip
* wip
* wip
* wip
* Update autocomplete.ts
* wip
* wip
* wip
* Update toast.vue
* wip
* Update post-form-dialog.vue
* wip
* wip
* wip
* wip
* wip
* Update users.vue
* wip
* Update explore.vue
* wip
* wip
* wip
* Update package.json
* wip
* Update icon-dialog.vue
* wip
* wip
* Update user-preview.ts
* wip
* wip
* wip
* wip
* wip
* Update instance.vue
* Update user-name.vue
* Update federation.vue
* Update instance.vue
* wip
* wip
* Update tag.vue
* wip
* wip
* wip
* wip
* wip
* Update instance.vue
* wip
* Update os.ts
* Update os.ts
* wip
* wip
* wip
* Update router.ts
* wip
* Update init.ts
* Update note.vue
* Update messages.vue
* wip
* wip
* wip
* wip
* wip
* google
* wip
* wip
* wip
* wip
* Update theme-editor.vue
* wip
* wip
* Update room.vue
* Update channel-editor.vue
* wip
* Update window.vue
* Update window.vue
* wip
* Update window.vue
* Update window.vue
* wip
* Update menu.vue
* wip
* wip
* wip
* wip
* Update messaging-room.vue
* wip
* Update post-form.vue
* Update default.widgets.vue
* Update window.vue
* wip
Diffstat (limited to 'src/client/ui')
| -rw-r--r-- | src/client/ui/_common_/header.vue | 149 | ||||
| -rw-r--r-- | src/client/ui/deck.vue | 276 | ||||
| -rw-r--r-- | src/client/ui/default.vue | 415 | ||||
| -rw-r--r-- | src/client/ui/default.widgets.vue | 158 | ||||
| -rw-r--r-- | src/client/ui/visitor.vue | 199 | ||||
| -rw-r--r-- | src/client/ui/zen.vue | 154 |
6 files changed, 1351 insertions, 0 deletions
diff --git a/src/client/ui/_common_/header.vue b/src/client/ui/_common_/header.vue new file mode 100644 index 0000000000..32207d5dca --- /dev/null +++ b/src/client/ui/_common_/header.vue @@ -0,0 +1,149 @@ +<template> +<div class="fdidabkb"> + <transition :name="$store.state.device.animation ? 'header' : ''" mode="out-in" appear> + <button class="_button back" v-if="withBack && canBack" @click="back()"><Fa :icon="faChevronLeft"/></button> + </transition> + <template v-if="info"> + <div class="titleContainer"> + <div class="title" v-for="header in info.header" :key="header.id" :class="{ _button: header.onClick, selected: header.selected }" @click="header.onClick" v-tooltip="header.tooltip"> + <Fa v-if="header.icon" :icon="header.icon" :key="header.icon" class="icon"/> + <MkAvatar v-else-if="header.avatar" class="avatar" :user="header.avatar" :disable-preview="true"/> + <span v-if="header.title" class="text">{{ header.title }}</span> + <MkUserName v-else-if="header.userName" :user="header.userName" :nowrap="false" class="text"/> + </div> + </div> + <button class="_button action" v-if="info.action" @click="info.action.handler"><Fa :icon="info.action.icon" :key="info.action.icon"/></button> + </template> +</div> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { faChevronLeft } from '@fortawesome/free-solid-svg-icons'; + +export default defineComponent({ + props: { + info: { + required: true + }, + withBack: { + type: Boolean, + required: false, + default: true, + }, + }, + + data() { + return { + canBack: false, + height: 0, + faChevronLeft + }; + }, + + watch: { + $route(to, from) { + this.canBack = (window.history.length > 0 && !['index'].includes(to.name)); + }, + }, + + mounted() { + this.height = this.$el.parentElement.offsetHeight + 'px'; + new ResizeObserver((entries, observer) => { + this.height = this.$el.parentElement.offsetHeight + 'px'; + }).observe(this.$el); + }, + + methods: { + back() { + if (this.canBack) this.$router.back(); + }, + } +}); +</script> + +<style lang="scss" scoped vars="{ height }"> +.fdidabkb { + text-align: center; + + > .back { + height: var(--height); + width: var(--height); + } + + > .action { + height: var(--height); + width: var(--height); + } + + > .titleContainer { + width: calc(100% - (var(--height) * 2)); + + > .title { + height: var(--height); + + > .avatar { + $size: 32px; + margin: calc((var(--height) - #{$size}) / 2) 8px calc((var(--height) - #{$size}) / 2) 0; + pointer-events: none; + } + } + } +} +</style> + +<style lang="scss" scoped> +.fdidabkb { + > .back { + position: absolute; + z-index: 1; + top: 0; + left: 0; + } + + > .action { + position: absolute; + z-index: 1; + top: 0; + right: 0; + } + + > .titleContainer { + margin: 0 auto; + overflow: auto; + white-space: nowrap; + + > .title { + display: inline-block; + vertical-align: bottom; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + padding: 0 16px; + + > .icon + .text { + margin-left: 8px; + } + + > .avatar { + $size: 32px; + display: inline-block; + width: $size; + height: $size; + vertical-align: bottom; + } + + &._button { + &:hover { + color: var(--fgHighlighted); + } + } + + &.selected { + box-shadow: 0 -2px 0 0 var(--accent) inset; + color: var(--fgHighlighted); + } + } + } +} +</style> diff --git a/src/client/ui/deck.vue b/src/client/ui/deck.vue new file mode 100644 index 0000000000..b067b948ce --- /dev/null +++ b/src/client/ui/deck.vue @@ -0,0 +1,276 @@ +<template> +<div class="mk-deck" :class="`${$store.state.device.deckColumnAlign}`" v-hotkey.global="keymap"> + <XSidebar ref="nav"/> + + <!-- TODO: deckMainColumnPlace を見て位置変える --> + <deck-column class="column" v-if="$store.state.device.deckAlwaysShowMainColumn || $route.name !== 'index'"> + <template #header> + <XHeader :info="pageInfo"/> + </template> + + <router-view v-slot="{ Component }"> + <transition> + <keep-alive :include="['timeline']"> + <component :is="Component" :ref="changePage"/> + </keep-alive> + </transition> + </router-view> + </deck-column> + + <template v-for="ids in layout"> + <div v-if="ids.length > 1" class="folder column"> + <deck-column-core v-for="id in ids" :ref="id" :key="id" :column="columns.find(c => c.id === id)" :is-stacked="true" @parent-focus="moveFocus(id, $event)"/> + </div> + <deck-column-core v-else class="column" :ref="ids[0]" :key="ids[0]" :column="columns.find(c => c.id === ids[0])" @parent-focus="moveFocus(ids[0], $event)"/> + </template> + + <button @click="addColumn" class="_button add"><Fa :icon="faPlus"/></button> + + <button v-if="$store.getters.isSignedIn" class="nav _button" @click="showNav()"><Fa :icon="faBars"/><i v-if="navIndicated"><Fa :icon="faCircle"/></i></button> + <button v-if="$store.getters.isSignedIn" class="post _buttonPrimary" @click="post()"><Fa :icon="faPencilAlt"/></button> + + <StreamIndicator v-if="$store.getters.isSignedIn"/> +</div> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { faPlus, faPencilAlt, faChevronLeft, faBars, faCircle } from '@fortawesome/free-solid-svg-icons'; +import { } from '@fortawesome/free-regular-svg-icons'; +import { v4 as uuid } from 'uuid'; +import { host } from '@/config'; +import { search } from '@/scripts/search'; +import DeckColumnCore from '@/components/deck/column-core.vue'; +import DeckColumn from '@/components/deck/column.vue'; +import XSidebar from '@/components/sidebar.vue'; +import XHeader from './_common_/header.vue'; +import { getScrollContainer } from '@/scripts/scroll'; +import * as os from '@/os'; +import { sidebarDef } from '@/sidebar'; + +export default defineComponent({ + components: { + XSidebar, + XHeader, + DeckColumn, + DeckColumnCore, + }, + + data() { + return { + host: host, + pageInfo: null, + pageKey: 0, + connection: null, + menuDef: sidebarDef, + wallpaper: localStorage.getItem('wallpaper') != null, + faPlus, faPencilAlt, faChevronLeft, faBars, faCircle + }; + }, + + computed: { + deck() { + return this.$store.state.deviceUser.deck; + }, + columns(): any[] { + return this.deck.columns; + }, + layout(): any[] { + return this.deck.layout; + }, + navIndicated(): boolean { + if (!this.$store.getters.isSignedIn) return false; + for (const def in this.menuDef) { + if (this.menuDef[def].indicated) return true; + } + return false; + }, + keymap(): any { + return { + 'p': this.post, + 'n': this.post, + 's': this.search, + 'h|/': this.help + }; + }, + }, + + watch: { + $route(to, from) { + this.pageKey++; + }, + }, + + created() { + document.documentElement.style.overflowY = 'hidden'; + document.documentElement.style.scrollBehavior = 'auto'; + window.addEventListener('wheel', this.onWheel); + + if (this.$store.getters.isSignedIn) { + this.connection = os.stream.useSharedConnection('main'); + this.connection.on('notification', this.onNotification); + } + }, + + mounted() { + }, + + methods: { + changePage(page) { + if (page == null) return; + if (page.INFO) { + this.pageInfo = page.INFO; + } + }, + + onWheel(e) { + if (getScrollContainer(e.target) == null) { + document.documentElement.scrollLeft += e.deltaY > 0 ? 96 : -96; + } + }, + + showNav() { + this.$refs.nav.show(); + }, + + help() { + this.$router.push('/docs/keyboard-shortcut'); + }, + + post() { + os.post(); + }, + + async onNotification(notification) { + if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { + return; + } + + if (document.visibilityState === 'visible') { + os.stream.send('readNotification', { + id: notification.id + }); + + os.popup(await import('@/components/toast.vue'), { + notification + }, {}, 'closed'); + } + os.sound('notification'); + }, + + async addColumn(ev) { + const columns = [ + 'widgets', + 'notifications', + 'tl', + 'antenna', + 'list', + 'mentions', + 'direct', + ]; + + const { canceled, result: column } = await os.dialog({ + title: this.$t('_deck.addColumn'), + type: null, + select: { + items: columns.map(column => ({ + value: column, text: this.$t('_deck._columns.' + column) + })) + }, + showCancelButton: true + }); + if (canceled) return; + + this.$store.commit('deviceUser/addDeckColumn', { + type: column, + id: uuid(), + name: this.$t('_deck._columns.' + column), + width: 330, + }); + }, + } +}); +</script> + +<style lang="scss" scoped> +.mk-deck { + $nav-hide-threshold: 650px; // TODO: どこかに集約したい + + // TODO: この値を設定で変えられるようにする? + $columnMargin: 12px; + + $deckMargin: 12px; + + --margin: var(--marginHalf); + + display: flex; + // ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + height: calc(var(--vh, 1vh) * 100); + box-sizing: border-box; + flex: 1; + padding: $deckMargin 0 $deckMargin $deckMargin; + + &.center { + > .column:first-of-type { + margin-left: auto; + } + + > .add { + margin-right: auto; + } + } + + > .column { + flex-shrink: 0; + margin-right: $columnMargin; + + &.folder { + display: flex; + flex-direction: column; + + > *:not(:last-child) { + margin-bottom: $columnMargin; + } + } + } + + > .post, + > .nav { + position: fixed; + z-index: 1000; + bottom: 32px; + width: 64px; + height: 64px; + border-radius: 100%; + box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12); + font-size: 22px; + } + + > .post { + right: 32px; + } + + > .nav { + left: 32px; + background: var(--panel); + color: var(--fg); + + @media (min-width: ($nav-hide-threshold + 1px)) { + display: none; + } + + &:hover { + background: var(--X2); + } + + > i { + position: absolute; + top: 0; + left: 0; + color: var(--indicator); + font-size: 16px; + animation: blink 1s infinite; + } + } +} +</style> diff --git a/src/client/ui/default.vue b/src/client/ui/default.vue new file mode 100644 index 0000000000..5eeee0a667 --- /dev/null +++ b/src/client/ui/default.vue @@ -0,0 +1,415 @@ +<template> +<div class="mk-app" v-hotkey.global="keymap"> + <XSidebar ref="nav" class="sidebar"/> + + <div class="contents" ref="contents" :class="{ wallpaper }"> + <header class="header" ref="header"> + <XHeader :info="pageInfo"/> + </header> + <main ref="main"> + <div class="content"> + <router-view v-slot="{ Component }"> + <transition :name="$store.state.device.animation ? 'page' : ''" mode="out-in" @enter="onTransition"> + <keep-alive :include="['timeline']"> + <component :is="Component" :ref="changePage"/> + </keep-alive> + </transition> + </router-view> + </div> + <div class="spacer"></div> + </main> + </div> + + <div v-if="isDesktop" class="widgets"> + <div ref="widgetsSpacer"></div> + <XWidgets @mounted="attachSticky"/> + </div> + + <div class="buttons" :class="{ navHidden }"> + <button class="button nav _button" @click="showNav" ref="navButton"><Fa :icon="faBars"/><i v-if="navIndicated"><Fa :icon="faCircle"/></i></button> + <button v-if="$route.name === 'index'" class="button home _button" @click="top()"><Fa :icon="faHome"/></button> + <button v-else class="button home _button" @click="$router.push('/')"><Fa :icon="faHome"/></button> + <button class="button notifications _button" @click="$router.push('/my/notifications')"><Fa :icon="faBell"/><i v-if="$store.state.i.hasUnreadNotification"><Fa :icon="faCircle"/></i></button> + <button class="button widget _button" @click="widgetsShowing = true"><Fa :icon="faLayerGroup"/></button> + </div> + + <button class="widgetButton _button" :class="{ navHidden }" @click="widgetsShowing = true"><Fa :icon="faLayerGroup"/></button> + + <transition name="tray-back"> + <div class="tray-back _modalBg" + v-if="widgetsShowing" + @click="widgetsShowing = false" + @touchstart.passive="widgetsShowing = false" + ></div> + </transition> + + <transition name="tray"> + <XWidgets v-if="widgetsShowing" class="tray"/> + </transition> + + <StreamIndicator/> +</div> +</template> + +<script lang="ts"> +import { defineComponent, defineAsyncComponent } from 'vue'; +import { faLayerGroup, faBars, faHome, faCircle } from '@fortawesome/free-solid-svg-icons'; +import { faBell } from '@fortawesome/free-regular-svg-icons'; +import { host } from '@/config'; +import { search } from '@/scripts/search'; +import { StickySidebar } from '@/scripts/sticky-sidebar'; +import XSidebar from '@/components/sidebar.vue'; +import XHeader from './_common_/header.vue'; +import * as os from '@/os'; +import { sidebarDef } from '@/sidebar'; + +const DESKTOP_THRESHOLD = 1100; + +export default defineComponent({ + components: { + XSidebar, + XHeader, + XWidgets: defineAsyncComponent(() => import('./default.widgets.vue')), + }, + + data() { + return { + host: host, + pageKey: 0, + pageInfo: null, + connection: null, + isDesktop: window.innerWidth >= DESKTOP_THRESHOLD, + menuDef: sidebarDef, + navHidden: false, + widgetsShowing: false, + wallpaper: localStorage.getItem('wallpaper') != null, + faLayerGroup, faBars, faBell, faHome, faCircle, + }; + }, + + computed: { + keymap(): any { + return { + 'd': () => { + if (this.$store.state.device.syncDeviceDarkMode) return; + this.$store.commit('device/set', { key: 'darkMode', value: !this.$store.state.device.darkMode }); + }, + 'p': os.post, + 'n': os.post, + 's': search, + 'h|/': this.help + }; + }, + + widgets(): any { + return this.$store.state.deviceUser.widgets; + }, + + menu(): string[] { + return this.$store.state.deviceUser.menu; + }, + + navIndicated(): boolean { + for (const def in this.menuDef) { + if (def === 'notifications') continue; // 通知は下にボタンとして表示されてるから + if (this.menuDef[def].indicated) return true; + } + return false; + } + }, + + watch: { + $route(to, from) { + this.pageKey++; + }, + }, + + created() { + document.documentElement.style.overflowY = 'scroll'; + + this.connection = os.stream.useSharedConnection('main'); + this.connection.on('notification', this.onNotification); + + if (this.$store.state.deviceUser.widgets.length === 0) { + this.$store.commit('deviceUser/setWidgets', [{ + name: 'calendar', + id: 'a', place: 'right', data: {} + }, { + name: 'notifications', + id: 'b', place: 'right', data: {} + }, { + name: 'trends', + id: 'c', place: 'right', data: {} + }]); + } + }, + + mounted() { + this.adjustUI(); + + const ro = new ResizeObserver((entries, observer) => { + this.adjustUI(); + }); + + ro.observe(this.$refs.contents); + + window.addEventListener('resize', this.adjustUI, { passive: true }); + + if (!this.isDesktop) { + window.addEventListener('resize', () => { + if (window.innerWidth >= DESKTOP_THRESHOLD) this.isDesktop = true; + }, { passive: true }); + } + }, + + methods: { + changePage(page) { + if (page == null) return; + if (page.INFO) { + this.pageInfo = page.INFO; + } + }, + + adjustUI() { + const navWidth = this.$refs.nav.$el.offsetWidth; + this.navHidden = navWidth === 0; + if (this.$refs.contents == null) return; + const width = this.$refs.contents.offsetWidth; + this.$refs.header.style.width = `${width}px`; + }, + + showNav() { + this.$refs.nav.show(); + }, + + attachSticky(el) { + const sticky = new StickySidebar(el, this.$refs.widgetsSpacer); + window.addEventListener('scroll', () => { + sticky.calc(window.scrollY); + }, { passive: true }); + }, + + top() { + window.scroll({ top: 0, behavior: 'smooth' }); + }, + + help() { + this.$router.push('/docs/keyboard-shortcut'); + }, + + onTransition() { + if (window._scroll) window._scroll(); + }, + + async onNotification(notification) { + if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { + return; + } + if (document.visibilityState === 'visible') { + os.stream.send('readNotification', { + id: notification.id + }); + + os.popup(await import('@/components/toast.vue'), { + notification + }, {}, 'closed'); + } + + os.sound('notification'); + }, + } +}); +</script> + +<style lang="scss" scoped> +.tray-enter-active, +.tray-leave-active { + opacity: 1; + transform: translateX(0); + transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1); +} +.tray-enter-from, +.tray-leave-active { + opacity: 0; + transform: translateX(240px); +} + +.tray-back-enter-active, +.tray-back-leave-active { + opacity: 1; + transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1); +} +.tray-back-enter-from, +.tray-back-leave-active { + opacity: 0; +} + +.mk-app { + $header-height: 60px; + $ui-font-size: 1em; // TODO: どこかに集約したい + $widgets-hide-threshold: 1090px; + + // ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + min-height: calc(var(--vh, 1vh) * 100); + box-sizing: border-box; + + display: flex; + + > .contents { + width: 100%; + min-width: 0; + padding-top: $header-height; + + &.wallpaper { + background: var(--wallpaperOverlay); + //backdrop-filter: blur(4px); + } + + > .header { + position: fixed; + z-index: 1000; + top: 0; + height: $header-height; + width: 100%; + line-height: $header-height; + text-align: center; + font-weight: bold; + //background-color: var(--panel); + -webkit-backdrop-filter: blur(32px); + backdrop-filter: blur(32px); + background-color: var(--header); + border-bottom: solid 1px var(--divider); + } + + > main { + min-width: 0; + + > .content { + > * { + // ほんとは単に calc(100vh - #{$header-height}) と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + min-height: calc((var(--vh, 1vh) * 100) - #{$header-height}); + } + } + + > .spacer { + height: 82px; + } + } + } + + > .widgets { + padding: 0 var(--margin); + border-left: solid 1px var(--divider); + + @media (max-width: $widgets-hide-threshold) { + display: none; + } + } + + > .widgetButton { + display: block; + position: fixed; + z-index: 1000; + bottom: 32px; + right: 32px; + width: 64px; + height: 64px; + border-radius: 100%; + box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12); + font-size: 22px; + background: var(--panel); + + &.navHidden { + display: none; + } + + @media (min-width: ($widgets-hide-threshold + 1px)) { + display: none; + } + } + + > .buttons { + position: fixed; + z-index: 1000; + bottom: 0; + padding: 0 32px 32px 32px; + display: flex; + width: 100%; + box-sizing: border-box; + background: linear-gradient(0deg, var(--bg), var(--X1)); + + @media (max-width: 500px) { + padding: 0 16px 16px 16px; + } + + &:not(.navHidden) { + display: none; + } + + > .button { + position: relative; + padding: 0; + margin: auto; + width: 64px; + height: 64px; + border-radius: 100%; + box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12); + background: var(--panel); + color: var(--fg); + + &:hover { + background: var(--X2); + } + + > i { + position: absolute; + top: 0; + left: 0; + color: var(--indicator); + font-size: 16px; + animation: blink 1s infinite; + } + + &:first-child { + margin-left: 0; + } + + &:last-child { + margin-right: 0; + } + + > * { + font-size: 22px; + } + + &:disabled { + cursor: default; + + > * { + opacity: 0.5; + } + } + } + } + + > .tray-back { + z-index: 1001; + } + + > .tray { + position: fixed; + top: 0; + right: 0; + z-index: 1001; + // ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + height: calc(var(--vh, 1vh) * 100); + padding: var(--margin); + box-sizing: border-box; + overflow: auto; + background: var(--bg); + } +} +</style> + +<style lang="scss"> +</style> diff --git a/src/client/ui/default.widgets.vue b/src/client/ui/default.widgets.vue new file mode 100644 index 0000000000..c41ba52a76 --- /dev/null +++ b/src/client/ui/default.widgets.vue @@ -0,0 +1,158 @@ +<template> +<div class="efzpzdvf"> + <template v-if="editMode"> + <MkButton primary @click="addWidget" class="add"><Fa :icon="faPlus"/></MkButton> + <XDraggable + :list="widgets" + handle=".handle" + animation="150" + class="sortable" + @sort="onWidgetSort" + > + <div v-for="widget in widgets" class="customize-container _panel" :key="widget.id"> + <header> + <span class="handle"><Fa :icon="faBars"/></span>{{ $t('_widgets.' + widget.name) }}<button class="remove _button" @click="removeWidget(widget)"><Fa :icon="faTimes"/></button> + </header> + <div @click="widgetFunc(widget.id)"> + <component class="_close_ _forceContainerFull_" :is="`mkw-${widget.name}`" :widget="widget" :ref="widget.id" :setting-callback="setting => settings[widget.id] = setting"/> + </div> + </div> + </XDraggable> + <button @click="editMode = false" class="_textButton" style="font-size: 0.9em;"><Fa :icon="faCheck"/> {{ $t('editWidgetsExit') }}</button> + </template> + <template v-else> + <component v-for="widget in widgets" class="_close_ _forceContainerFull_" :is="`mkw-${widget.name}`" :key="widget.id" :widget="widget"/> + <button @click="editMode = true" class="_textButton" style="font-size: 0.9em;"><Fa :icon="faPencilAlt"/> {{ $t('editWidgets') }}</button> + </template> +</div> +</template> + +<script lang="ts"> +import { defineComponent, defineAsyncComponent } from 'vue'; +import { v4 as uuid } from 'uuid'; +import { faPencilAlt, faPlus, faBars, faTimes, faCheck } from '@fortawesome/free-solid-svg-icons'; +import { widgets } from '@/widgets'; +import * as os from '@/os'; +import MkButton from '@/components/ui/button.vue'; + +export default defineComponent({ + components: { + MkButton, + XDraggable: defineAsyncComponent(() => import('vue-draggable-next').then(x => x.VueDraggableNext)), + }, + + emits: ['mounted'], + + data() { + return { + editMode: false, + settings: {}, + faPencilAlt, faPlus, faBars, faTimes, faCheck, + }; + }, + + computed: { + widgets(): any { + return this.$store.state.deviceUser.widgets; + }, + }, + + mounted() { + this.$emit('mounted', this.$el); + }, + + methods: { + widgetFunc(id) { + this.settings[id](); + }, + + onWidgetSort() { + // TODO: vuexを直接書き換えているのでなんとかする + this.saveHome(); + }, + + async addWidget() { + const { canceled, result: widget } = await os.dialog({ + type: null, + title: this.$t('chooseWidget'), + select: { + items: widgets.map(widget => ({ + value: widget, + text: this.$t('_widgets.' + widget), + })) + }, + showCancelButton: true + }); + if (canceled) return; + + this.$store.commit('deviceUser/addWidget', { + name: widget, + id: uuid(), + place: null, + data: {} + }); + }, + + removeWidget(widget) { + this.$store.commit('deviceUser/removeWidget', widget); + }, + + saveHome() { + this.$store.commit('deviceUser/setWidgets', this.widgets); + } + } +}); +</script> + +<style lang="scss" scoped> +.efzpzdvf { + position: sticky; + height: min-content; + min-height: 100vh; + padding: var(--margin) 0; + box-sizing: border-box; + + > * { + margin: var(--margin) 0; + width: 300px; + + &:first-child { + margin-top: 0; + } + } + + > .add { + margin: 0 auto; + } + + .customize-container { + margin: 8px 0; + + > header { + position: relative; + line-height: 32px; + + > .handle { + padding: 0 8px; + cursor: move; + } + + > .remove { + position: absolute; + top: 0; + right: 0; + padding: 0 8px; + line-height: 32px; + } + } + + > div { + padding: 8px; + + > * { + pointer-events: none; + } + } + } +} +</style> diff --git a/src/client/ui/visitor.vue b/src/client/ui/visitor.vue new file mode 100644 index 0000000000..fb21dc01d1 --- /dev/null +++ b/src/client/ui/visitor.vue @@ -0,0 +1,199 @@ +<template> +<div class="mk-app"> + <header> + <router-link class="link" to="/">{{ $t('home') }}</router-link> + <router-link class="link" to="/announcements">{{ $t('announcements') }}</router-link> + <router-link class="link" to="/channels">{{ $t('channel') }}</router-link> + <router-link class="link" to="/about">{{ $t('aboutX', { x: instanceName || host }) }}</router-link> + </header> + + <div class="banner" :style="{ backgroundImage: `url(${ $store.state.instance.meta.bannerUrl })` }"> + <h1>{{ instanceName || host }}</h1> + </div> + + <div class="contents" ref="contents" :class="{ wallpaper }"> + <header class="header" ref="header"> + <XHeader :info="pageInfo"/> + </header> + <main ref="main"> + <router-view v-slot="{ Component }"> + <transition :name="$store.state.device.animation ? 'page' : ''" mode="out-in" @enter="onTransition"> + <component :is="Component" :ref="changePage"/> + </transition> + </router-view> + </main> + <div class="powered-by"> + <b><router-link to="/">{{ host }}</router-link></b> + <small>Powered by <a href="https://github.com/syuilo/misskey" target="_blank">Misskey</a></small> + </div> + </div> + + <StreamIndicator v-if="$store.getters.isSignedIn"/> +</div> +</template> + +<script lang="ts"> +import { defineComponent, defineAsyncComponent } from 'vue'; +import { } from '@fortawesome/free-solid-svg-icons'; +import { host, instanceName } from '@/config'; +import { search } from '@/scripts/search'; +import * as os from '@/os'; +import XHeader from './_common_/header.vue'; + +const DESKTOP_THRESHOLD = 1100; + +export default defineComponent({ + components: { + XHeader + }, + + data() { + return { + host, + instanceName, + pageKey: 0, + pageInfo: null, + isDesktop: window.innerWidth >= DESKTOP_THRESHOLD, + }; + }, + + computed: { + keymap(): any { + return { + 'd': () => { + if (this.$store.state.device.syncDeviceDarkMode) return; + this.$store.commit('device/set', { key: 'darkMode', value: !this.$store.state.device.darkMode }); + }, + 's': search, + 'h|/': this.help + }; + }, + }, + + watch: { + $route(to, from) { + this.pageKey++; + }, + }, + + created() { + document.documentElement.style.overflowY = 'scroll'; + }, + + mounted() { + if (!this.isDesktop) { + window.addEventListener('resize', () => { + if (window.innerWidth >= DESKTOP_THRESHOLD) this.isDesktop = true; + }, { passive: true }); + } + }, + + methods: { + changePage(page) { + if (page == null) return; + if (page.INFO) { + this.pageInfo = page.INFO; + } + }, + + top() { + window.scroll({ top: 0, behavior: 'smooth' }); + }, + + help() { + this.$router.push('/docs/keyboard-shortcut'); + }, + + onTransition() { + if (window._scroll) window._scroll(); + }, + } +}); +</script> + +<style lang="scss" scoped> +.mk-app { + min-height: 100vh; + max-width: 1300px; + margin: 0 auto; + box-shadow: 1px 0 var(--divider), -1px 0 var(--divider); + + > header { + background: var(--panel); + padding: 0 16px; + text-align: center; + overflow: auto; + white-space: nowrap; + + > .link { + display: inline-block; + line-height: 60px; + padding: 0 0.7em; + + &.router-link-active { + box-shadow: 0 -2px 0 0 var(--accent) inset; + } + } + } + + > .banner { + position: relative; + width: 100%; + height: 200px; + background-size: cover; + background-position: center; + + &:after { + content: ""; + display: block; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 64px; + background: linear-gradient(transparent, var(--bg)); + } + + > h1 { + margin: 0; + text-align: center; + color: #fff; + text-shadow: 0 0 8px #000; + line-height: 200px; + } + } + + > .contents { + > .header { + position: sticky; + top: 0; + left: 0; + z-index: 1000; + height: 60px; + width: 100%; + line-height: 60px; + text-align: center; + -webkit-backdrop-filter: blur(32px); + backdrop-filter: blur(32px); + background-color: var(--header); + border-bottom: 1px solid var(--divider); + } + + > .powered-by { + padding: 28px; + font-size: 14px; + text-align: center; + border-top: 1px solid var(--divider); + + > small { + display: block; + margin-top: 8px; + opacity: 0.5; + } + } + } +} +</style> + +<style lang="scss"> +</style> diff --git a/src/client/ui/zen.vue b/src/client/ui/zen.vue new file mode 100644 index 0000000000..66dfa72797 --- /dev/null +++ b/src/client/ui/zen.vue @@ -0,0 +1,154 @@ +<template> +<div class="mk-app" v-hotkey.global="keymap"> + <div class="contents"> + <header class="header"> + <XHeader :info="pageInfo"/> + </header> + <main ref="main"> + <div class="content"> + <router-view v-slot="{ Component }"> + <transition :name="$store.state.device.animation ? 'page' : ''" mode="out-in" @enter="onTransition"> + <keep-alive :include="['timeline']"> + <component :is="Component" :ref="changePage"/> + </keep-alive> + </transition> + </router-view> + </div> + </main> + </div> + + <StreamIndicator/> +</div> +</template> + +<script lang="ts"> +import { defineComponent, defineAsyncComponent } from 'vue'; +import { faLayerGroup, faBars, faHome, faCircle } from '@fortawesome/free-solid-svg-icons'; +import { faBell } from '@fortawesome/free-regular-svg-icons'; +import { host } from '@/config'; +import { search } from '@/scripts/search'; +import XHeader from './_common_/header.vue'; +import * as os from '@/os'; + +export default defineComponent({ + components: { + XHeader, + }, + + data() { + return { + host: host, + pageKey: 0, + pageInfo: null, + connection: null, + faLayerGroup, faBars, faBell, faHome, faCircle, + }; + }, + + computed: { + keymap(): any { + return { + 'd': () => { + if (this.$store.state.device.syncDeviceDarkMode) return; + this.$store.commit('device/set', { key: 'darkMode', value: !this.$store.state.device.darkMode }); + }, + 'p': os.post, + 'n': os.post, + 's': search, + 'h|/': this.help + }; + }, + }, + + watch: { + $route(to, from) { + this.pageKey++; + }, + }, + + created() { + document.documentElement.style.overflowY = 'scroll'; + + this.connection = os.stream.useSharedConnection('main'); + this.connection.on('notification', this.onNotification); + }, + + methods: { + changePage(page) { + if (page == null) return; + if (page.INFO) { + this.pageInfo = page.INFO; + } + }, + + top() { + window.scroll({ top: 0, behavior: 'smooth' }); + }, + + help() { + this.$router.push('/docs/keyboard-shortcut'); + }, + + onTransition() { + if (window._scroll) window._scroll(); + }, + + async onNotification(notification) { + if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { + return; + } + if (document.visibilityState === 'visible') { + os.stream.send('readNotification', { + id: notification.id + }); + + os.popup(await import('@/components/toast.vue'), { + notification + }, {}, 'closed'); + } + + os.sound('notification'); + }, + } +}); +</script> + +<style lang="scss" scoped> +.mk-app { + $header-height: 52px; + $ui-font-size: 1em; // TODO: どこかに集約したい + $widgets-hide-threshold: 1090px; + + // ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + min-height: calc(var(--vh, 1vh) * 100); + box-sizing: border-box; + + > .contents { + padding-top: $header-height; + + > .header { + position: fixed; + z-index: 1000; + top: 0; + height: $header-height; + width: 100%; + line-height: $header-height; + text-align: center; + //background-color: var(--panel); + -webkit-backdrop-filter: blur(32px); + backdrop-filter: blur(32px); + background-color: var(--header); + border-bottom: solid 1px var(--divider); + } + + > main { + > .content { + > * { + // ほんとは単に calc(100vh - #{$header-height}) と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ + min-height: calc((var(--vh, 1vh) * 100) - #{$header-height}); + } + } + } + } +} +</style> |