mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-24 13:09:07 +01:00
08a2162aa7
* wip * tabun ok * better msg * oops * fix lint * Update gulpfile.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update src/client/scripts/set-i18n-contexts.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * refactor Co-authored-by: acid-chicken <root@acid-chicken.com> * ✨ * wip * fix lint * たぶんおk * fix flush * Translate Notification * remove console.log * fix * add notifications * remove san * wip * ok * ✌️ * Update src/prelude/array.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * wip * i18n refactor * Update init.ts * ✌️ Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
151 lines
3.9 KiB
Vue
151 lines
3.9 KiB
Vue
<template>
|
|
<div class="mkw-timeline" :style="`flex-basis: calc(${basis}% - var(--margin)); height: ${previewHeight}px;`">
|
|
<mk-container :show-header="!props.compact" class="container">
|
|
<template #header>
|
|
<button @click="choose" class="_button">
|
|
<fa v-if="props.src === 'home'" :icon="faHome"/>
|
|
<fa v-if="props.src === 'local'" :icon="faComments"/>
|
|
<fa v-if="props.src === 'social'" :icon="faShareAlt"/>
|
|
<fa v-if="props.src === 'global'" :icon="faGlobe"/>
|
|
<fa v-if="props.src === 'list'" :icon="faListUl"/>
|
|
<fa v-if="props.src === 'antenna'" :icon="faSatellite"/>
|
|
<span style="margin-left: 8px;">{{ props.src === 'list' ? props.list.name : props.src === 'antenna' ? props.antenna.name : $t('_timelines.' + props.src) }}</span>
|
|
<fa :icon="menuOpened ? faAngleUp : faAngleDown" style="margin-left: 8px;"/>
|
|
</button>
|
|
</template>
|
|
|
|
<div>
|
|
<x-timeline :key="props.src === 'list' ? `list:${props.list.id}` : props.src === 'antenna' ? `antenna:${props.antenna.id}` : props.src" :src="props.src" :list="props.list" :antenna="props.antenna"/>
|
|
</div>
|
|
</mk-container>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faListUl, faSatellite } from '@fortawesome/free-solid-svg-icons';
|
|
import { faComments } from '@fortawesome/free-regular-svg-icons';
|
|
import MkContainer from '../components/ui/container.vue';
|
|
import XTimeline from '../components/timeline.vue';
|
|
import define from './define';
|
|
|
|
const basisSteps = [25, 50, 75, 100]
|
|
const previewHeights = [200, 300, 400, 500]
|
|
|
|
export default define({
|
|
name: 'timeline',
|
|
props: () => ({
|
|
src: 'home',
|
|
list: null,
|
|
compact: false,
|
|
basisStep: 0
|
|
})
|
|
}).extend({
|
|
|
|
components: {
|
|
MkContainer,
|
|
XTimeline,
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
menuOpened: false,
|
|
faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faComments, faListUl, faSatellite
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
basis(): number {
|
|
return basisSteps[this.props.basisStep] || 25
|
|
},
|
|
|
|
previewHeight(): number {
|
|
return previewHeights[this.props.basisStep] || 200
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
func() {
|
|
if (this.props.basisStep === basisSteps.length - 1) {
|
|
this.props.basisStep = 0
|
|
this.props.compact = !this.props.compact;
|
|
} else {
|
|
this.props.basisStep += 1
|
|
}
|
|
|
|
this.save();
|
|
},
|
|
|
|
async choose(ev) {
|
|
this.menuOpened = true;
|
|
const [antennas, lists] = await Promise.all([
|
|
this.$root.api('antennas/list'),
|
|
this.$root.api('users/lists/list')
|
|
]);
|
|
const antennaItems = antennas.map(antenna => ({
|
|
text: antenna.name,
|
|
icon: faSatellite,
|
|
action: () => {
|
|
this.props.antenna = antenna;
|
|
this.setSrc('antenna');
|
|
}
|
|
}));
|
|
const listItems = lists.map(list => ({
|
|
text: list.name,
|
|
icon: faListUl,
|
|
action: () => {
|
|
this.props.list = list;
|
|
this.setSrc('list');
|
|
}
|
|
}));
|
|
this.$root.menu({
|
|
items: [{
|
|
text: this.$t('_timelines.home'),
|
|
icon: faHome,
|
|
action: () => { this.setSrc('home') }
|
|
}, {
|
|
text: this.$t('_timelines.local'),
|
|
icon: faComments,
|
|
action: () => { this.setSrc('local') }
|
|
}, {
|
|
text: this.$t('_timelines.social'),
|
|
icon: faShareAlt,
|
|
action: () => { this.setSrc('social') }
|
|
}, {
|
|
text: this.$t('_timelines.global'),
|
|
icon: faGlobe,
|
|
action: () => { this.setSrc('global') }
|
|
}, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems],
|
|
noCenter: true,
|
|
source: ev.currentTarget || ev.target
|
|
}).then(() => {
|
|
this.menuOpened = false;
|
|
});
|
|
},
|
|
|
|
setSrc(src) {
|
|
this.props.src = src;
|
|
this.save();
|
|
},
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.mkw-timeline {
|
|
flex-grow: 1;
|
|
flex-shrink: 0;
|
|
min-height: 0; // https://www.gwtcenter.com/min-height-required-on-firefox-flexbox
|
|
|
|
.container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
|
|
> div {
|
|
overflow: auto;
|
|
flex-grow: 1;
|
|
}
|
|
}
|
|
}
|
|
</style>
|