Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #251 Show toot design sample in appearance setting page #620

Merged
merged 8 commits into from
Sep 22, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/config/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,37 @@
"title": "Preferences",
"general": {
"title": "General",
"appearance": "Appearance",
"theme_color": "Theme color:",
"toot": "Toot",
"visibility": {
"title": "Default visibility:",
"public": "Public",
"unlisted": "Unlisted",
"private": "Private",
"direct": "Direct"
},
"sounds": "Sounds",
"fav_rb_sound": "Favorite and Boost:",
"toot_sound": "Toot:"
},
"appearance": {
"title": "Appearance",
"theme_color": "Theme color",
"theme": {
"light": "Light",
"dark": "Dark"
},
"font_size": "Font size:",
"font_size": "Font size",
"display_style": {
"title": "Display style:",
"title": "Display style of username",
"display_name_and_username": "Display name and username",
"display_name": "Display name",
"username": "Username"
},
"time_format": {
"title": "Time format:",
"title": "Time format",
"absolute": "Absolute",
"relative": "Relative"
},
"toot": "Toot",
"visibility": {
"title": "Default visibility:",
"public": "Public",
"unlisted": "Unlisted",
"private": "Private",
"direct": "Direct"
},
"sounds": "Sounds",
"fav_rb_sound": "Favorite and Boost:",
"toot_sound": "Toot:"
}
},
"notification": {
"title": "Notification",
Expand Down
6 changes: 3 additions & 3 deletions src/constants/displayStyle.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export default {
DisplayNameAndUsername: {
name: 'preferences.general.display_style.display_name_and_username',
name: 'preferences.appearance.display_style.display_name_and_username',
value: 0
},
DisplayName: {
name: 'preferences.general.display_style.display_name',
name: 'preferences.appearance.display_style.display_name',
value: 1
},
Username: {
name: 'preferences.general.display_style.username',
name: 'preferences.appearance.display_style.username',
value: 2
}
}
4 changes: 2 additions & 2 deletions src/constants/theme.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
Light: {
name: 'preferences.general.theme.light',
name: 'preferences.appearance.theme.light',
key: 'light'
},
Dark: {
name: 'preferences.general.theme.dark',
name: 'preferences.appearance.theme.dark',
key: 'dark'
}
}
4 changes: 2 additions & 2 deletions src/constants/timeFormat.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
Absolute: {
name: 'preferences.general.time_format.absolute',
name: 'preferences.appearance.time_format.absolute',
value: 0
},
Relative: {
name: 'preferences.general.time_format.relative',
name: 'preferences.appearance.time_format.relative',
value: 1
}
}
12 changes: 7 additions & 5 deletions src/main/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ const Base = {
fav_rb: true,
toot: true
},
theme: Theme.Light.key,
fontSize: 14,
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
tootVisibility: Visibility.Public.value,
timeFormat: TimeFormat.Absolute.value
tootVisibility: Visibility.Public.value
},
state: {
collapse: false
Expand All @@ -31,6 +27,12 @@ const Base = {
favourite: true,
follow: true
}
},
appearance: {
theme: Theme.Light.key,
fontSize: 14,
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
timeFormat: TimeFormat.Absolute.value
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/renderer/components/Preferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@
<icon name="cog" class="icon" scale="1.3"></icon>
<span>{{ $t('preferences.general.title') }}</span>
</el-menu-item>
<el-menu-item index="2" :route="{path: '/preferences/notification'}" @click="notification">
<el-menu-item index="2" :route="{path: '/preferences/appearance'}" @click="appearance">
<icon name="palette" class="icon" scale="1.3"></icon>
<span>{{ $t('preferences.appearance.title') }}</span>
</el-menu-item>
<el-menu-item index="3" :route="{path: '/preferences/notification'}" @click="notification">
<icon name="bell" class="icon" scale="1.3"></icon>
<span>{{ $t('preferences.notification.title') }}</span>
</el-menu-item>
<el-menu-item index="3" :route="{path: '/preferences/account'}" @click="account">
<el-menu-item index="4" :route="{path: '/preferences/account'}" @click="account">
<icon name="user" class="icon" scale="1.3"></icon>
<span>{{ $t('preferences.account.title') }}</span>
</el-menu-item>
<el-menu-item index="4" :route="{path: '/preferences/language'}" @click="language">
<el-menu-item index="5" :route="{path: '/preferences/language'}" @click="language">
<icon name="language" class="icon" scale="1.3"></icon>
<span>{{ $t('preferences.language.title') }}</span>
</el-menu-item>
Expand Down Expand Up @@ -72,6 +76,9 @@ export default {
},
language () {
this.$router.push('/preferences/language')
},
appearance () {
this.$router.push('/preferences/appearance')
}
}
}
Expand Down
150 changes: 150 additions & 0 deletions src/renderer/components/Preferences/Appearance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<template>
<div id="appearance">
<h2>{{ $t('preferences.appearance.title') }}</h2>
<div class="theme section">
<div class="left">
<h4>{{ $t('preferences.appearance.theme_color') }}</h4>
<span class="status">
<el-select v-model="theme" placeholder="theme">
<el-option
v-for="t in themes"
:key="t.key"
:label="$t(t.name)"
:value="t.key">
</el-option>
</el-select>
</span>
</div>
<div class="right">
<Toot
:displayNameStyle="displayNameStyle"
:timeFormat="timeFormat"
></Toot>
</div>
</div>
<div class="font section">
<h4>{{ $t('preferences.appearance.font_size') }}</h4>
<span class="status">
<el-input-number :value="fontSize" :min="9" :max="18" @change="updateFontSize"></el-input-number>
</span>
</div>
<div class="display-style section">
<h4>{{ $t('preferences.appearance.display_style.title') }}</h4>
<span class="status">
<el-select v-model="displayNameStyle" placeholder="style">
<el-option
v-for="style in nameStyles"
:key="style.value"
:label="$t(style.name)"
:value="style.value">
</el-option>
</el-select>
</span>
</div>
<div class="time-format section">
<h4>{{ $t('preferences.appearance.time_format.title') }}</h4>
<span class="status">
<el-select v-model="timeFormat" placeholder="format">
<el-option
v-for="format in timeFormats"
:key="format.value"
:label="$t(format.name)"
:value="format.value">
</el-option>
</el-select>
</span>
</div>
</div>
</template>

