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,
|
rateUnit,
|
||||||
dynamicIcon,
|
dynamicIcon,
|
||||||
icon,
|
icon,
|
||||||
|
networkInLabel,
|
||||||
|
networkOutLabel,
|
||||||
round,
|
round,
|
||||||
leftClick,
|
leftClick,
|
||||||
rightClick,
|
rightClick,
|
||||||
@@ -47,11 +49,11 @@ export const Netstat = (): BarBoxChild => {
|
|||||||
const renderNetworkLabel = (lblType: NetstatLabelType, networkService: NetworkResourceData): string => {
|
const renderNetworkLabel = (lblType: NetstatLabelType, networkService: NetworkResourceData): string => {
|
||||||
switch (lblType) {
|
switch (lblType) {
|
||||||
case 'in':
|
case 'in':
|
||||||
return `↓ ${networkService.in}`;
|
return `${networkInLabel.get()} ${networkService.in}`;
|
||||||
case 'out':
|
case 'out':
|
||||||
return `↑ ${networkService.out}`;
|
return `${networkOutLabel.get()} ${networkService.out}`;
|
||||||
default:
|
default:
|
||||||
return `↓ ${networkService.in} ↑ ${networkService.out}`;
|
return `${networkInLabel.get()} ${networkService.in} ${networkOutLabel.get()} ${networkService.out}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const {
|
|||||||
updateCommand,
|
updateCommand,
|
||||||
label,
|
label,
|
||||||
padZero,
|
padZero,
|
||||||
|
autoHide,
|
||||||
pollingInterval,
|
pollingInterval,
|
||||||
icon,
|
icon,
|
||||||
leftClick,
|
leftClick,
|
||||||
@@ -21,6 +22,7 @@ const {
|
|||||||
|
|
||||||
const pendingUpdates: Variable<string> = Variable('0');
|
const pendingUpdates: Variable<string> = Variable('0');
|
||||||
const postInputUpdater = Variable(true);
|
const postInputUpdater = Variable(true);
|
||||||
|
const isVis = Variable(!autoHide.get());
|
||||||
|
|
||||||
const processUpdateCount = (updateCount: string): string => {
|
const processUpdateCount = (updateCount: string): string => {
|
||||||
if (!padZero.get()) return updateCount;
|
if (!padZero.get()) return updateCount;
|
||||||
@@ -40,6 +42,7 @@ updatesPoller.initialize('updates');
|
|||||||
const updatesIcon = Variable.derive(
|
const updatesIcon = Variable.derive(
|
||||||
[bind(icon.pending), bind(icon.updated), bind(pendingUpdates)],
|
[bind(icon.pending), bind(icon.updated), bind(pendingUpdates)],
|
||||||
(pendingIcon, updatedIcon, pUpdates) => {
|
(pendingIcon, updatedIcon, pUpdates) => {
|
||||||
|
isVis.set(!autoHide.get() || (autoHide.get() && parseFloat(pUpdates) > 0));
|
||||||
return parseFloat(pUpdates) === 0 ? updatedIcon : pendingIcon;
|
return parseFloat(pUpdates) === 0 ? updatedIcon : pendingIcon;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -49,6 +52,7 @@ export const Updates = (): BarBoxChild => {
|
|||||||
textIcon: updatesIcon(),
|
textIcon: updatesIcon(),
|
||||||
tooltipText: bind(pendingUpdates).as((v) => `${v} updates available`),
|
tooltipText: bind(pendingUpdates).as((v) => `${v} updates available`),
|
||||||
boxClass: 'updates',
|
boxClass: 'updates',
|
||||||
|
isVis: isVis,
|
||||||
label: bind(pendingUpdates),
|
label: bind(pendingUpdates),
|
||||||
showLabelBinding: bind(label),
|
showLabelBinding: bind(label),
|
||||||
props: {
|
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.icon} title="Netstat Icon" type="string" />
|
||||||
<Option opt={options.bar.customModules.netstat.label} title="Show Label" type="boolean" />
|
<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
|
<Option
|
||||||
opt={options.bar.customModules.netstat.rateUnit}
|
opt={options.bar.customModules.netstat.rateUnit}
|
||||||
title="Rate Unit"
|
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.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.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.bar.customModules.updates.padZero} title="Pad with 0" type="boolean" />
|
||||||
<Option opt={options.theme.bar.buttons.modules.updates.spacing} title="Spacing" type="string" />
|
<Option opt={options.theme.bar.buttons.modules.updates.spacing} title="Spacing" type="string" />
|
||||||
<Option
|
<Option
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const Module = ({
|
|||||||
label,
|
label,
|
||||||
tooltipText,
|
tooltipText,
|
||||||
boxClass,
|
boxClass,
|
||||||
|
isVis,
|
||||||
props = {},
|
props = {},
|
||||||
showLabelBinding = bind(undefinedVar),
|
showLabelBinding = bind(undefinedVar),
|
||||||
showLabel,
|
showLabel,
|
||||||
@@ -86,7 +87,7 @@ export const Module = ({
|
|||||||
return {
|
return {
|
||||||
component,
|
component,
|
||||||
tooltip_text: tooltipText,
|
tooltip_text: tooltipText,
|
||||||
isVisible: true,
|
isVis: isVis,
|
||||||
boxClass,
|
boxClass,
|
||||||
props,
|
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;
|
boundLabel?: string;
|
||||||
tooltipText?: string | Binding<string>;
|
tooltipText?: string | Binding<string>;
|
||||||
boxClass: string;
|
boxClass: string;
|
||||||
|
isVis?: Variable<boolean>;
|
||||||
props?: Widget.ButtonProps;
|
props?: Widget.ButtonProps;
|
||||||
showLabel?: boolean;
|
showLabel?: boolean;
|
||||||
showLabelBinding?: Binding;
|
showLabelBinding?: Binding;
|
||||||
|
|||||||
@@ -1072,6 +1072,8 @@ const options = mkOptions(CONFIG, {
|
|||||||
networkInterface: opt(''),
|
networkInterface: opt(''),
|
||||||
dynamicIcon: opt(false),
|
dynamicIcon: opt(false),
|
||||||
icon: opt(''),
|
icon: opt(''),
|
||||||
|
networkInLabel: opt('↓'),
|
||||||
|
networkOutLabel: opt('↑'),
|
||||||
round: opt(true),
|
round: opt(true),
|
||||||
labelType: opt<NetstatLabelType>('full'),
|
labelType: opt<NetstatLabelType>('full'),
|
||||||
rateUnit: opt<RateUnit>('auto'),
|
rateUnit: opt<RateUnit>('auto'),
|
||||||
@@ -1094,6 +1096,7 @@ const options = mkOptions(CONFIG, {
|
|||||||
updateCommand: opt(`${SRC_DIR}/scripts/checkUpdates.sh -arch`),
|
updateCommand: opt(`${SRC_DIR}/scripts/checkUpdates.sh -arch`),
|
||||||
label: opt(true),
|
label: opt(true),
|
||||||
padZero: opt(true),
|
padZero: opt(true),
|
||||||
|
autoHide: opt(false),
|
||||||
icon: {
|
icon: {
|
||||||
pending: opt(''),
|
pending: opt(''),
|
||||||
updated: opt(''),
|
updated: opt(''),
|
||||||
|
|||||||
Reference in New Issue
Block a user