summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-07-04 22:33:42 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-07-04 22:33:42 +0900
commit624c9f3418ce1c2597fbe2cb75caf01939e4d845 (patch)
tree743ce13484f47aefad5e26a33964f6f2ce39c8b6
parentwip (diff)
downloadmisskey-624c9f3418ce1c2597fbe2cb75caf01939e4d845.tar.gz
misskey-624c9f3418ce1c2597fbe2cb75caf01939e4d845.tar.bz2
misskey-624c9f3418ce1c2597fbe2cb75caf01939e4d845.zip
feat(client): ウィジェットを左にも置けるように
-rw-r--r--src/client/app.vue83
1 files changed, 53 insertions, 30 deletions
diff --git a/src/client/app.vue b/src/client/app.vue
index dc396d753e..94d75ebe64 100644
--- a/src/client/app.vue
+++ b/src/client/app.vue
@@ -86,18 +86,18 @@
</div>
</main>
- <div class="widgets" :class="{ edit: widgetsEditMode }">
- <template v-if="isDesktop && $store.getters.isSignedIn">
+ <template v-if="isDesktop">
+ <div class="widgets" :class="{ edit: widgetsEditMode }" v-for="place in ['left', 'right']" :key="place">
<template v-if="widgetsEditMode">
- <mk-button primary @click="addWidget" class="add"><fa :icon="faPlus"/></mk-button>
+ <mk-button primary @click="addWidget(place)" class="add"><fa :icon="faPlus"/></mk-button>
<x-draggable
- :list="widgets"
+ :list="widgets[place]"
handle=".handle"
animation="150"
class="sortable"
@sort="onWidgetSort"
>
- <div v-for="widget in widgets" class="customize-container _panel" :key="widget.id">
+ <div v-for="widget in widgets[place]" 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>
@@ -107,11 +107,9 @@
</div>
</x-draggable>
</template>
- <template v-else>
- <component class="_widget" v-for="widget in widgets" :is="`mkw-${widget.name}`" :key="widget.id" :ref="widget.id" :widget="widget"/>
- </template>
- </template>
- </div>
+ <component v-else class="_widget" v-for="widget in widgets[place]" :is="`mkw-${widget.name}`" :key="widget.id" :ref="widget.id" :widget="widget"/>
+ </div>
+ </template>
</div>
<div class="buttons">
@@ -179,7 +177,12 @@ export default Vue.extend({
},
widgets(): any[] {
- return this.$store.state.deviceUser.widgets;
+ const widgets = this.$store.state.deviceUser.widgets;
+ return {
+ left: widgets.filter(x => x.place === 'left'),
+ right: widgets.filter(x => x.place == null || x.place === 'right'),
+ mobile: widgets.filter(x => x.place === 'mobile'),
+ };
},
menu(): string[] {
@@ -219,16 +222,16 @@ export default Vue.extend({
this.connection = this.$root.stream.useSharedConnection('main');
this.connection.on('notification', this.onNotification);
- if (this.widgets.length === 0) {
+ if (this.$store.state.deviceUser.widgets.length === 0) {
this.$store.commit('deviceUser/setWidgets', [{
name: 'calendar',
- id: 'a', data: {}
+ id: 'a', place: 'right', data: {}
}, {
name: 'notifications',
- id: 'b', data: {}
+ id: 'b', place: 'right', data: {}
}, {
name: 'trends',
- id: 'c', data: {}
+ id: 'c', place: 'right', data: {}
}]);
}
}
@@ -503,7 +506,7 @@ export default Vue.extend({
this.saveHome();
},
- addWidget(ev) {
+ async addWidget(place) {
const widgets = [
'memo',
'notifications',
@@ -516,18 +519,24 @@ export default Vue.extend({
'photos',
];
- this.$root.menu({
- items: widgets.map(widget => ({
- text: this.$t('_widgets.' + widget),
- action: () => {
- this.$store.commit('deviceUser/addWidget', {
- name: widget,
- id: uuid(),
- data: {}
- });
- }
- })),
- source: ev.currentTarget || ev.target,
+ const { canceled, result: widget } = await this.$root.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: place,
+ data: {}
});
},
@@ -536,7 +545,7 @@ export default Vue.extend({
},
saveHome() {
- this.$store.commit('deviceUser/setWidgets', this.widgets);
+ this.$store.commit('deviceUser/setWidgets', [...this.widgets.left, ...this.widgets.right, ...this.widgets.mobile]);
}
}
});
@@ -574,6 +583,8 @@ export default Vue.extend({
$nav-icon-only-threshold: 1279px;
$nav-hide-threshold: 650px;
$side-hide-threshold: 1090px;
+ $left-widgets-hide-threshold: 1600px;
+ $right-widgets-hide-threshold: 1090px;
min-height: 100vh;
box-sizing: border-box;
@@ -970,7 +981,19 @@ export default Vue.extend({
overflow: auto;
box-shadow: 1px 0 0 0 var(--divider), -1px 0 0 0 var(--divider);
- @media (max-width: $side-hide-threshold) {
+ &:first-of-type {
+ order: -1;
+
+ @media (max-width: $left-widgets-hide-threshold) {
+ display: none;
+ }
+ }
+
+ &:empty {
+ display: none;
+ }
+
+ @media (max-width: $right-widgets-hide-threshold) {
display: none;
}