diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-02-24 02:46:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-02-24 02:46:09 +0900 |
| commit | df8a2aea358ca3bcec60c878a6399df46390e3e1 (patch) | |
| tree | 2e187e34a53d9372a797fb9d5882069545f1f03f /src/web/app/mobile/views/components | |
| parent | v3840 (diff) | |
| download | sharkey-df8a2aea358ca3bcec60c878a6399df46390e3e1.tar.gz sharkey-df8a2aea358ca3bcec60c878a6399df46390e3e1.tar.bz2 sharkey-df8a2aea358ca3bcec60c878a6399df46390e3e1.zip | |
Implement #1098
Diffstat (limited to 'src/web/app/mobile/views/components')
| -rw-r--r-- | src/web/app/mobile/views/components/activity.vue | 62 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/home.vue | 29 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/index.ts | 14 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/ui.header.vue | 4 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/ui.vue | 6 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/widget-container.vue | 65 | ||||
| -rw-r--r-- | src/web/app/mobile/views/components/widgets/activity.vue | 23 |
7 files changed, 166 insertions, 37 deletions
diff --git a/src/web/app/mobile/views/components/activity.vue b/src/web/app/mobile/views/components/activity.vue new file mode 100644 index 0000000000..b50044b3de --- /dev/null +++ b/src/web/app/mobile/views/components/activity.vue @@ -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> diff --git a/src/web/app/mobile/views/components/home.vue b/src/web/app/mobile/views/components/home.vue deleted file mode 100644 index 3feab581d2..0000000000 --- a/src/web/app/mobile/views/components/home.vue +++ /dev/null @@ -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> diff --git a/src/web/app/mobile/views/components/index.ts b/src/web/app/mobile/views/components/index.ts index 905baaf20d..d372f22332 100644 --- a/src/web/app/mobile/views/components/index.ts +++ b/src/web/app/mobile/views/components/index.ts @@ -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 diff --git a/src/web/app/mobile/views/components/ui.header.vue b/src/web/app/mobile/views/components/ui.header.vue index 2df5ea162e..026e7eb1b4 100644 --- a/src/web/app/mobile/views/components/ui.header.vue +++ b/src/web/app/mobile/views/components/ui.header.vue @@ -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> diff --git a/src/web/app/mobile/views/components/ui.vue b/src/web/app/mobile/views/components/ui.vue index 91d7ea29b6..325ce9d40e 100644 --- a/src/web/app/mobile/views/components/ui.vue +++ b/src/web/app/mobile/views/components/ui.vue @@ -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, diff --git a/src/web/app/mobile/views/components/widget-container.vue b/src/web/app/mobile/views/components/widget-container.vue new file mode 100644 index 0000000000..1775188a93 --- /dev/null +++ b/src/web/app/mobile/views/components/widget-container.vue @@ -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> diff --git a/src/web/app/mobile/views/components/widgets/activity.vue b/src/web/app/mobile/views/components/widgets/activity.vue new file mode 100644 index 0000000000..c3fe63f264 --- /dev/null +++ b/src/web/app/mobile/views/components/widgets/activity.vue @@ -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> |