forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: メインタイムラインのタブをカスタマイズ可能に(misskey-dev#8759)
- Loading branch information
Showing
8 changed files
with
318 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
packages/frontend/src/pages/settings/timelineHeader.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: syuilo and misskey-project | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
--> | ||
|
||
<template> | ||
<div class="_gaps_m"> | ||
<FormSlot> | ||
<template #label>{{ i18n.ts.timelineHeader }}</template> | ||
<MkContainer :showHeader="false"> | ||
<Sortable | ||
v-model="items" | ||
itemKey="id" | ||
:animation="150" | ||
:handle="'.' + $style.itemHandle" | ||
@start="e => e.item.classList.add('active')" | ||
@end="e => e.item.classList.remove('active')" | ||
> | ||
<template #item="{element,index}"> | ||
<div | ||
v-if="element.type === '-' || timelineHeaderItemDef[element.type]" | ||
:class="$style.item" | ||
> | ||
<button class="_button" :class="$style.itemHandle"><i class="ti ti-menu"></i></button> | ||
|
||
<i class="ti-fw" :class="[$style.itemIcon, timelineHeaderItemDef[element.type]?.icon]"></i><span :class="$style.itemText">{{ timelineHeaderItemDef[element.type]?.title }}</span> | ||
<button class="_button" :class="$style.itemRemove" @click="removeItem(index)"><i class="ti ti-x"></i></button> | ||
</div> | ||
</template> | ||
</Sortable> | ||
</MkContainer> | ||
</FormSlot> | ||
<div class="_buttons"> | ||
<MkButton @click="addItem"><i class="ti ti-plus"></i> {{ i18n.ts.addItem }}</MkButton> | ||
<MkButton danger @click="reset"><i class="ti ti-reload"></i> {{ i18n.ts.default }}</MkButton> | ||
<MkButton primary class="save" @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import { computed, defineAsyncComponent, ref, watch } from 'vue'; | ||
import MkRadios from '@/components/MkRadios.vue'; | ||
import MkButton from '@/components/MkButton.vue'; | ||
import FormSlot from '@/components/form/slot.vue'; | ||
import MkContainer from '@/components/MkContainer.vue'; | ||
import * as os from '@/os.js'; | ||
import { navbarItemDef } from '@/navbar.js'; | ||
import { defaultStore } from '@/store.js'; | ||
import { unisonReload } from '@/scripts/unison-reload.js'; | ||
import { i18n } from '@/i18n.js'; | ||
import { definePageMetadata } from '@/scripts/page-metadata.js'; | ||
import { timelineHeaderItemDef } from '@/timelineHeader.js'; | ||
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default)); | ||
const items = ref(defaultStore.state.timelineTopBar.map(x => ({ | ||
id: Math.random().toString(), | ||
type: x, | ||
}))); | ||
async function reloadAsk() { | ||
const { canceled } = await os.confirm({ | ||
type: 'info', | ||
text: i18n.ts.reloadToApplySetting, | ||
}); | ||
if (canceled) return; | ||
unisonReload(); | ||
} | ||
async function addItem() { | ||
const menu = Object.keys(timelineHeaderItemDef).filter(k => !defaultStore.state.timelineTopBar.includes(k)); | ||
console.log(menu); | ||
const { canceled, result: item } = await os.select({ | ||
title: i18n.ts.addItem, | ||
items: [...menu.map(k => ({ | ||
value: k, text: timelineHeaderItemDef[k].title, | ||
}))], | ||
}); | ||
if (canceled) return; | ||
items.value = [...items.value, { | ||
id: Math.random().toString(), | ||
type: item, | ||
}]; | ||
} | ||
function removeItem(index: number) { | ||
items.value.splice(index, 1); | ||
} | ||
async function save() { | ||
defaultStore.set('timelineTopBar', items.value.map(x => x.type)); | ||
await reloadAsk(); | ||
} | ||
function reset() { | ||
items.value = defaultStore.def.timelineTopBar.default.map(x => ({ | ||
id: Math.random().toString(), | ||
type: x, | ||
})); | ||
} | ||
definePageMetadata(() => ({ | ||
title: i18n.ts.navbar, | ||
icon: 'ti ti-list', | ||
})); | ||
</script> | ||
<style lang="scss" module> | ||
.item { | ||
position: relative; | ||
display: block; | ||
line-height: 2.85rem; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
color: var(--navFg); | ||
} | ||
.itemIcon { | ||
position: relative; | ||
width: 32px; | ||
margin-right: 8px; | ||
} | ||
.itemText { | ||
position: relative; | ||
font-size: 0.9em; | ||
} | ||
.itemRemove { | ||
position: absolute; | ||
z-index: 10000; | ||
width: 32px; | ||
height: 32px; | ||
color: #ff2a2a; | ||
right: 8px; | ||
opacity: 0.8; | ||
} | ||
.itemHandle { | ||
cursor: move; | ||
width: 32px; | ||
height: 32px; | ||
margin: 0 8px; | ||
opacity: 0.5; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.