From e1844db11b7c5db6ee47213f7d553387633ab938 Mon Sep 17 00:00:00 2001 From: ShittyKopper Date: Tue, 31 Oct 2023 21:21:29 +0300 Subject: [PATCH] upd: add corner roundness setting --- locales/en-US.yml | 1 + locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + packages/backend/src/server/web/boot.js | 5 +++++ packages/frontend/src/local-storage.ts | 1 + packages/frontend/src/pages/settings/general.vue | 16 ++++++++++++++++ .../src/pages/settings/preferences-backups.vue | 9 +++++++++ 7 files changed, 34 insertions(+) diff --git a/locales/en-US.yml b/locales/en-US.yml index e8e3497f8..3bb8739f1 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -507,6 +507,7 @@ createAccount: "Create account" existingAccount: "Existing account" regenerate: "Regenerate" fontSize: "Font size" +cornerRadius: "Corner roundness" mediaListWithOneImageAppearance: "Height of media lists with one image only" limitTo: "Limit to {x}" noFollowRequests: "You don't have any pending follow requests" diff --git a/locales/index.d.ts b/locales/index.d.ts index 1c1105cb8..b2dec3e58 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -510,6 +510,7 @@ export interface Locale { "existingAccount": string; "regenerate": string; "fontSize": string; + "cornerRadius": string; "mediaListWithOneImageAppearance": string; "limitTo": string; "noFollowRequests": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 68a6ca2da..c49de02b1 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -507,6 +507,7 @@ createAccount: "アカウントを作成" existingAccount: "既存のアカウント" regenerate: "再生成" fontSize: "フォントサイズ" +cornerRadius: "コーナーの丸み" mediaListWithOneImageAppearance: "画像が1枚のみのメディアリストの高さ" limitTo: "{x}を上限に" noFollowRequests: "フォロー申請はありません" diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 570b15da0..19c23af32 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -132,6 +132,11 @@ document.documentElement.classList.add('f-' + fontSize); } + const cornerRadius = localStorage.getItem('cornerRadius'); + if (cornerRadius) { + document.documentElement.classList.add(`radius-${cornerRadius}`); + } + const useSystemFont = localStorage.getItem('useSystemFont'); if (useSystemFont) { document.documentElement.classList.add('useSystemFont'); diff --git a/packages/frontend/src/local-storage.ts b/packages/frontend/src/local-storage.ts index 0d73885b6..3023471b1 100644 --- a/packages/frontend/src/local-storage.ts +++ b/packages/frontend/src/local-storage.ts @@ -21,6 +21,7 @@ type Keys = 'colorScheme' | 'useSystemFont' | 'fontSize' | + 'cornerRadius' | 'ui' | 'ui_temp' | 'locale' | diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 05ff43091..22c24bec1 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -142,6 +142,12 @@ SPDX-License-Identifier: AGPL-3.0-only + + + + + + @@ -212,6 +218,7 @@ import { claimAchievement } from '@/scripts/achievements.js'; const lang = ref(miLocalStorage.getItem('lang')); const fontSize = ref(miLocalStorage.getItem('fontSize')); +const cornerRadius = ref(miLocalStorage.getItem('cornerRadius')); const useSystemFont = ref(miLocalStorage.getItem('useSystemFont') != null); async function reloadAsk() { @@ -277,6 +284,14 @@ watch(fontSize, () => { } }); +watch(cornerRadius, () => { + if (cornerRadius.value == null) { + miLocalStorage.removeItem('cornerRadius'); + } else { + miLocalStorage.setItem('cornerRadius', cornerRadius.value); + } +}); + watch(useSystemFont, () => { if (useSystemFont.value) { miLocalStorage.setItem('useSystemFont', 't'); @@ -288,6 +303,7 @@ watch(useSystemFont, () => { watch([ lang, fontSize, + cornerRadius, useSystemFont, enableInfiniteScroll, squareAvatars, diff --git a/packages/frontend/src/pages/settings/preferences-backups.vue b/packages/frontend/src/pages/settings/preferences-backups.vue index b347d9555..ecb7c68f7 100644 --- a/packages/frontend/src/pages/settings/preferences-backups.vue +++ b/packages/frontend/src/pages/settings/preferences-backups.vue @@ -114,6 +114,7 @@ type Profile = { hot: Record; cold: Record; fontSize: string | null; + cornerRadius: string | null; useSystemFont: 't' | null; wallpaper: string | null; }; @@ -171,6 +172,7 @@ function getSettings(): Profile['settings'] { hot, cold, fontSize: miLocalStorage.getItem('fontSize'), + cornerRadius: miLocalStorage.getItem('cornerRadius'), useSystemFont: miLocalStorage.getItem('useSystemFont') as 't' | null, wallpaper: miLocalStorage.getItem('wallpaper'), }; @@ -284,6 +286,13 @@ async function applyProfile(id: string): Promise { miLocalStorage.removeItem('fontSize'); } + // cornerRadius + if (settings.cornerRadius) { + miLocalStorage.setItem('cornerRadius', settings.cornerRadius); + } else { + miLocalStorage.removeItem('cornerRadius'); + } + // useSystemFont if (settings.useSystemFont) { miLocalStorage.setItem('useSystemFont', settings.useSystemFont);