From 86a93866d049a2e755c258ce4a0b5b610f5245ff Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 3 Feb 2024 15:22:26 -0600 Subject: [PATCH] [enhancement] Add a button size setting (#486) * Add a button size setting * Reduce setting size and add px suffix * Looks like I don't need || inside of control-settings * Update translation * Bump settings version to 7 --- src/i18n/locales/en.json | 2 ++ .../player/components/center-controls.tsx | 23 ++++++++------- .../components/general/control-settings.tsx | 29 +++++++++++++++++++ src/renderer/store/settings.store.ts | 4 ++- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index d491fad1a..a6c7cebea 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -400,6 +400,8 @@ "audioExclusiveMode_description": "enable exclusive output mode. In this mode, the system is usually locked out, and only mpv will be able to output audio", "audioPlayer": "audio player", "audioPlayer_description": "select the audio player to use for playback", + "buttonSize": "Player bar button size", + "buttonSize_description": "The size of the player bar buttons", "clearCache": "Clear browser cache", "clearCache_description": "A 'hard clear' of Feishin. In addition to clearing Feishin's cache, empty the browser cache (saved images and other assets). Server credentials and settings are preserved.", "clearQueryCache": "Clear Feishin cache", diff --git a/src/renderer/features/player/components/center-controls.tsx b/src/renderer/features/player/components/center-controls.tsx index d84685c07..cb27df613 100644 --- a/src/renderer/features/player/components/center-controls.tsx +++ b/src/renderer/features/player/components/center-controls.tsx @@ -98,6 +98,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { const [isSeeking, setIsSeeking] = useState(false); const currentSong = useCurrentSong(); const skip = useSettingsStore((state) => state.general.skipButtons); + const buttonSize = useSettingsStore((state) => state.general.buttonSize); const playerType = usePlayerType(); const player1 = playersRef?.current?.player1; const player2 = playersRef?.current?.player2; @@ -171,7 +172,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { } + icon={} tooltip={{ label: t('player.stop', { postProcess: 'sentenceCase' }), }} @@ -180,7 +181,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { /> } + icon={} tooltip={{ label: shuffle === PlayerShuffle.NONE @@ -194,7 +195,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { onClick={handleToggleShuffle} /> } + icon={} tooltip={{ label: t('player.previous', { postProcess: 'sentenceCase' }), }} @@ -203,7 +204,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { /> {skip?.enabled && ( } + icon={} tooltip={{ label: t('player.skip', { context: 'back', @@ -218,9 +219,9 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { disabled={currentSong?.id === undefined} icon={ status === PlayerStatus.PAUSED ? ( - + ) : ( - + ) } tooltip={{ @@ -234,7 +235,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { /> {skip?.enabled && ( } + icon={} tooltip={{ label: t('player.skip', { context: 'forward', @@ -246,7 +247,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { /> )} } + icon={} tooltip={{ label: t('player.next', { postProcess: 'sentenceCase' }), }} @@ -257,9 +258,9 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { $isActive={repeat !== PlayerRepeat.NONE} icon={ repeat === PlayerRepeat.ONE ? ( - + ) : ( - + ) } tooltip={{ @@ -285,7 +286,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => { /> } + icon={} tooltip={{ label: t('player.playRandom', { postProcess: 'sentenceCase' }), }} diff --git a/src/renderer/features/settings/components/general/control-settings.tsx b/src/renderer/features/settings/components/general/control-settings.tsx index 35e6f2fcd..899082769 100644 --- a/src/renderer/features/settings/components/general/control-settings.tsx +++ b/src/renderer/features/settings/components/general/control-settings.tsx @@ -36,6 +36,35 @@ export const ControlSettings = () => { const { setSettings } = useSettingsStoreActions(); const controlOptions = [ + { + control: ( + { + if (!e) return; + const newVal = e.currentTarget.value + ? Math.min(Math.max(Number(e.currentTarget.value), 15), 30) + : settings.buttonSize; + setSettings({ + general: { + ...settings, + buttonSize: newVal, + }, + }); + }} + /> + ), + description: t('setting.buttonSize', { + context: 'description', + postProcess: 'sentenceCase', + }), + isHidden: false, + title: t('setting.buttonSize', { postProcess: 'sentenceCase' }), + }, { control: ( ()( return merge(currentState, persistedState); }, name: 'store_settings', - version: 6, + version: 7, }, ), );