sidebar: news use monitor height

Use monitor height instead of absolute
This commit is contained in:
2 * r + 2 * t 2025-04-09 15:54:46 +10:00
parent b26bd44735
commit 71025c6ed0
6 changed files with 20 additions and 20 deletions

View file

@ -751,10 +751,6 @@
.news { .news {
min-height: lib.s(200); min-height: lib.s(200);
.expanded {
min-height: lib.s(500);
}
.empty { .empty {
margin-top: lib.s(40); margin-top: lib.s(40);
} }
@ -795,10 +791,6 @@
.headlines { .headlines {
min-height: lib.s(200); min-height: lib.s(200);
.expanded {
min-height: lib.s(500);
}
.empty { .empty {
margin-top: lib.s(40); margin-top: lib.s(40);
} }

View file

@ -1,10 +1,11 @@
import type { Monitor } from "@/services/monitors";
import Headlines from "./modules/headlines"; import Headlines from "./modules/headlines";
import Notifications from "./modules/notifications"; import Notifications from "./modules/notifications";
export default () => ( export default ({ monitor }: { monitor: Monitor }) => (
<box vertical className="pane alerts" name="alerts"> <box vertical className="pane alerts" name="alerts">
<Notifications /> <Notifications />
<box className="separator" /> <box className="separator" />
<Headlines /> <Headlines monitor={monitor} />
</box> </box>
); );

View file

@ -33,12 +33,12 @@ export const awaitSidebar = (monitor: Monitor) =>
idle(awaitSidebar); idle(awaitSidebar);
}); });
const getPane = (name: PaneName) => { const getPane = (monitor: Monitor, name: PaneName) => {
if (name === "dashboard") return <Dashboard />; if (name === "dashboard") return <Dashboard />;
if (name === "audio") return <Audio />; if (name === "audio") return <Audio />;
if (name === "connectivity") return <Connectivity />; if (name === "connectivity") return <Connectivity />;
if (name === "packages") return <Packages />; if (name === "packages") return <Packages monitor={monitor} />;
if (name === "alerts") return <Alerts />; if (name === "alerts") return <Alerts monitor={monitor} />;
return <Time />; return <Time />;
}; };
@ -76,7 +76,7 @@ export default class SideBar extends Widget.Window {
transitionDuration={200} transitionDuration={200}
shown={bind(this.shown)} shown={bind(this.shown)}
> >
{paneNames.map(getPane)} {paneNames.map(n => getPane(monitor, n))}
</stack> </stack>
</box> </box>
</eventbox> </eventbox>

View file

@ -1,3 +1,4 @@
import type { Monitor } from "@/services/monitors";
import News, { type IArticle } from "@/services/news"; import News, { type IArticle } from "@/services/news";
import Palette, { type IPalette } from "@/services/palette"; import Palette, { type IPalette } from "@/services/palette";
import { capitalize } from "@/utils/strings"; import { capitalize } from "@/utils/strings";
@ -143,7 +144,7 @@ const NoNews = () => (
</box> </box>
); );
export default () => ( export default ({ monitor }: { monitor: Monitor }) => (
<box vertical className="headlines"> <box vertical className="headlines">
<box className="header-bar"> <box className="header-bar">
<label label="Top news headlines" /> <label label="Top news headlines" />
@ -163,7 +164,9 @@ export default () => (
> >
<NoNews /> <NoNews />
<scrollable <scrollable
className={bind(News.get_default(), "articles").as(a => (a.length > 0 ? "expanded" : ""))} css={bind(News.get_default(), "articles").as(a =>
a.length > 0 ? `min-height: ${Math.round(monitor.height * 0.4)}px;` : ""
)}
hscroll={Gtk.PolicyType.NEVER} hscroll={Gtk.PolicyType.NEVER}
name="list" name="list"
> >

View file

@ -1,3 +1,4 @@
import type { Monitor } from "@/services/monitors";
import Palette from "@/services/palette"; import Palette from "@/services/palette";
import Updates from "@/services/updates"; import Updates from "@/services/updates";
import { setupCustomTooltip } from "@/utils/widgets"; import { setupCustomTooltip } from "@/utils/widgets";
@ -75,7 +76,7 @@ const NoNews = () => (
</box> </box>
); );
export default () => ( export default ({ monitor }: { monitor: Monitor }) => (
<box vertical className="news"> <box vertical className="news">
<box className="header-bar"> <box className="header-bar">
<label <label
@ -99,7 +100,9 @@ export default () => (
> >
<NoNews /> <NoNews />
<scrollable <scrollable
className={bind(Updates.get_default(), "news").as(n => (n ? "expanded" : ""))} css={bind(Updates.get_default(), "news").as(n =>
n ? `min-height: ${Math.round(monitor.height * 0.4)}px;` : ""
)}
hscroll={Gtk.PolicyType.NEVER} hscroll={Gtk.PolicyType.NEVER}
name="list" name="list"
> >

View file

@ -1,10 +1,11 @@
import type { Monitor } from "@/services/monitors";
import News from "./modules/news"; import News from "./modules/news";
import Updates from "./modules/updates"; import Updates from "./modules/updates";
export default () => ( export default ({ monitor }: { monitor: Monitor }) => (
<box vertical className="pane packages" name="packages"> <box vertical className="pane packages" name="packages">
<Updates /> <Updates />
<box className="separator" /> <box className="separator" />
<News /> <News monitor={monitor} />
</box> </box>
); );