feat: no update w/ autohide option & add option to swap netstat icon … (#591)
* 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 <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -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}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ const {
|
||||
updateCommand,
|
||||
label,
|
||||
padZero,
|
||||
autoHide,
|
||||
pollingInterval,
|
||||
icon,
|
||||
leftClick,
|
||||
@@ -21,6 +22,7 @@ const {
|
||||
|
||||
const pendingUpdates: Variable<string> = 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: {
|
||||
|
||||
@@ -154,6 +154,12 @@ export const CustomModuleSettings = (): JSX.Element => {
|
||||
/>
|
||||
<Option opt={options.bar.customModules.netstat.icon} title="Netstat Icon" type="string" />
|
||||
<Option opt={options.bar.customModules.netstat.label} title="Show Label" type="boolean" />
|
||||
<Option opt={options.bar.customModules.netstat.networkInLabel} title="Network In Label" type="string" />
|
||||
<Option
|
||||
opt={options.bar.customModules.netstat.networkOutLabel}
|
||||
title="Network Out Label"
|
||||
type="string"
|
||||
/>
|
||||
<Option
|
||||
opt={options.bar.customModules.netstat.rateUnit}
|
||||
title="Rate Unit"
|
||||
@@ -221,6 +227,12 @@ export const CustomModuleSettings = (): JSX.Element => {
|
||||
/>
|
||||
<Option opt={options.bar.customModules.updates.icon.updated} title="No Updates Icon" type="string" />
|
||||
<Option opt={options.bar.customModules.updates.label} title="Show Label" type="boolean" />
|
||||
<Option
|
||||
opt={options.bar.customModules.updates.autoHide}
|
||||
title="Auto Hide"
|
||||
subtitle="Hides module when no updates are available."
|
||||
type="boolean"
|
||||
/>
|
||||
<Option opt={options.bar.customModules.updates.padZero} title="Pad with 0" type="boolean" />
|
||||
<Option opt={options.theme.bar.buttons.modules.updates.spacing} title="Spacing" type="string" />
|
||||
<Option
|
||||
|
||||
@@ -14,6 +14,7 @@ export const Module = ({
|
||||
label,
|
||||
tooltipText,
|
||||
boxClass,
|
||||
isVis,
|
||||
props = {},
|
||||
showLabelBinding = bind(undefinedVar),
|
||||
showLabel,
|
||||
@@ -86,7 +87,7 @@ export const Module = ({
|
||||
return {
|
||||
component,
|
||||
tooltip_text: tooltipText,
|
||||
isVisible: true,
|
||||
isVis: isVis,
|
||||
boxClass,
|
||||
props,
|
||||
};
|
||||
|
||||
1
src/lib/types/bar.d.ts
vendored
1
src/lib/types/bar.d.ts
vendored
@@ -29,6 +29,7 @@ export type BarModule = {
|
||||
boundLabel?: string;
|
||||
tooltipText?: string | Binding<string>;
|
||||
boxClass: string;
|
||||
isVis?: Variable<boolean>;
|
||||
props?: Widget.ButtonProps;
|
||||
showLabel?: boolean;
|
||||
showLabelBinding?: Binding;
|
||||
|
||||
@@ -1072,6 +1072,8 @@ const options = mkOptions(CONFIG, {
|
||||
networkInterface: opt(''),
|
||||
dynamicIcon: opt(false),
|
||||
icon: opt(''),
|
||||
networkInLabel: opt('↓'),
|
||||
networkOutLabel: opt('↑'),
|
||||
round: opt(true),
|
||||
labelType: opt<NetstatLabelType>('full'),
|
||||
rateUnit: opt<RateUnit>('auto'),
|
||||
@@ -1094,6 +1096,7 @@ const options = mkOptions(CONFIG, {
|
||||
updateCommand: opt(`${SRC_DIR}/scripts/checkUpdates.sh -arch`),
|
||||
label: opt(true),
|
||||
padZero: opt(true),
|
||||
autoHide: opt(false),
|
||||
icon: {
|
||||
pending: opt(''),
|
||||
updated: opt(''),
|
||||
|
||||
Reference in New Issue
Block a user