chore(client): tweak ui

This commit is contained in:
syuilo 2022-06-30 21:38:34 +09:00
parent 1bec974fe6
commit 4c2cd3c8d5
6 changed files with 126 additions and 118 deletions

View file

@ -112,9 +112,9 @@ function createDoughnut(chartEl, tooltip, data) {
labels: data.map(x => x.name), labels: data.map(x => x.name),
datasets: [{ datasets: [{
backgroundColor: data.map(x => x.color), backgroundColor: data.map(x => x.color),
borderWidth: 0, borderColor: getComputedStyle(document.documentElement).getPropertyValue('--panel'),
spacing: 4, borderWidth: 2,
hoverOffset: 4, hoverOffset: 0,
data: data.map(x => x.value), data: data.map(x => x.value),
}], }],
}, },

View file

@ -64,9 +64,9 @@ onMounted(() => {
labels: props.data.map(x => x.name), labels: props.data.map(x => x.name),
datasets: [{ datasets: [{
backgroundColor: props.data.map(x => x.color), backgroundColor: props.data.map(x => x.color),
borderWidth: 0, borderColor: getComputedStyle(document.documentElement).getPropertyValue('--panel'),
spacing: 4, borderWidth: 2,
hoverOffset: 4, hoverOffset: 0,
data: props.data.map(x => x.value), data: props.data.map(x => x.value),
}], }],
}, },

View file

