Skip to content

Commit

Permalink
change the playerbar animation
Browse files Browse the repository at this point in the history
  • Loading branch information
pyxfluff committed Sep 1, 2024
1 parent 77f471d commit c887a9b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/renderer/features/player/components/playerbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const CenterGridItem = styled.div`
export const Playerbar = () => {
const playersRef = PlayersRef;
const settings = useSettingsStore((state) => state.playback);
const generalSetings = useGeneralSettings();
const { playerbarOpenDrawer } = useGeneralSettings();
const playbackType = usePlaybackType();
const volume = useVolume();
const player1 = usePlayer1Data();
Expand All @@ -81,10 +81,8 @@ export const Playerbar = () => {
const setFullScreenPlayerStore = useSetFullScreenPlayerStore();

const handleToggleFullScreenPlayer = (e?: MouseEvent<HTMLDivElement> | KeyboardEvent) => {
if (generalSetings.playerbarOpenDrawer) {
e?.stopPropagation();
setFullScreenPlayerStore({ expanded: !isFullScreenPlayerExpanded });
}
e?.stopPropagation();
setFullScreenPlayerStore({ expanded: !isFullScreenPlayerExpanded });
};

const autoNextFn = useCallback(() => {
Expand All @@ -93,7 +91,9 @@ export const Playerbar = () => {
}, [autoNext]);

return (
<PlayerbarContainer onClick={handleToggleFullScreenPlayer}>
<PlayerbarContainer
onClick={playerbarOpenDrawer ? handleToggleFullScreenPlayer : undefined}
>
<PlayerbarControlsGrid>
<LeftGridItem>
<LeftControls />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,28 @@ export const ControlSettings = () => {
isHidden: false,
title: t('setting.albumBackgroundBlur', { postProcess: 'sentenceCase' }),
},
{
control: (
<Switch
aria-label={t('setting.playerbarOpenDrawer ', { postProcess: 'sentenceCase' })}
defaultChecked={settings.playerbarOpenDrawer}
onChange={(e) =>
setSettings({
general: {
...settings,
playerbarOpenDrawer: e.currentTarget.checked,
},
})
}
/>
),
description: t('setting.playerbarOpenDrawer', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: false,
title: t('setting.playerbarOpenDrawer', { postProcess: 'sentenceCase' }),
},
];

return <SettingsSection options={controlOptions} />;
Expand Down
29 changes: 26 additions & 3 deletions src/renderer/layouts/default-layout/player-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
import { useState } from 'react';
import styled from 'styled-components';
import { Playerbar } from '/@/renderer/features/player';
import { useGeneralSettings } from '/@/renderer/store/settings.store';

const PlayerbarContainer = styled.footer`
interface PlayerbarContainerProps {
barState: string;
}

const PlayerbarContainer = styled.footer<PlayerbarContainerProps>`
z-index: 200;
grid-area: player;
background: var(--playerbar-bg);
background: var(--${(props) => props.barState});
transition: background 0.5s;
`;

export const PlayerBar = () => {
const { playerbarOpenDrawer } = useGeneralSettings();
const [barState, setBarState] = useState('playerbar-bg');

const handleMouseEnter = () => {
setBarState('playerbar-bg-active');
};

const handleMouseLeave = () => {
setBarState('playerbar-bg');
};

return (
<PlayerbarContainer id="player-bar">
<PlayerbarContainer
barState={barState}
id="player-bar"
onMouseLeave={playerbarOpenDrawer ? handleMouseLeave : undefined}
onMouseOver={playerbarOpenDrawer ? handleMouseEnter : undefined}
>
<Playerbar />
</PlayerbarContainer>
);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/themes/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
--sidebar-handle-bg: #4d4d4d;
--sidebar-border: 2px rgba(18, 18, 18, 70%) solid;
--playerbar-bg: rgb(16, 16, 16);
--playerbar-bg-active: rgb(14, 14, 14);
--playerbar-btn-main-fg: rgb(0, 0, 0);
--playerbar-btn-main-fg-hover: rgb(0, 0, 0);
--playerbar-btn-main-bg: rgb(230, 230, 230);
Expand Down
7 changes: 2 additions & 5 deletions src/renderer/themes/light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ body[data-theme='defaultLight'] {
--sidebar-fg-hover: rgb(85, 85, 85);
--sidebar-handle-bg: rgb(220, 220, 220);
--sidebar-border: 1px rgba(220, 220, 220, 70%) solid;
--playerbar-bg: linear-gradient(
rgb(220, 220, 220) 0%,
rgb(240, 240, 240) 50%,
rgb(220, 220, 220) 100%
);
--playerbar-bg: rgb(220, 220, 220);
--playerbar-bg-active: rgb(175, 175, 175);
--playerbar-btn-main-fg: rgb(0, 0, 0);
--playerbar-btn-main-fg-hover: rgb(0, 0, 0);
--playerbar-btn-main-bg: transparent;
Expand Down

0 comments on commit c887a9b

Please sign in to comment.