[wip] darkmode

This commit is contained in:
syuilo 2018-04-20 04:16:48 +09:00
parent cba07d08d0
commit 2145730409
2 changed files with 44 additions and 55 deletions

View file

@ -46,15 +46,28 @@ init(async (launch) => {
// Dark/Light // Dark/Light
Vue.mixin({ Vue.mixin({
data() {
return {
_darkmode_: false
};
},
beforeCreate() {
// なぜか警告が出るため
this._darkmode_ = false;
},
mounted() { mounted() {
const set = () => { const set = () => {
if (!this.$el || !this.os || !this.os.i) return; if (!this.$el || !this.$el.setAttribute || !this.os || !this.os.i) return;
if (this.os.i.clientSettings.dark) { if (this.os.i.clientSettings.dark) {
document.documentElement.setAttribute('data-darkmode', 'true'); document.documentElement.setAttribute('data-darkmode', 'true');
this.$el.setAttribute('data-darkmode', 'true'); this.$el.setAttribute('data-darkmode', 'true');
this._darkmode_ = true;
this.$forceUpdate();
} else { } else {
document.documentElement.removeAttribute('data-darkmode'); document.documentElement.removeAttribute('data-darkmode');
this.$el.removeAttribute('data-darkmode'); this.$el.removeAttribute('data-darkmode');
this._darkmode_ = false;
this.$forceUpdate();
} }
}; };

View file

@ -1,9 +1,10 @@
<template> <template>
<div class="mkw-users"> <div class="mkw-users">
<template v-if="!props.compact"> <mk-widget-container :show-header="!props.compact">
<p class="title">%fa:users%%i18n:@title%</p> <template slot="header">%fa:users%%i18n:@title%</template>
<button @click="refresh" title="%i18n:@refresh%">%fa:sync%</button> <button slot="func" title="%i18n:@refresh%" @click="refresh">%fa:sync%</button>
</template>
<div class="mkw-users--body" :data-darkmode="_darkmode_">
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p> <p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
<template v-else-if="users.length != 0"> <template v-else-if="users.length != 0">
<div class="user" v-for="_user in users"> <div class="user" v-for="_user in users">
@ -19,6 +20,8 @@
</template> </template>
<p class="empty" v-else>%i18n:@no-one%</p> <p class="empty" v-else>%i18n:@no-one%</p>
</div> </div>
</mk-widget-container>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -71,43 +74,10 @@ export default define({
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
.mkw-users root(isDark)
background #fff
border solid 1px rgba(0, 0, 0, 0.075)
border-radius 6px
> .title
margin 0
padding 0 16px
line-height 42px
font-size 0.9em
font-weight bold
color #888
border-bottom solid 1px #eee
> [data-fa]
margin-right 4px
> button
position absolute
z-index 2
top 0
right 0
padding 0
width 42px
font-size 0.9em
line-height 42px
color #ccc
&:hover
color #aaa
&:active
color #999
> .user > .user
padding 16px padding 16px
border-bottom solid 1px #eee border-bottom solid 1px isDark ? #1c2023 : #eee
&:last-child &:last-child
border-bottom none border-bottom none
@ -138,14 +108,14 @@ export default define({
margin 0 margin 0
font-size 16px font-size 16px
line-height 24px line-height 24px
color #555 color isDark ? #fff : #555
> .username > .username
display block display block
margin 0 margin 0
font-size 15px font-size 15px
line-height 16px line-height 16px
color #ccc color isDark ? #606984 : #ccc
> .mk-follow-button > .mk-follow-button
position absolute position absolute
@ -167,4 +137,10 @@ export default define({
> [data-fa] > [data-fa]
margin-right 4px margin-right 4px
.mkw-users--body[data-darkmode]
root(true)
.mkw-users--body:not([data-darkmode])
root(false)
</style> </style>