Files
custum-hyprpanel/modules/bar/network/index.ts
Jas Singh 3dc5bbbe13 Adding configuration options to change spacing between icons and labels inside the buttons in the bar. (#30)
* Branch protection check.

* Move button spacing config into the Configuration section instead of Theming.

* Partially Resolves #26 - Added the ability to configure outer spacing on the bar.

* Renamed all class names for buttons so they can be styled with margins.

* Added configurable spacing to buttons.

* Fixed styling for network module when using wifi.

* Fixed ghost margins that occur when labels are disabled in the bar buttons.

* Change the default page of the settings dialog to configuration.
2024-07-28 15:16:31 -07:00

72 lines
2.1 KiB
TypeScript

import Gdk from 'gi://Gdk?version=3.0';
const network = await Service.import("network");
import options from "options";
import { openMenu } from "../utils.js";
const Network = () => {
const wifiIndicator = [
Widget.Icon({
class_name: "bar-button-icon network",
icon: network.wifi.bind("icon_name"),
}),
Widget.Box({
children: Utils.merge(
[network.bind("wifi"), options.bar.network.label.bind("value")],
(wifi, showLabel) => {
if (!showLabel) {
return [];
}
return [
Widget.Label({
class_name: "bar-button-label network",
label: wifi.ssid ? `${wifi.ssid.substring(0, 7)}` : "--",
}),
]
},
)
})
];
const wiredIndicator = [
Widget.Icon({
class_name: "bar-button-icon network",
icon: network.wired.bind("icon_name"),
}),
Widget.Box({
children: Utils.merge(
[network.bind("wired"), options.bar.network.label.bind("value")],
(_, showLabel) => {
if (!showLabel) {
return [];
}
return [
Widget.Label({
class_name: "bar-button-label network",
label: "Wired",
}),
]
},
)
})
];
return {
component: Widget.Box({
vpack: "center",
class_name: "bar-network",
children: network
.bind("primary")
.as((w) => (w === "wired" ? wiredIndicator : wifiIndicator)),
}),
isVisible: true,
boxClass: "network",
props: {
on_primary_click: (clicked: any, event: Gdk.Event) => {
openMenu(clicked, event, "networkmenu");
},
},
};
};
export { Network };