Better broadcast widget mk2 (#5455)

* better broadcast widget

* 🎨

* 🎨

* 🎨

* mk2 (left nav with chevron icons)

* fix

* button title
This commit is contained in:
tamaina 2019-09-26 04:23:48 +09:00 committed by syuilo
parent 11ddbdc58d
commit ef17838c64
2 changed files with 129 additions and 78 deletions

View File

@ -878,6 +878,7 @@ common/views/widgets/broadcast.vue:
no-broadcasts: "お知らせはありません"
have-a-nice-day: "良い一日を!"
next: "次"
prev: "前"
common/views/widgets/calendar.vue:
year: "{}年"

View File

@ -1,11 +1,12 @@
<template>
<div class="anltbovirfeutcigvwgmgxipejaeozxi">
<ui-container :show-header="false" :naked="props.design == 1">
<ui-container :show-header="false" :naked="props.design === 1">
<div class="anltbovirfeutcigvwgmgxipejaeozxi-body"
:data-found="announcements && announcements.length != 0"
:data-found="announcements && announcements.length !== 0"
:data-melt="props.design == 1"
:data-mobile="platform == 'mobile'"
>
<div class="broadcast-left" v-show="announcements && announcements.length !== 0">
<div class="icon">
<svg height="32" version="1.1" viewBox="0 0 32 32" width="32">
<path class="tower" d="M16.04,11.24c1.79,0,3.239-1.45,3.239-3.24S17.83,4.76,16.04,4.76c-1.79,0-3.24,1.45-3.24,3.24 C12.78,9.78,14.24,11.24,16.04,11.24z M16.04,13.84c-0.82,0-1.66-0.2-2.4-0.6L7.34,29.98h2.98l1.72-2h8l1.681,2H24.7L18.42,13.24 C17.66,13.64,16.859,13.84,16.04,13.84z M16.02,14.8l2.02,7.2h-4L16.02,14.8z M12.04,25.98l2-2h4l2,2H12.04z"></path>
@ -15,6 +16,13 @@
<path class="wave d" d="M29.18,1.06c-0.479-0.502-1.273-0.522-1.775-0.044c-0.016,0.015-0.029,0.029-0.045,0.044c-0.5,0.52-0.5,1.36,0,1.88 c1.361,1.4,2.041,3.24,2.041,5.08s-0.68,3.66-2.041,5.08c-0.5,0.52-0.5,1.36,0,1.88c0.509,0.508,1.332,0.508,1.841,0 c1.86-1.92,2.8-4.44,2.8-6.96C31.99,5.424,30.98,2.931,29.18,1.06z"></path>
</svg>
</div>
<div class="broadcast-nav" v-show="announcements && announcements.length > 1">
<div class="broadcast-page">{{ i + 1 }} / {{ announcements.length }}</div>
<ui-button class="broadcast-prev" @click="prev" :title="$t('next')"><fa :icon="faAngleLeft"/></ui-button>
<ui-button class="broadcast-next" @click="next" :title="$t('prev')"><fa :icon="faAngleRight"/></ui-button>
</div>
</div>
<div class="broadcast-right">
<p class="fetching" v-if="fetching">{{ $t('fetching') }}<mk-ellipsis/></p>
<h1 v-if="!fetching">{{ announcements.length == 0 ? $t('no-broadcasts') : announcements[i].title }}</h1>
<p v-if="!fetching">
@ -22,7 +30,7 @@
<img v-if="announcements.length != 0 && announcements[i].image" :src="announcements[i].image" alt="" style="display: block; max-height: 130px; max-width: 100%;"/>
<template v-if="announcements.length == 0">{{ $t('have-a-nice-day') }}</template>
</p>
<a v-if="announcements.length > 1" @click="next">{{ $t('next') }} &gt;&gt;</a>
</div>
</div>
</ui-container>
</div>
@ -30,6 +38,7 @@
<script lang="ts">
import define from '../../../common/define-widget';
import { faAngleLeft, faAngleRight } from '@fortawesome/free-solid-svg-icons';
import i18n from '../../../i18n';
export default define({
@ -43,7 +52,8 @@ export default define({
return {
i: 0,
fetching: true,
announcements: []
announcements: [],
faAngleLeft, faAngleRight
};
},
mounted() {
@ -54,14 +64,21 @@ export default define({
},
methods: {
next() {
if (this.i == this.announcements.length - 1) {
if (this.i === this.announcements.length - 1) {
this.i = 0;
} else {
this.i++;
}
},
prev() {
if (this.i === 0) {
this.i = this.announcements.length - 1;
} else {
this.i--;
}
},
func() {
if (this.props.design == 1) {
if (this.props.design === 1) {
this.props.design = 0;
} else {
this.props.design++;
@ -74,31 +91,21 @@ export default define({
<style lang="stylus" scoped>
.anltbovirfeutcigvwgmgxipejaeozxi-body
display flex
padding 10px
background var(--announcementsBg)
&[data-melt]
background transparent
&[data-found]
padding-left 50px
> .broadcast-left
width 32px
margin-right 8px
> .icon
display block
&:after
content ""
display block
clear both
> .icon
display none
float left
margin-left -40px
> svg
fill currentColor
color #4078c0
color var(--announcementsTitle)
> .wave
opacity 1
@ -128,26 +135,69 @@ export default define({
10%
opacity 1
> .broadcast-nav
display flex
flex-wrap wrap
padding 1px 0 2px
> .broadcast-page
width 100%
color var(--announcementsTitle)
text-align center
font-size .8rem
> .broadcast-prev,
> .broadcast-next
flex 1
width 50%
display block
margin 0
padding 0
font-size .9rem
line-height 1.3em
color var(--link)
background transparent
cursor pointer
&:focus
&:after
top -1px
right -1px
bottom -1px
left -1px
&.round:focus:after
border-radius 5px
> .broadcast-prev
padding-right 3px
> .broadcast-next
padding-left 3px
> .broadcast-right
flex 1
word-break break-word
> h1
margin 0
font-size 0.95em
font-size .975em
font-weight normal
line-height 1.3em
color var(--announcementsTitle)
padding-bottom 2px
> p
display block
z-index 1
margin 0
font-size 0.7em
font-size .8em
color var(--announcementsText)
width 100%
&.fetching
text-align center
> a
display block
font-size 0.7em
&[data-mobile]
> p
color #fff