From e0917ffb28fb958a4a92e0aff43f7f6701687b96 Mon Sep 17 00:00:00 2001 From: ilikestreet Date: Tue, 24 Dec 2024 18:34:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20no=20update=20w/=20autohide=20option=20?= =?UTF-8?q?&=20add=20option=20to=20swap=20netstat=20icon=20=E2=80=A6=20(#5?= =?UTF-8?q?91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: no update w/ autohide option & add option to swap netstat icon for up/down links * Update src/scss/style/bar/bar.scss * Update src/components/bar/shared/Module.tsx * Update src/components/bar/settings/config.tsx * Update src/options.ts * Apply suggestions from code review * move visibilty to updatesIcon func --------- Co-authored-by: Jas Singh --- src/components/bar/modules/netstat/index.tsx | 8 +++++--- src/components/bar/modules/updates/index.tsx | 4 ++++ src/components/bar/settings/config.tsx | 12 ++++++++++++ src/components/bar/shared/Module.tsx | 3 ++- src/lib/types/bar.d.ts | 1 + src/options.ts | 3 +++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/components/bar/modules/netstat/index.tsx b/src/components/bar/modules/netstat/index.tsx index 8a515e6..ae0f7f5 100644 --- a/src/components/bar/modules/netstat/index.tsx +++ b/src/components/bar/modules/netstat/index.tsx @@ -19,6 +19,8 @@ const { rateUnit, dynamicIcon, icon, + networkInLabel, + networkOutLabel, round, leftClick, rightClick, @@ -47,11 +49,11 @@ export const Netstat = (): BarBoxChild => { const renderNetworkLabel = (lblType: NetstatLabelType, networkService: NetworkResourceData): string => { switch (lblType) { case 'in': - return `↓ ${networkService.in}`; + return `${networkInLabel.get()} ${networkService.in}`; case 'out': - return `↑ ${networkService.out}`; + return `${networkOutLabel.get()} ${networkService.out}`; default: - return `↓ ${networkService.in} ↑ ${networkService.out}`; + return `${networkInLabel.get()} ${networkService.in} ${networkOutLabel.get()} ${networkService.out}`; } }; diff --git a/src/components/bar/modules/updates/index.tsx b/src/components/bar/modules/updates/index.tsx index 6887c17..d7307a3 100644 --- a/src/components/bar/modules/updates/index.tsx +++ b/src/components/bar/modules/updates/index.tsx @@ -10,6 +10,7 @@ const { updateCommand, label, padZero, + autoHide, pollingInterval, icon, leftClick, @@ -21,6 +22,7 @@ const { const pendingUpdates: Variable = Variable('0'); const postInputUpdater = Variable(true); +const isVis = Variable(!autoHide.get()); const processUpdateCount = (updateCount: string): string => { if (!padZero.get()) return updateCount; @@ -40,6 +42,7 @@ updatesPoller.initialize('updates'); const updatesIcon = Variable.derive( [bind(icon.pending), bind(icon.updated), bind(pendingUpdates)], (pendingIcon, updatedIcon, pUpdates) => { + isVis.set(!autoHide.get() || (autoHide.get() && parseFloat(pUpdates) > 0)); return parseFloat(pUpdates) === 0 ? updatedIcon : pendingIcon; }, ); @@ -49,6 +52,7 @@ export const Updates = (): BarBoxChild => { textIcon: updatesIcon(), tooltipText: bind(pendingUpdates).as((v) => `${v} updates available`), boxClass: 'updates', + isVis: isVis, label: bind(pendingUpdates), showLabelBinding: bind(label), props: { diff --git a/src/components/bar/settings/config.tsx b/src/components/bar/settings/config.tsx index e43fc37..384715e 100644 --- a/src/components/bar/settings/config.tsx +++ b/src/components/bar/settings/config.tsx @@ -154,6 +154,12 @@ export const CustomModuleSettings = (): JSX.Element => { />