Fixed an issue that would caused empty dashboard shortcuts to not hide properly. (#610)

This commit is contained in:
Jas Singh
2024-12-24 02:17:08 -08:00
committed by GitHub
parent d8a59c1d18
commit a3f348c580
4 changed files with 44 additions and 8 deletions

View File

@@ -24,36 +24,60 @@ const ShortcutButton = ({ shortcut, ...props }: ShortcutButtonProps): JSX.Elemen
}; };
export const LeftShortcut1 = (): JSX.Element => { export const LeftShortcut1 = (): JSX.Element => {
if (!hasCommand(left.shortcut1)) {
return <box />;
}
return ( return (
<ShortcutButton <ShortcutButton
shortcut={left.shortcut1} shortcut={left.shortcut1}
className={`dashboard-button top-button ${hasCommand(left.shortcut1) ? 'paired' : ''}`} className={`dashboard-button top-button ${hasCommand(left.shortcut2) ? 'paired' : ''}`}
/> />
); );
}; };
export const LeftShortcut2 = (): JSX.Element => { export const LeftShortcut2 = (): JSX.Element => {
if (!hasCommand(left.shortcut2)) {
return <box />;
}
return <ShortcutButton shortcut={left.shortcut2} className={`dashboard-button`} />; return <ShortcutButton shortcut={left.shortcut2} className={`dashboard-button`} />;
}; };
export const LeftShortcut3 = (): JSX.Element => { export const LeftShortcut3 = (): JSX.Element => {
if (!hasCommand(left.shortcut3)) {
return <box />;
}
return ( return (
<ShortcutButton <ShortcutButton
shortcut={left.shortcut3} shortcut={left.shortcut3}
className={`dashboard-button top-button ${hasCommand(left.shortcut3) ? 'paired' : ''}`} className={`dashboard-button top-button ${hasCommand(left.shortcut4) ? 'paired' : ''}`}
/> />
); );
}; };
export const LeftShortcut4 = (): JSX.Element => { export const LeftShortcut4 = (): JSX.Element => {
if (!hasCommand(left.shortcut4)) {
return <box />;
}
return <ShortcutButton shortcut={left.shortcut4} className={`dashboard-button `} />; return <ShortcutButton shortcut={left.shortcut4} className={`dashboard-button `} />;
}; };
export const RightShortcut1 = (): JSX.Element => { export const RightShortcut1 = (): JSX.Element => {
if (!hasCommand(right.shortcut1)) {
return <box />;
}
return <ShortcutButton shortcut={right.shortcut1} className={`dashboard-button top-button paired`} />; return <ShortcutButton shortcut={right.shortcut1} className={`dashboard-button top-button paired`} />;
}; };
export const RightShortcut3 = (): JSX.Element => { export const RightShortcut3 = (): JSX.Element => {
if (!hasCommand(right.shortcut3)) {
return <box />;
}
return <ShortcutButton shortcut={right.shortcut3} className={`dashboard-button top-button paired`} />; return <ShortcutButton shortcut={right.shortcut3} className={`dashboard-button top-button paired`} />;
}; };

View File

@@ -1,9 +1,9 @@
import { BindableChild } from 'astal/gtk3/astalify'; import { BindableChild } from 'astal/gtk3/astalify';
export const LeftColumn = ({ visibleClass, children }: LeftColumnProps): JSX.Element => { export const LeftColumn = ({ isVisible, children }: LeftColumnProps): JSX.Element => {
return ( return (
<box className={`card-button-section-container ${visibleClass ? 'visible' : ''}`}> <box className={`card-button-section-container ${isVisible ? 'visible' : ''}`}>
{visibleClass ? ( {isVisible ? (
<box vertical hexpand vexpand> <box vertical hexpand vexpand>
{children} {children}
</box> </box>
@@ -25,7 +25,7 @@ export const RightColumn = ({ children }: RightColumnProps): JSX.Element => {
}; };
interface LeftColumnProps { interface LeftColumnProps {
visibleClass?: boolean; isVisible?: boolean;
children?: BindableChild | BindableChild[]; children?: BindableChild | BindableChild[];
} }

View File

@@ -57,7 +57,7 @@ export const LeftShortcuts = (): JSX.Element => {
return ( return (
<box className={'container most-used dashboard-card'}> <box className={'container most-used dashboard-card'}>
<LeftColumn visibleClass={isVisibleRight && isVisibleLeft}> <LeftColumn isVisible={isVisibleRight && isVisibleLeft}>
<LeftShortcut1 /> <LeftShortcut1 />
<LeftShortcut2 /> <LeftShortcut2 />
</LeftColumn> </LeftColumn>
@@ -78,7 +78,7 @@ export const RightShortcuts = (): JSX.Element => {
{Variable.derive(rightBindings, () => { {Variable.derive(rightBindings, () => {
return ( return (
<box className={`container utilities dashboard-card ${!leftCardHidden.get() ? 'paired' : ''}`}> <box className={`container utilities dashboard-card ${!leftCardHidden.get() ? 'paired' : ''}`}>
<LeftColumn visibleClass={!leftCardHidden.get()}> <LeftColumn isVisible={true}>
<RightShortcut1 /> <RightShortcut1 />
<SettingsButton /> <SettingsButton />
</LeftColumn> </LeftColumn>

View File

@@ -8,6 +8,14 @@ const { enable, duration, active_monitor, monitor } = options.theme.osd;
let count = 0; let count = 0;
/*
* So the OSD doesn't show on startup for no reason
*/
let isStartingUp = true;
timeout(3000, () => {
isStartingUp = false;
});
/** /**
* Handles the reveal state of a Widget.Revealer. * Handles the reveal state of a Widget.Revealer.
* *
@@ -69,6 +77,10 @@ export const handleRevealWindow = (self: Widget.Window, property: 'revealChild'
* @param property The property to check, either 'revealChild' or 'visible'. * @param property The property to check, either 'revealChild' or 'visible'.
*/ */
export const handleReveal = (self: Widget.Revealer | Widget.Window, property: 'revealChild' | 'visible'): void => { export const handleReveal = (self: Widget.Revealer | Widget.Window, property: 'revealChild' | 'visible'): void => {
if (isStartingUp) {
return;
}
if (self instanceof Widget.Revealer) { if (self instanceof Widget.Revealer) {
handleRevealRevealer(self, property); handleRevealRevealer(self, property);
} else if (self instanceof Widget.Window) { } else if (self instanceof Widget.Window) {