From d52d9136b83adfb3ff443e5521d09c9aa64ac08d Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 5 Mar 2024 02:30:37 -0600 Subject: [PATCH] [feat] Add a dynamic image option to the fullscreen player (#526) * Add an option for a dynamic background image in the fullscreen player * Center the background image and fix some more bugs * More cleaning up the background image * Add option for customizable blur amount * Fix missing translation key for image blur * Fix dynamic image shifting when player is opened * Hide image blur size config if dynamic background is disabled --------- Co-authored-by: Jeff <42182408+jeffvli@users.noreply.github.com> --- src/i18n/locales/en.json | 2 + .../player/components/full-screen-player.tsx | 78 +++++++++++++++++-- .../store/full-screen-player.store.ts | 4 + 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index fbede376c..b7965f778 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -311,6 +311,8 @@ "fullscreenPlayer": { "config": { "dynamicBackground": "dynamic background", + "dynamicImageBlur": "image blur size", + "dynamicIsImage": "enable background image", "followCurrentLyric": "follow current lyric", "lyricAlignment": "lyric alignment", "lyricGap": "lyric gap", diff --git a/src/renderer/features/player/components/full-screen-player.tsx b/src/renderer/features/player/components/full-screen-player.tsx index 970f52e42..edb8e320f 100644 --- a/src/renderer/features/player/components/full-screen-player.tsx +++ b/src/renderer/features/player/components/full-screen-player.tsx @@ -60,7 +60,11 @@ const ResponsiveContainer = styled.div` } `; -const BackgroundImageOverlay = styled.div` +interface BackgroundImageOverlayProps { + $blur: number; +} + +const BackgroundImageOverlay = styled.div` position: absolute; top: 0; left: 0; @@ -68,12 +72,21 @@ const BackgroundImageOverlay = styled.div` width: 100%; height: 100%; background: var(--bg-header-overlay); + backdrop-filter: blur(${({ $blur }) => $blur}rem); `; +const mainBackground = 'var(--main-bg)'; + const Controls = () => { const { t } = useTranslation(); - const { dynamicBackground, expanded, opacity, useImageAspectRatio } = - useFullScreenPlayerStore(); + const { + dynamicBackground, + dynamicImageBlur, + dynamicIsImage, + expanded, + opacity, + useImageAspectRatio, + } = useFullScreenPlayerStore(); const { setStore } = useFullScreenPlayerStoreActions(); const { setSettings } = useSettingsStoreActions(); const lyricConfig = useLyricsSettings(); @@ -141,6 +154,45 @@ const Controls = () => { /> + {dynamicBackground && ( + + )} + {dynamicBackground && dynamicIsImage && ( + + )} {dynamicBackground && (