Fix: css modulesを使うように

その他修正

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-11-03 03:07:05 +09:00
parent 28dd05216f
commit 1d30c51d77
No known key found for this signature in database
GPG Key ID: 068E54E2C33BEF9A
7 changed files with 198 additions and 231 deletions

@ -1 +1 @@
Subproject commit 0179793ec891856d6f37a3be16ba4c22f67a81b5 Subproject commit cf3ce27b2eb8417233072e3d6d2fb7c5356c2364

View File

@ -18,20 +18,20 @@
<MkPagination ref="emojisPaginationComponent" :pagination="pagination" :displayLimit="100"> <MkPagination ref="emojisPaginationComponent" :pagination="pagination" :displayLimit="100">
<template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template> <template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template>
<template #default="{items}"> <template #default="{items}">
<div class="ldhfsamy"> <div :class="$style.root">
<div v-for="emoji in items" :key="emoji.id"> <div v-for="emoji in items" :key="emoji.id">
<button v-if="emoji.request" class="emoji _panel _button emoji-request" :class="{ selected: selectedEmojis.includes(emoji.id) }" @click="selectMode ? toggleSelect(emoji) : edit(emoji)"> <button v-if="emoji.request" class="_panel _button" :class="[{ selected: selectedEmojis.includes(emoji.id) },$style.emoji,$style.emojirequest]" @click="selectMode ? toggleSelect(emoji) : edit(emoji)">
<img :src="emoji.url" class="img" :alt="emoji.name"/> <img :src="emoji.url" class="img" :alt="emoji.name"/>
<div class="body"> <div class="body">
<div class="name _monospace">{{ emoji.name }}</div> <div class="name _monospace">{{ emoji.name }}</div>
<div class="info">{{ emoji.category }}</div> <div class="info">{{ emoji.category }}</div>
</div> </div>
</button> </button>
<button v-else class="emoji _panel _button" :class="{ selected: selectedEmojis.includes(emoji.id) }" @click="selectMode ? toggleSelect(emoji) : edit(emoji)"> <button v-else class="_panel _button" :class="[{ selected: selectedEmojis.includes(emoji.id) },$style.emoji]" @click="selectMode ? toggleSelect(emoji) : edit(emoji)">
<img :src="emoji.url" class="img" :alt="emoji.name"/> <img :src="emoji.url" :class="$style.img" :alt="emoji.name"/>
<div class="body"> <div :class="$style.body">
<div class="name _monospace">{{ emoji.name }}</div> <div :class="$style.name" class="_monospace">{{ emoji.name }}</div>
<div class="info">{{ emoji.category }}</div> <div :class="$style.info">{{ emoji.category }}</div>
</div> </div>
</button> </button>
</div> </div>
@ -82,7 +82,7 @@ const toggleSelect = (emoji) => {
const edit = (emoji) => { const edit = (emoji) => {
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), { os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), {
emoji: emoji, emoji: emoji,
requestNow: false, isRequest: false,
}, { }, {
done: result => { done: result => {
if (result.updated) { if (result.updated) {
@ -171,53 +171,48 @@ const delBulk = async () => {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.ldhfsamy { .root {
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
grid-gap: var(--margin); grid-gap: var(--margin);
}
.emoji {
display: flex;
align-items: center;
padding: 11px;
text-align: left;
border: solid 1px var(--panel);
width: 100%;
div > .emoji { &:hover {
display: flex; border-color: var(--inputBorderHover);
align-items: center; }
padding: 11px;
text-align: left;
border: solid 1px var(--panel);
width: 100%;
&:hover { &.selected {
border-color: var(--inputBorderHover); border-color: var(--accent);
} }
}
&.selected { .img {
border-color: var(--accent); width: 42px;
} height: 42px;
}
> .img { .body {
width: 42px; padding: 0 0 0 8px;
height: 42px; white-space: nowrap;
} overflow: hidden;
}
> .body { .name {
padding: 0 0 0 8px; text-overflow: ellipsis;
white-space: nowrap; overflow: hidden;
overflow: hidden;
> .name {
text-overflow: ellipsis;
overflow: hidden;
}
> .info {
opacity: 0.5;
text-overflow: ellipsis;
overflow: hidden;
}
}
}
} }
.emoji-request { .info {
opacity: 0.5;
text-overflow: ellipsis;
overflow: hidden;
}
.emojirequest {
--c: rgb(255 196 0 / 15%);; --c: rgb(255 196 0 / 15%);;
background-image: linear-gradient(45deg,var(--c) 16.67%,transparent 16.67%,transparent 50%,var(--c) 50%,var(--c) 66.67%,transparent 66.67%,transparent 100%); background-image: linear-gradient(45deg,var(--c) 16.67%,transparent 16.67%,transparent 50%,var(--c) 50%,var(--c) 66.67%,transparent 66.67%,transparent 100%);
background-size: 16px 16px; background-size: 16px 16px;

View File

@ -11,12 +11,12 @@
<MkPagination :pagination="remotePagination"> <MkPagination :pagination="remotePagination">
<template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template> <template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template>
<template #default="{items}"> <template #default="{items}">
<div class="ldhfsamy"> <div :class="$style.root">
<div v-for="emoji in items" :key="emoji.id" class="emoji _panel _button" @click="remoteMenu(emoji, $event)"> <div v-for="emoji in items" :key="emoji.id" :class="$style.emoji" class="_panel _button" @click="remoteMenu(emoji, $event)">
<img :src="`/emoji/${emoji.name}@${emoji.host}.webp`" class="img" :alt="emoji.name"/> <img :src="`/emoji/${emoji.name}@${emoji.host}.webp`" :class="$style.img" :alt="emoji.name"/>
<div class="body"> <div :class="$style.body">
<div class="name _monospace">{{ emoji.name }}</div> <div :class="$style.name" class="_monospace">{{ emoji.name }}</div>
<div class="info">{{ emoji.host }}</div> <div :class="$style.info">{{ emoji.host }}</div>
</div> </div>
</div> </div>
</div> </div>
@ -62,49 +62,45 @@ const remoteMenu = (emoji, ev: MouseEvent) => {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.empty {
margin: var(--margin); .root {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
grid-gap: 12px;
margin: var(--margin) 0;
} }
.ldhfsamy { .emoji {
display: grid; display: flex;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-items: center;
grid-gap: 12px; padding: 12px;
margin: var(--margin) 0; text-align: left;
> .emoji { &:hover {
display: flex; color: var(--accent);
align-items: center; }
padding: 12px; }
text-align: left;
&:hover { .img {
color: var(--accent); width: 32px;
} height: 32px;
}
> .img { .body {
width: 32px; padding: 0 0 0 8px;
height: 32px; white-space: nowrap;
} overflow: hidden;
}
.name {
text-overflow: ellipsis;
overflow: hidden;
}
> .body { .info {
padding: 0 0 0 8px; opacity: 0.5;
white-space: nowrap; font-size: 90%;
overflow: hidden; text-overflow: ellipsis;
overflow: hidden;
> .name {
text-overflow: ellipsis;
overflow: hidden;
}
> .info {
opacity: 0.5;
font-size: 90%;
text-overflow: ellipsis;
overflow: hidden;
}
}
}
} }
</style> </style>

View File

@ -2,33 +2,31 @@
<MkPagination ref="emojisRequestPaginationComponent" :pagination="paginationRequest"> <MkPagination ref="emojisRequestPaginationComponent" :pagination="paginationRequest">
<template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template> <template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template>
<template #default="{items}"> <template #default="{items}">
<div class="ldhfsamy"> <template v-for="emoji in items" :key="emoji.id">
<template v-for="emoji in items" :key="emoji.id"> <div :class="$style.emoji" class="_panel">
<div class="emoji _panel"> <div :class="$style.img">
<div class="img"> <div :class="$style.imgLight"><img :src="emoji.url" :alt="emoji.name"/></div>
<div class="imgLight"><img :src="emoji.url" :alt="emoji.name"/></div> <div :class="$style.imgDark"><img :src="emoji.url" :alt="emoji.name"/></div>
<div class="imgDark"><img :src="emoji.url" :alt="emoji.name"/></div>
</div>
<div class="info">
<div class="name">{{ i18n.ts.name }}: {{ emoji.name }}</div>
<div class="category">{{ i18n.ts.category }}:{{ emoji.category }}</div>
<div class="aliases">{{ i18n.ts.tags }}:{{ emoji.aliases.join(' ') }}</div>
<div class="license">{{ i18n.ts.license }}:{{ emoji.license }}</div>
</div>
<div class="edit-button">
<MkButton primary class="edit" @click="editRequest(emoji)">
{{ i18n.ts.edit }}
</MkButton>
<MkButton class="request" @click="unrequested(emoji)">
{{ i18n.ts.approve }}
</MkButton>
<MkButton danger class="delete" @click="deleteRequest(emoji)">
{{ i18n.ts.delete }}
</MkButton>
</div>
</div> </div>
</template> <div :class="$style.info">
</div> <div :class="$style.name">{{ i18n.ts.name }}: {{ emoji.name }}</div>
<div :class="$style.category">{{ i18n.ts.category }}:{{ emoji.category }}</div>
<div :class="$style.aliases">{{ i18n.ts.tags }}:{{ emoji.aliases.join(' ') }}</div>
<div :class="$style.license">{{ i18n.ts.license }}:{{ emoji.license }}</div>
</div>
<div :class="$style.editbutton">
<MkButton primary :class="$style.edit" @click="editRequest(emoji)">
{{ i18n.ts.edit }}
</MkButton>
<MkButton :class="$style.request" @click="unrequested(emoji)">
{{ i18n.ts.approve }}
</MkButton>
<MkButton danger :class="$style.delete" @click="deleteRequest(emoji)">
{{ i18n.ts.delete }}
</MkButton>
</div>
</div>
</template>
</template> </template>
</MkPagination> </MkPagination>
</template> </template>
@ -52,12 +50,10 @@ const paginationRequest = {
})), })),
}; };
const editRequest = (emoji) => { function editRequest(emoji) {
emoji.requestNow = true;
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), { os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), {
emoji: emoji, emoji: emoji,
requestNow: false, isRequest: true,
isRequestEdit: true,
}, { }, {
done: result => { done: result => {
if (result.updated) { if (result.updated) {
@ -72,7 +68,7 @@ const editRequest = (emoji) => {
} }
}, },
}, 'closed'); }, 'closed');
}; }
async function unrequested(emoji) { async function unrequested(emoji) {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
@ -113,103 +109,90 @@ async function deleteRequest(emoji) {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.empty { .emoji {
margin: var(--margin); align-items: center;
padding: 11px;
text-align: left;
border: solid 1px var(--panel);
margin: 10px;
}
.img {
display: grid;
grid-row: 1;
grid-column: 1/ span 2;
grid-template-columns: 50% 50%;
place-content: center;
place-items: center;
}
.imgLight {
display: grid;
grid-column: 1;
background-color: #fff;
margin-bottom: 12px;
img {
max-height: 64px;
max-width: 100%;
}
}
.imgDark {
display: grid;
grid-column: 2;
background-color: #000;
margin-bottom: 12px;
img {
max-height: 64px;
max-width: 100%;
}
}
.info {
display: grid;
grid-row: 2;
grid-template-rows: 30px 30px 30px;
}
.name {
grid-row: 1;
text-overflow: ellipsis;
overflow: hidden;
} }
.ldhfsamy { .category {
> .emoji { grid-row: 2;
align-items: center; text-overflow: ellipsis;
padding: 11px; overflow: hidden;
text-align: left; }
border: solid 1px var(--panel);
margin: 10px;
> .img { .aliases {
display: grid; grid-row: 3;
grid-row: 1; text-overflow: ellipsis;
grid-column: 1/ span 2; overflow: hidden;
grid-template-columns: 50% 50%; }
place-content: center;
place-items: center;
> .imgLight { .license {
display: grid; grid-row: 4;
grid-column: 1; text-overflow: ellipsis;
background-color: #fff; overflow: hidden;
margin-bottom: 12px; }
> img { .editbutton {
max-height: 64px; display: grid;
max-width: 100%; grid-template-rows: 42px;
} margin-top: 6px;
} }
.edit {
grid-row: 1;
width: 100%;
margin: 6px 0;
}
> .imgDark { .request {
display: grid; grid-row: 2;
grid-column: 2; width: 100%;
background-color: #000; margin: 6px 0;
margin-bottom: 12px; }
> img {
max-height: 64px;
max-width: 100%;
}
}
}
> .info { .delete {
display: grid; grid-row: 3;
grid-row: 2; width: 100%;
grid-template-rows: 30px 30px 30px; margin: 6px 0;
> .name {
grid-row: 1;
text-overflow: ellipsis;
overflow: hidden;
}
> .category {
grid-row: 2;
text-overflow: ellipsis;
overflow: hidden;
}
> .aliases {
grid-row: 3;
text-overflow: ellipsis;
overflow: hidden;
}
> .license {
grid-row: 4;
text-overflow: ellipsis;
overflow: hidden;
}
}
> .edit-button {
display: grid;
grid-template-rows: 42px;
margin-top: 6px;
> .edit {
grid-row: 1;
width: 100%;
margin: 6px 0;
}
> .request {
grid-row: 2;
width: 100%;
margin: 6px 0;
}
> .delete {
grid-row: 3;
width: 100%;
margin: 6px 0;
}
}
}
} }
</style> </style>

View File

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
@closed="$emit('closed')" @closed="$emit('closed')"
> >
<template v-if="emoji" #header>:{{ emoji.name }}:</template> <template v-if="emoji" #header>:{{ emoji.name }}:</template>
<template v-else-if="requestNow" #header>{{ i18n.ts.requestCustomEmojis }}</template> <template v-else-if="isRequest && !emoji" #header>{{ i18n.ts.requestCustomEmojis }}</template>
<template v-else #header>New emoji</template> <template v-else #header>New emoji</template>
<div> <div>
@ -46,7 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="license"> <MkInput v-model="license">
<template #label>{{ i18n.ts.license }}</template> <template #label>{{ i18n.ts.license }}</template>
</MkInput> </MkInput>
<MkFolder v-if="!requestNow && !isRequestEdit"> <MkFolder v-if="!isRequest">
<template #label>{{ i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction }}</template> <template #label>{{ i18n.ts.rolesThatCanBeUsedThisEmojiAsReaction }}</template>
<template #suffix>{{ rolesThatCanBeUsedThisEmojiAsReaction.length === 0 ? i18n.ts.all : rolesThatCanBeUsedThisEmojiAsReaction.length }}</template> <template #suffix>{{ rolesThatCanBeUsedThisEmojiAsReaction.length === 0 ? i18n.ts.all : rolesThatCanBeUsedThisEmojiAsReaction.length }}</template>
@ -65,14 +65,11 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkFolder> </MkFolder>
<MkSwitch v-model="isSensitive">isSensitive</MkSwitch> <MkSwitch v-model="isSensitive">isSensitive</MkSwitch>
<MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch> <MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch>
<MkSwitch v-if="!requestNow" v-model="isRequest" :disabled="requestNow">
{{ i18n.ts.requestPending }}
</MkSwitch>
</div> </div>
</MkSpacer> </MkSpacer>
<div :class="$style.footer"> <div :class="$style.footer">
<div :class="$style.footerButtons"> <div :class="$style.footerButtons">
<MkButton v-if="!requestNow" danger rounded style="margin: 0 auto;" @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton> <MkButton v-if="!isRequest" danger rounded style="margin: 0 auto;" @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
<MkButton v-if="validation" primary rounded style="margin: 0 auto;" @click="done"><i class="ti ti-check"></i> {{ props.emoji ? i18n.ts.update : i18n.ts.create }}</MkButton> <MkButton v-if="validation" primary rounded style="margin: 0 auto;" @click="done"><i class="ti ti-check"></i> {{ props.emoji ? i18n.ts.update : i18n.ts.create }}</MkButton>
<MkButton v-else rounded style="margin: 0 auto;"><i class="ti ti-check"></i> {{ props.emoji ? i18n.ts.update : i18n.ts.create }}</MkButton> <MkButton v-else rounded style="margin: 0 auto;"><i class="ti ti-check"></i> {{ props.emoji ? i18n.ts.update : i18n.ts.create }}</MkButton>
</div> </div>
@ -99,8 +96,7 @@ import MkRolePreview from '@/components/MkRolePreview.vue';
const props = defineProps<{ const props = defineProps<{
emoji?: any, emoji?: any,
requestNow: boolean, isRequest: boolean,
isRequestEdit?: boolean,
}>(); }>();
let dialog = $ref(null); let dialog = $ref(null);
@ -114,14 +110,12 @@ let roleIdsThatCanBeUsedThisEmojiAsReaction = $ref((props.emoji && props.emoji.r
let rolesThatCanBeUsedThisEmojiAsReaction = $ref([]); let rolesThatCanBeUsedThisEmojiAsReaction = $ref([]);
let file = $ref<Misskey.entities.DriveFile>(); let file = $ref<Misskey.entities.DriveFile>();
let chooseFile: DriveFile|null = $ref(null); let chooseFile: DriveFile|null = $ref(null);
let requestNow = $ref(props.requestNow); let isRequest = $ref(props.isRequest ?? false);
let isRequestEdit = $ref(props.isRequestEdit ?? false);
let isRequest = $ref(!!(isRequestEdit || props.requestNow));
watch($$(roleIdsThatCanBeUsedThisEmojiAsReaction), async () => { watch($$(roleIdsThatCanBeUsedThisEmojiAsReaction), async () => {
rolesThatCanBeUsedThisEmojiAsReaction = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.map((id) => os.api('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null); rolesThatCanBeUsedThisEmojiAsReaction = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.map((id) => os.api('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
}, { immediate: true }); }, { immediate: true });
const imgUrl = computed(() => file ? file.url : props.emoji && !isRequestEdit ? `/emoji/${props.emoji.name}.webp` : props.emoji && props.emoji.url ? props.emoji.url : null); const imgUrl = computed(() => file ? file.url : props.emoji && !isRequest ? `/emoji/${props.emoji.name}.webp` : props.emoji && props.emoji.url ? props.emoji.url : null);
const validation = computed(() => { const validation = computed(() => {
return name.match(/^[a-zA-Z0-9_]+$/) && imgUrl.value != null; return name.match(/^[a-zA-Z0-9_]+$/) && imgUrl.value != null;
}); });
@ -171,7 +165,7 @@ async function done() {
} }
if (props.emoji) { if (props.emoji) {
if (isRequestEdit) { if (isRequest) {
await os.apiWithDialog('admin/emoji/update-request', { await os.apiWithDialog('admin/emoji/update-request', {
id: props.emoji.id, id: props.emoji.id,
...params, ...params,

View File

@ -98,7 +98,7 @@ function search() {
const edit = () => { const edit = () => {
os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), { os.popup(defineAsyncComponent(() => import('@/components/MkEmojiEditDialog.vue')), {
requestNow: true, isRequest: true,
}, { }, {
done: result => { done: result => {
window.location.reload(); window.location.reload();

View File

@ -319,7 +319,6 @@ export type CustomEmoji = {
url: string; url: string;
category: string; category: string;
aliases: string[]; aliases: string[];
Request: boolean;
}; };
export type LiteInstanceMetadata = { export type LiteInstanceMetadata = {