Skip to content

Commit

Permalink
option to prefer softwareColor on ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
atsu1125 committed Feb 23, 2024
1 parent f397bbb commit 4c32025
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ deleteAccountConfirm: "Are you sure that you want to delete this account?"
createdAt: "Created at"
invitationRequiredToRegister: "This server is currently invitation only. Only those with an invitation code can register."
themeColor: "Theme Color"
preferTickerSoftwareColor: "Prefer Software Color on instance ticker"

_template:
edit: "Edit Template..."
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ leaveGroup: "グループから抜ける"
leaveGroupConfirm: "「{name}」から抜けますか?"
notSpecifiedMentionWarning: "宛先に含まれていないメンションがあります"
themeColor: "テーマカラー"
preferTickerSoftwareColor: "インスタンスティッカーにソフトウェアカラーを採用して表示する"

_template:
edit: "定型文を編集…"
Expand Down
14 changes: 11 additions & 3 deletions src/client/components/instance-ticker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

<script lang="ts">
import { defineComponent } from 'vue';
import { instanceName } from '@/config';
import { instanceName, software } from '@/config';
import { defaultStore } from '@/store';
export default defineComponent({
props: {
Expand All @@ -22,7 +23,8 @@ export default defineComponent({
info: this.instance || {
faviconUrl: '/favicon.ico',
name: instanceName,
themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content
themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement)?.content,
softwareName: software,
}
}
},
Expand Down Expand Up @@ -62,7 +64,13 @@ export default defineComponent({
default:
softwareColor = '#777777';
}
const themeColor = this.info.themeColor || softwareColor;
const preferSoftwareColor = this.$store.reactiveState.preferTickerSoftwareColor.value;
let themeColor = '';
if (preferSoftwareColor) {
themeColor = softwareColor;
} else {
themeColor = this.info.themeColor || softwareColor;
}
return {
background: `linear-gradient(90deg, ${themeColor}, ${themeColor}00)`
};
Expand Down
1 change: 1 addition & 0 deletions src/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const lang = localStorage.getItem('lang');
export const langs = _LANGS_;
export const locale = JSON.parse(localStorage.getItem('locale'));
export const version = _VERSION_;
export const software = _SOFTWARE_;
export const instanceName = siteName === 'Groundpolis' ? host : siteName;
export const ui = localStorage.getItem('ui');
export const debug = localStorage.getItem('debug') === 'true';
Expand Down
16 changes: 10 additions & 6 deletions src/client/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@
<option value="veryLarge"><span style="font-size: 20px;">Aa</span></option>
</FormRadios>

<FormSelect v-model:value="instanceTicker">
<template #label>{{ $ts.instanceTicker }}</template>
<option value="none">{{ $ts._instanceTicker.none }}</option>
<option value="remote">{{ $ts._instanceTicker.remote }}</option>
<option value="always">{{ $ts._instanceTicker.always }}</option>
</FormSelect>
<FormGroup>
<FormSelect v-model:value="instanceTicker">
<template #label>{{ $ts.instanceTicker }}</template>
<option value="none">{{ $ts._instanceTicker.none }}</option>
<option value="remote">{{ $ts._instanceTicker.remote }}</option>
<option value="always">{{ $ts._instanceTicker.always }}</option>
</FormSelect>
<FormSwitch v-model:value="preferTickerSoftwareColor">{{ $ts.preferTickerSoftwareColor }}</FormSwitch>
</FormGroup>

<FormSelect v-model:value="nsfw">
<template #label>{{ $ts.nsfw }}</template>
Expand Down Expand Up @@ -228,6 +231,7 @@ export default defineComponent({
showVoteConfirm: defaultStore.makeGetterSetter('showVoteConfirm'),
aiChanMode: defaultStore.makeGetterSetter('aiChanMode'),
renoteButtonMode: defaultStore.makeGetterSetter('renoteButtonMode'),
preferTickerSoftwareColor: defaultStore.makeGetterSetter('preferTickerSoftwareColor'),
},
watch: {
Expand Down
5 changes: 5 additions & 0 deletions src/client/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ export const defaultStore = markRaw(new Storage('base', {
default: false
},

preferTickerSoftwareColor: {
where: 'device',
default: false
},

//#endregion
}));

Expand Down
1 change: 1 addition & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ module.exports = {
_DATA_TRANSFER_DECK_COLUMN_: JSON.stringify('mk_deck_column'),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
_SOFTWARE_: JSON.stringify(meta.name),
}),
new VueLoaderPlugin(),
new WebpackOnBuildPlugin((stats: any) => {
Expand Down

0 comments on commit 4c32025

Please sign in to comment.