summaryrefslogtreecommitdiff
path: root/packages/client/src/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-12-30 21:47:48 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-12-30 21:47:48 +0900
commit616b18a9e520aa5beee0719c1b92b13bb60c91b4 (patch)
tree2f3bf9585a35b71b2757a1a3e06a10f6ee4ee14f /packages/client/src/components
parentenhance: pizzaxでstreamingのuser storage updateイベントを監視して... (diff)
downloadmisskey-616b18a9e520aa5beee0719c1b92b13bb60c91b4.tar.gz
misskey-616b18a9e520aa5beee0719c1b92b13bb60c91b4.tar.bz2
misskey-616b18a9e520aa5beee0719c1b92b13bb60c91b4.zip
enhance(client): tweak ui
Diffstat (limited to 'packages/client/src/components')
-rw-r--r--packages/client/src/components/form/section.vue7
-rw-r--r--packages/client/src/components/form/split.vue27
-rw-r--r--packages/client/src/components/form/switch.vue3
-rw-r--r--packages/client/src/components/user-select-dialog.vue148
4 files changed, 105 insertions, 80 deletions
diff --git a/packages/client/src/components/form/section.vue b/packages/client/src/components/form/section.vue
index bc2ab966b8..ab9fbe5fcd 100644
--- a/packages/client/src/components/form/section.vue
+++ b/packages/client/src/components/form/section.vue
@@ -7,12 +7,7 @@
</div>
</template>
-<script lang="ts">
-import { defineComponent } from 'vue';
-
-export default defineComponent({
-
-});
+<script lang="ts" setup>
</script>
<style lang="scss" scoped>
diff --git a/packages/client/src/components/form/split.vue b/packages/client/src/components/form/split.vue
new file mode 100644
index 0000000000..676b293967
--- /dev/null
+++ b/packages/client/src/components/form/split.vue
@@ -0,0 +1,27 @@
+<template>
+<div class="terlnhxf _formBlock">
+ <slot></slot>
+</div>
+</template>
+
+<script lang="ts" setup>
+const props = withDefaults(defineProps<{
+ minWidth: number;
+}>(), {
+ minWidth: 210,
+});
+
+const minWidth = props.minWidth + 'px';
+</script>
+
+<style lang="scss" scoped>
+.terlnhxf {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(v-bind('minWidth'), 1fr));
+ grid-gap: 12px;
+
+ > ::v-deep(*) {
+ margin: 0 !important;
+ }
+}
+</style>
diff --git a/packages/client/src/components/form/switch.vue b/packages/client/src/components/form/switch.vue
index aa9b09215e..ac3284e7da 100644
--- a/packages/client/src/components/form/switch.vue
+++ b/packages/client/src/components/form/switch.vue
@@ -13,7 +13,8 @@
<i class="check fas fa-check"></i>
</span>
<span class="label">
- <span @click="toggle"><slot></slot></span>
+ <!-- TODO: 無名slotの方は廃止 -->
+ <span @click="toggle"><slot name="label"></slot><slot></slot></span>
<p class="caption"><slot name="caption"></slot></p>
</span>
</div>
diff --git a/packages/client/src/components/user-select-dialog.vue b/packages/client/src/components/user-select-dialog.vue
index ba2975478b..dbef34d547 100644
--- a/packages/client/src/components/user-select-dialog.vue
+++ b/packages/client/src/components/user-select-dialog.vue
@@ -1,5 +1,5 @@
<template>
-<XModalWindow ref="dialog"
+<XModalWindow ref="dialogEl"
:with-ok-button="true"
:ok-button-disabled="selected == null"
@click="cancel()"
@@ -8,20 +8,20 @@
@closed="$emit('closed')"
>
<template #header>{{ $ts.selectUser }}</template>
- <div class="tbhwbxda _monolithic_">
- <div class="_section">
- <div class="_inputSplit">
- <MkInput ref="username" v-model="username" class="input" @update:modelValue="search">
+ <div class="tbhwbxda">
+ <div class="form">
+ <FormSplit :min-width="170">
+ <MkInput ref="usernameEl" v-model="username" @update:modelValue="search">
<template #label>{{ $ts.username }}</template>
<template #prefix>@</template>
</MkInput>
- <MkInput v-model="host" class="input" @update:modelValue="search">
+ <MkInput v-model="host" @update:modelValue="search">
<template #label>{{ $ts.host }}</template>
<template #prefix>@</template>
</MkInput>
- </div>
+ </FormSplit>
</div>
- <div v-if="username != '' || host != ''" class="_section result" :class="{ hit: users.length > 0 }">
+ <div v-if="username != '' || host != ''" class="result" :class="{ hit: users.length > 0 }">
<div v-if="users.length > 0" class="users">
<div v-for="user in users" :key="user.id" class="user" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
@@ -35,7 +35,7 @@
<span>{{ $ts.noUsers }}</span>
</div>
</div>
- <div v-if="username == '' && host == ''" class="_section recent">
+ <div v-if="username == '' && host == ''" class="recent">
<div class="users">
<div v-for="user in recentUsers" :key="user.id" class="user" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
<MkAvatar :user="user" class="avatar" :show-indicator="true"/>
@@ -50,87 +50,89 @@
</XModalWindow>
</template>
-<script lang="ts">
-import { defineComponent } from 'vue';
-import MkInput from './form/input.vue';
+<script lang="ts" setup>
+import { nextTick, onMounted } from 'vue';
+import * as misskey from 'misskey-js';
+import MkInput from '@/components/form/input.vue';
+import FormSplit from '@/components/form/split.vue';
import XModalWindow from '@/components/ui/modal-window.vue';
import * as os from '@/os';
+import { defaultStore } from '@/store';
-export default defineComponent({
- components: {
- MkInput,
- XModalWindow,
- },
-
- props: {
- },
+const emit = defineEmits<{
+ (e: 'ok', selected: misskey.entities.UserDetailed): void;
+ (e: 'cancel'): void;
+ (e: 'closed'): void;
+}>();
- emits: ['ok', 'cancel', 'closed'],
+let username = $ref('');
+let host = $ref('');
+let users: misskey.entities.UserDetailed[] = $ref([]);
+let recentUsers: misskey.entities.UserDetailed[] = $ref([]);
+let selected: misskey.entities.UserDetailed | null = $ref(null);
+let usernameEl: HTMLElement = $ref();
+let dialogEl = $ref();
- data() {
- return {
- username: '',
- host: '',
- recentUsers: [],
- users: [],
- selected: null,
- };
- },
+const focus = () => {
+ if (usernameEl) {
+ usernameEl.focus();
+ }
+};
- async mounted() {
- this.focus();
+const search = () => {
+ if (username === '' && host === '') {
+ users = [];
+ return;
+ }
+ os.api('users/search-by-username-and-host', {
+ username: username,
+ host: host,
+ limit: 10,
+ detail: false
+ }).then(_users => {
+ users = _users;
+ });
+};
- this.$nextTick(() => {
- this.focus();
- });
+const ok = () => {
+ if (selected == null) return;
+ emit('ok', selected);
+ dialogEl.close();
- this.recentUsers = await os.api('users/show', {
- userIds: this.$store.state.recentlyUsedUsers
- });
- },
+ // 最近使ったユーザー更新
+ let recents = defaultStore.state.recentlyUsedUsers;
+ recents = recents.filter(x => x !== selected.id);
+ recents.unshift(selected.id);
+ defaultStore.set('recentlyUsedUsers', recents.splice(0, 16));
+};
- methods: {
- search() {
- if (this.username == '' && this.host == '') {
- this.users = [];
- return;
- }
- os.api('users/search-by-username-and-host', {
- username: this.username,
- host: this.host,
- limit: 10,
- detail: false
- }).then(users => {
- this.users = users;
- });
- },
+const cancel = () => {
+ emit('cancel');
+ dialogEl.close();
+};
- focus() {
- this.$refs.username.focus();
- },
+onMounted(() => {
+ focus();
- ok() {
- this.$emit('ok', this.selected);
- this.$refs.dialog.close();
+ nextTick(() => {
+ focus();
+ });
- // 最近使ったユーザー更新
- let recents = this.$store.state.recentlyUsedUsers;
- recents = recents.filter(x => x !== this.selected.id);
- recents.unshift(this.selected.id);
- this.$store.set('recentlyUsedUsers', recents.splice(0, 16));
- },
-
- cancel() {
- this.$emit('cancel');
- this.$refs.dialog.close();
- },
- }
+ os.api('users/show', {
+ userIds: defaultStore.state.recentlyUsedUsers,
+ }).then(users => {
+ recentUsers = users;
+ });
});
</script>
<style lang="scss" scoped>
.tbhwbxda {
- > ._section {
+ > .form {
+ padding: 0 var(--root-margin);
+ }
+
+ > .result, > .recent {
display: flex;
flex-direction: column;
overflow: auto;