This commit is contained in:
syuilo 2018-02-24 02:46:09 +09:00
parent 83f2e906bb
commit df8a2aea35
42 changed files with 823 additions and 511 deletions

View file

@ -0,0 +1,62 @@
<template>
<div class="mk-activity">
<svg v-if="data" ref="canvas" viewBox="0 0 30 1" preserveAspectRatio="none">
<g v-for="(d, i) in data">
<rect width="0.8" :height="d.postsH"
:x="i + 0.1" :y="1 - d.postsH - d.repliesH - d.repostsH"
fill="#41ddde"/>
<rect width="0.8" :height="d.repliesH"
:x="i + 0.1" :y="1 - d.repliesH - d.repostsH"
fill="#f7796c"/>
<rect width="0.8" :height="d.repostsH"
:x="i + 0.1" :y="1 - d.repostsH"
fill="#a1de41"/>
</g>
</svg>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['user'],
data() {
return {
fetching: true,
data: [],
peak: null
};
},
mounted() {
(this as any).api('aggregation/users/activity', {
user_id: this.user.id,
limit: 30
}).then(data => {
data.forEach(d => d.total = d.posts + d.replies + d.reposts);
this.peak = Math.max.apply(null, data.map(d => d.total));
data.forEach(d => {
d.postsH = d.posts / this.peak;
d.repliesH = d.replies / this.peak;
d.repostsH = d.reposts / this.peak;
});
data.reverse();
this.data = data;
});
}
});
</script>
<style lang="stylus" scoped>
.mk-activity
max-width 600px
margin 0 auto
> svg
display block
width 100%
height 80px
> rect
transform-origin center
</style>

View file

@ -1,29 +0,0 @@
<template>
<div class="mk-home">
<mk-timeline @loaded="onTlLoaded"/>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
methods: {
onTlLoaded() {
this.$emit('loaded');
}
}
});
</script>
<style lang="stylus" scoped>
.mk-home
> .mk-timeline
max-width 600px
margin 0 auto
padding 8px
@media (min-width 500px)
padding 16px
</style>

View file

@ -1,7 +1,6 @@
import Vue from 'vue';
import ui from './ui.vue';
import home from './home.vue';
import timeline from './timeline.vue';
import posts from './posts.vue';
import imagesImage from './images-image.vue';
@ -19,9 +18,14 @@ import notificationPreview from './notification-preview.vue';
import usersList from './users-list.vue';
import userPreview from './user-preview.vue';
import userTimeline from './user-timeline.vue';
import activity from './activity.vue';
import widgetContainer from './widget-container.vue';
//#region widgets
import wActivity from './widgets/activity.vue';
//#endregion
Vue.component('mk-ui', ui);
Vue.component('mk-home', home);
Vue.component('mk-timeline', timeline);
Vue.component('mk-posts', posts);
Vue.component('mk-images-image', imagesImage);
@ -39,3 +43,9 @@ Vue.component('mk-notification-preview', notificationPreview);
Vue.component('mk-users-list', usersList);
Vue.component('mk-user-preview', userPreview);
Vue.component('mk-user-timeline', userTimeline);
Vue.component('mk-activity', activity);
Vue.component('mk-widget-container', widgetContainer);
//#region widgets
Vue.component('mkw-activity', wActivity);
//#endregion

View file

@ -9,9 +9,7 @@
<h1>
<slot>Misskey</slot>
</h1>
<button v-if="func" @click="func">
<slot name="funcIcon"></slot>
</button>
<slot name="func"></slot>
</div>
</div>
</div>

View file

@ -1,7 +1,7 @@
<template>
<div class="mk-ui">
<x-header :func="func">
<template slot="funcIcon"><slot name="funcIcon"></slot></template>
<x-header>
<template slot="func"><slot name="func"></slot></template>
<slot name="header"></slot>
</x-header>
<x-nav :is-open="isDrawerOpening"/>
@ -23,7 +23,7 @@ export default Vue.extend({
XHeader,
XNav
},
props: ['title', 'func'],
props: ['title'],
data() {
return {
isDrawerOpening: false,

View file

@ -0,0 +1,65 @@
<template>
<div class="mk-widget-container" :class="{ naked }">
<header v-if="showHeader">
<div class="title"><slot name="header"></slot></div>
<slot name="func"></slot>
</header>
<slot></slot>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
showHeader: {
type: Boolean,
default: true
},
naked: {
type: Boolean,
default: false
}
}
});
</script>
<style lang="stylus" scoped>
.mk-widget-container
background #eee
border-radius 8px
box-shadow 0 0 0 1px rgba(0, 0, 0, 0.2)
overflow hidden
&.naked
background transparent !important
border none !important
> header
> .title
margin 0
padding 8px 10px
font-size 15px
font-weight normal
color #465258
background #fff
border-radius 8px 8px 0 0
> [data-fa]
margin-right 6px
&:empty
display none
> button
position absolute
z-index 2
top 0
right 0
padding 0
width 42px
height 100%
font-size 15px
color #465258
</style>

View file

@ -0,0 +1,23 @@
<template>
<div class="mkw-activity">
<mk-widget-container>
<template slot="header">%fa:chart-bar%アクティビティ</template>
<div :class="$style.body">
<mk-activity :user="os.i"/>
</div>
</mk-widget-container>
</div>
</template>
<script lang="ts">
import define from '../../../../common/define-widget';
export default define({
name: 'activity',
});
</script>
<style lang="stylus" module>
.body
padding 8px
</style>