@ -1,30 +1,33 @@
<template> <template>
<div> <MkStickyContainer>
<FormSuspense :p="init"> <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<FormInput v-model="title"> <MkSpacer :content-max="800" :margin-min="16" :margin-max="32">
<template #label>{{ $ts.title }}</template> <FormSuspense :p="init">
</FormInput> <FormInput v-model="title">
<template #label>{{ $ts.title }}</template>
</FormInput>
<FormTextarea v-model="description" :max="500"> <FormTextarea v-model="description" :max="500">
<template #label>{{ $ts.description }}</template> <template #label>{{ $ts.description }}</template>
</FormTextarea> </FormTextarea>
<div class=""> <div class="">
<div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : null }"> <div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : null }">
<div class="name">{{ file.name }}</div> <div class="name">{{ file.name }}</div>
<button v-tooltip="$ts.remove" class="remove _button" @click="remove(file)"><i class="fas fa-times"></i></button> <button v-tooltip="$ts.remove" class="remove _button" @click="remove(file)"><i class="fas fa-times"></i></button>
</div>
<FormButton primary @click="selectFile"><i class="fas fa-plus"></i> {{ $ts.attachFile }}</FormButton>
</div> </div>
<FormButton primary @click="selectFile"><i class="fas fa-plus"></i> {{ $ts.attachFile }}</FormButton>
</div>
<FormSwitch v-model="isSensitive">{{ $ts.markAsSensitive }}</FormSwitch> <FormSwitch v-model="isSensitive">{{ $ts.markAsSensitive }}</FormSwitch>
<FormButton v-if="postId" primary @click="save"><i class="fas fa-save"></i> {{ $ts.save }}</FormButton> <FormButton v-if="postId" primary @click="save"><i class="fas fa-save"></i> {{ $ts.save }}</FormButton>
<FormButton v-else primary @click="save"><i class="fas fa-save"></i> {{ $ts.publish }}</FormButton> <FormButton v-else primary @click="save"><i class="fas fa-save"></i> {{ $ts.publish }}</FormButton>
<FormButton v-if="postId" danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</FormButton> <FormButton v-if="postId" danger @click="del"><i class="fas fa-trash-alt"></i> {{ $ts.delete }}</FormButton>
</FormSuspense> </FormSuspense>
</div> </MkSpacer>
</MkStickyContainer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -71,7 +74,7 @@ async function save() {
fileIds: files.map(file => file.id), fileIds: files.map(file => file.id),
isSensitive: isSensitive, isSensitive: isSensitive,
}); });
mainRouter.push(`/gallery/${props.postId}`); router.push(`/gallery/${props.postId}`);
} else { } else {
const created = await os.apiWithDialog('gallery/posts/create', { const created = await os.apiWithDialog('gallery/posts/create', {
title: title, title: title,
@ -92,7 +95,7 @@ async function del() {
await os.apiWithDialog('gallery/posts/delete', { await os.apiWithDialog('gallery/posts/delete', {
postId: props.postId, postId: props.postId,
}); });
mainRouter.push('/gallery'); router.push('/gallery');
} }
watch(() => props.postId, () => { watch(() => props.postId, () => {
@ -113,9 +116,11 @@ const headerTabs = $computed(() => []);
definePageMetadata(computed(() => props.postId ? { definePageMetadata(computed(() => props.postId ? {
title: i18n.ts.edit, title: i18n.ts.edit,
icon: 'fas fa-pencil-alt', icon: 'fas fa-pencil-alt',
bg: 'var(--bg)',
} : { } : {
title: i18n.ts.postToGallery, title: i18n.ts.postToGallery,
icon: 'fas fa-pencil-alt', icon: 'fas fa-pencil-alt',
bg: 'var(--bg)',
})); }));
</script> </script>

View file

@ -1,14 +1,8 @@
<template> <template>
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :content-max="1400"> <MkSpacer :content-max="1400">
<div class="_root"> <div class="_root">
<MkTab v-if="$i" v-model="tab">
<option value="explore"><i class="fas fa-icons"></i> {{ $ts.gallery }}</option>
<option value="liked"><i class="fas fa-heart"></i> {{ $ts._gallery.liked }}</option>
<option value="my"><i class="fas fa-edit"></i> {{ $ts._gallery.my }}</option>
</MkTab>
<div v-if="tab === 'explore'"> <div v-if="tab === 'explore'">
<MkFolder class="_gap"> <MkFolder class="_gap">
<template #header><i class="fas fa-clock"></i>{{ $ts.recentPosts }}</template> <template #header><i class="fas fa-clock"></i>{{ $ts.recentPosts }}</template>
@ -60,6 +54,9 @@ import number from '@/filters/number';
import * as os from '@/os'; import * as os from '@/os';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { useRouter } from '@/router';
const router = useRouter();
const props = defineProps<{ const props = defineProps<{
tag?: string; tag?: string;
@ -100,9 +97,27 @@ watch(() => props.tag, () => {
if (tagsRef) tagsRef.tags.toggleContent(props.tag == null); if (tagsRef) tagsRef.tags.toggleContent(props.tag == null);
}); });
const headerActions = $computed(() => []); const headerActions = $computed(() => [{
icon: 'fas fa-plus',
text: i18n.ts.create,
handler: () => {
router.push('/gallery/new');
},
}]);
const headerTabs = $computed(() => []); const headerTabs = $computed(() => [{
key: 'explore',
title: i18n.ts.gallery,
icon: 'fas fa-icons',
}, {
key: 'liked',
title: i18n.ts._gallery.liked,
icon: 'fas fa-heart',
}, {
key: 'my',
title: i18n.ts._gallery.my,
icon: 'fas fa-edit',
}]);
definePageMetadata({ definePageMetadata({
title: i18n.ts.gallery, title: i18n.ts.gallery,

View file

@ -1,52 +1,57 @@
<template> <template>
<div class="_root"> <MkStickyContainer>
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in"> <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<div v-if="post" class="rkxwuolj"> <MkSpacer :content-max="1000" :margin-min="16" :margin-max="32">
<div class="files"> <div class="_root">
<div v-for="file in post.files" :key="file.id" class="file"> <transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
<img :src="file.url"/> <div v-if="post" class="rkxwuolj">
</div> <div class="files">
</div> <div v-for="file in post.files" :key="file.id" class="file">
<div class="body _block"> <img :src="file.url"/>
<div class="title">{{ post.title }}</div> </div>
<div class="description"><Mfm :text="post.description"/></div>
<div class="info">
<i class="fas fa-clock"></i> <MkTime :time="post.createdAt" mode="detail"/>
</div>
<div class="actions">
<div class="like">
<MkButton v-if="post.isLiked" v-tooltip="$ts._gallery.unlike" class="button" primary @click="unlike()"><i class="fas fa-heart"></i><span v-if="post.likedCount > 0" class="count">{{ post.likedCount }}</span></MkButton>
<MkButton v-else v-tooltip="$ts._gallery.like" class="button" @click="like()"><i class="far fa-heart"></i><span v-if="post.likedCount > 0" class="count">{{ post.likedCount }}</span></MkButton>
</div> </div>
<div class="other"> <div class="body _block">
<button v-if="$i && $i.id === post.user.id" v-tooltip="$ts.edit" v-click-anime class="_button" @click="edit"><i class="fas fa-pencil-alt fa-fw"></i></button> <div class="title">{{ post.title }}</div>
<button v-tooltip="$ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="fas fa-retweet fa-fw"></i></button> <div class="description"><Mfm :text="post.description"/></div>
<button v-tooltip="$ts.share" v-click-anime class="_button" @click="share"><i class="fas fa-share-alt fa-fw"></i></button> <div class="info">
<i class="fas fa-clock"></i> <MkTime :time="post.createdAt" mode="detail"/>
</div>
<div class="actions">
<div class="like">
<MkButton v-if="post.isLiked" v-tooltip="$ts._gallery.unlike" class="button" primary @click="unlike()"><i class="fas fa-heart"></i><span v-if="post.likedCount > 0" class="count">{{ post.likedCount }}</span></MkButton>
<MkButton v-else v-tooltip="$ts._gallery.like" class="button" @click="like()"><i class="far fa-heart"></i><span v-if="post.likedCount > 0" class="count">{{ post.likedCount }}</span></MkButton>
</div>
<div class="other">
<button v-if="$i && $i.id === post.user.id" v-tooltip="$ts.edit" v-click-anime class="_button" @click="edit"><i class="fas fa-pencil-alt fa-fw"></i></button>
<button v-tooltip="$ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="fas fa-retweet fa-fw"></i></button>
<button v-tooltip="$ts.share" v-click-anime class="_button" @click="share"><i class="fas fa-share-alt fa-fw"></i></button>
</div>
</div>
<div class="user">
<MkAvatar :user="post.user" class="avatar"/>
<div class="name">
<MkUserName :user="post.user" style="display: block;"/>
<MkAcct :user="post.user"/>
</div>
<MkFollowButton v-if="!$i || $i.id != post.user.id" :user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
</div>
</div> </div>
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
<MkContainer :max-height="300" :foldable="true" class="other">
<template #header><i class="fas fa-clock"></i> {{ $ts.recentPosts }}</template>
<MkPagination v-slot="{items}" :pagination="otherPostsPagination">
<div class="sdrarzaf">
<MkGalleryPostPreview v-for="post in items" :key="post.id" :post="post" class="post"/>
</div>
</MkPagination>
</MkContainer>
</div> </div>
<div class="user"> <MkError v-else-if="error" @retry="fetch()"/>
<MkAvatar :user="post.user" class="avatar"/> <MkLoading v-else/>
<div class="name"> </transition>
<MkUserName :user="post.user" style="display: block;"/>
<MkAcct :user="post.user"/>
</div>
<MkFollowButton v-if="!$i || $i.id != post.user.id" :user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
</div>
</div>
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
<MkContainer :max-height="300" :foldable="true" class="other">
<template #header><i class="fas fa-clock"></i> {{ $ts.recentPosts }}</template>
<MkPagination v-slot="{items}" :pagination="otherPostsPagination">
<div class="sdrarzaf">
<MkGalleryPostPreview v-for="post in items" :key="post.id" :post="post" class="post"/>
</div>
</MkPagination>
</MkContainer>
</div> </div>
<MkError v-else-if="error" @retry="fetch()"/> </MkSpacer>
<MkLoading v-else/> </MkStickyContainer>
</transition>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -133,23 +138,18 @@ function edit() {
watch(() => props.postId, fetchPost, { immediate: true }); watch(() => props.postId, fetchPost, { immediate: true });
const headerActions = $computed(() => []); const headerActions = $computed(() => [{
icon: 'fas fa-pencil-alt',
text: i18n.ts.edit,
handler: edit,
}]);
const headerTabs = $computed(() => []); const headerTabs = $computed(() => []);
definePageMetadata(computed(() => post ? { definePageMetadata(computed(() => post ? {
title: post.title, title: post.title,
avatar: post.user, avatar: post.user,
path: `/gallery/${post.id}`, bg: 'var(--bg)',
share: {
title: post.title,
text: post.description,
},
actions: [{
icon: 'fas fa-pencil-alt',
text: i18n.ts.edit,
handler: edit,
}],
} : null)); } : null));
</script> </script>

View file

@ -8,36 +8,24 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { computed, defineComponent } from 'vue'; import { computed } from 'vue';
import * as misskey from 'misskey-js';
import MkGalleryPostPreview from '@/components/gallery-post-preview.vue'; import MkGalleryPostPreview from '@/components/gallery-post-preview.vue';
import MkPagination from '@/components/ui/pagination.vue'; import MkPagination from '@/components/ui/pagination.vue';
export default defineComponent({ const props = withDefaults(defineProps<{
components: { user: misskey.entities.User;
MkPagination, }>(), {
MkGalleryPostPreview,
},
props: {
user: {
type: Object,
required: true
},
},
data() {
return {
pagination: {
endpoint: 'users/gallery/posts' as const,
limit: 6,
params: computed(() => ({
userId: this.user.id
})),
},
};
},
}); });
const pagination = {
endpoint: 'users/gallery/posts' as const,
limit: 6,
params: computed(() => ({
userId: props.user.id,
})),
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>