<script>
import { mapState } from 'vuex'
import Toot from './Appearance/Toot'
import DisplayStyle from '~/src/constants/displayStyle'
import Theme from '~/src/constants/theme'
import TimeFormat from '~/src/constants/timeFormat'

export default {
name: 'appearance',
components: {
Toot
},
data () {
return {
nameStyles: [
DisplayStyle.DisplayNameAndUsername,
DisplayStyle.DisplayName,
DisplayStyle.Username
],
themes: [
Theme.Light,
Theme.Dark
],
timeFormats: [
TimeFormat.Absolute,
TimeFormat.Relative
]
}
},
computed: {
...mapState('Preferences/Appearance', {
fontSize: state => state.appearance.fontSize
}),
theme: {
get () {
return this.$store.state.Preferences.Appearance.appearance.theme
},
set (value) {
this.$store.dispatch('Preferences/Appearance/updateTheme', value)
}
},
displayNameStyle: {
get () {
return this.$store.state.Preferences.Appearance.appearance.displayNameStyle
},
set (value) {
this.$store.dispatch('Preferences/Appearance/updateDisplayNameStyle', value)
}
},
timeFormat: {
get () {
return this.$store.state.Preferences.Appearance.appearance.timeFormat
},
set (value) {
this.$store.dispatch('Preferences/Appearance/updateTimeFormat', value)
}
}
},
created () {
this.$store.dispatch('Preferences/Appearance/loadAppearance')
},
methods: {
updateFontSize (value) {
this.$store.dispatch('Preferences/Appearance/updateFontSize', value)
}
}
}
</script>

<style lang="scss" scoped>
#appearance {
color: var(--theme-secondary-color);
box-sizing: border-box;

.theme {
display: flex;
align-items: flex-start;

.left {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[stylelint]

Unexpected empty block (block-no-empty)

}

.right {
margin-left: 40px;
}
}

.section {
margin-bottom: 48px;
}
}
</style>
Loading