Convert all remaining files to typescript.
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
import brightness from "../../../../services/Brightness.js";
|
||||
import icons from "../../../icons/index.js";
|
||||
|
||||
const Brightness = () => {
|
||||
return Widget.Box({
|
||||
class_name: "menu-section-container brightness",
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "menu-label-container",
|
||||
hpack: "fill",
|
||||
child: Widget.Label({
|
||||
class_name: "menu-label",
|
||||
hexpand: true,
|
||||
hpack: "start",
|
||||
label: "Brightness",
|
||||
}),
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "menu-items-section",
|
||||
vpack: "fill",
|
||||
vexpand: true,
|
||||
vertical: true,
|
||||
child: Widget.Box({
|
||||
class_name: "brightness-container",
|
||||
children: [
|
||||
Widget.Icon({
|
||||
vexpand: true,
|
||||
vpack: "center",
|
||||
class_name: "brightness-slider-icon",
|
||||
icon: icons.brightness.screen,
|
||||
}),
|
||||
Widget.Slider({
|
||||
vpack: "center",
|
||||
vexpand: true,
|
||||
value: brightness.bind("screen_value"),
|
||||
class_name: "menu-active-slider menu-slider brightness",
|
||||
draw_value: false,
|
||||
hexpand: true,
|
||||
min: 0,
|
||||
max: 1,
|
||||
onChange: ({ value }) => (brightness.screen_value = value),
|
||||
}),
|
||||
Widget.Label({
|
||||
vpack: "center",
|
||||
vexpand: true,
|
||||
class_name: "brightness-slider-label",
|
||||
label: brightness
|
||||
.bind("screen_value")
|
||||
.as((b) => `${Math.floor(b * 100)}%`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export { Brightness };
|
||||
59
modules/menus/energy/brightness/index.ts
Normal file
59
modules/menus/energy/brightness/index.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import brightness from "../../../../services/Brightness.js";
|
||||
import icons from "../../../icons/index.js";
|
||||
|
||||
const Brightness = () => {
|
||||
return Widget.Box({
|
||||
class_name: "menu-section-container brightness",
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "menu-label-container",
|
||||
hpack: "fill",
|
||||
child: Widget.Label({
|
||||
class_name: "menu-label",
|
||||
hexpand: true,
|
||||
hpack: "start",
|
||||
label: "Brightness",
|
||||
}),
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "menu-items-section",
|
||||
vpack: "fill",
|
||||
vexpand: true,
|
||||
vertical: true,
|
||||
child: Widget.Box({
|
||||
class_name: "brightness-container",
|
||||
children: [
|
||||
Widget.Icon({
|
||||
vexpand: true,
|
||||
vpack: "center",
|
||||
class_name: "brightness-slider-icon",
|
||||
icon: icons.brightness.screen,
|
||||
}),
|
||||
Widget.Slider({
|
||||
vpack: "center",
|
||||
vexpand: true,
|
||||
value: brightness.bind("screen_value"),
|
||||
class_name: "menu-active-slider menu-slider brightness",
|
||||
draw_value: false,
|
||||
hexpand: true,
|
||||
min: 0,
|
||||
max: 1,
|
||||
onChange: ({ value }) => (brightness.screen_value = value),
|
||||
}),
|
||||
Widget.Label({
|
||||
vpack: "center",
|
||||
vexpand: true,
|
||||
class_name: "brightness-slider-label",
|
||||
label: brightness
|
||||
.bind("screen_value")
|
||||
.as((b) => `${Math.floor(b * 100)}%`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export { Brightness };
|
||||
@@ -1,25 +0,0 @@
|
||||
import DropdownMenu from "../DropdownMenu.js";
|
||||
import { EnergyProfiles } from "./profiles/index.js";
|
||||
import { Brightness } from "./brightness/index.js";
|
||||
|
||||
export default () => {
|
||||
return DropdownMenu({
|
||||
name: "energymenu",
|
||||
transition: "crossfade",
|
||||
child: Widget.Box({
|
||||
class_name: "menu-items energy",
|
||||
hpack: "fill",
|
||||
hexpand: true,
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
hpack: "fill",
|
||||
hexpand: true,
|
||||
class_name: "menu-items-container energy",
|
||||
children: [
|
||||
Brightness(),
|
||||
EnergyProfiles(),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
};
|
||||
25
modules/menus/energy/index.ts
Normal file
25
modules/menus/energy/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import DropdownMenu from "../DropdownMenu.js";
|
||||
import { EnergyProfiles } from "./profiles/index.js";
|
||||
import { Brightness } from "./brightness/index.js";
|
||||
|
||||
export default () => {
|
||||
return DropdownMenu({
|
||||
name: "energymenu",
|
||||
transition: "crossfade",
|
||||
child: Widget.Box({
|
||||
class_name: "menu-items energy",
|
||||
hpack: "fill",
|
||||
hexpand: true,
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
hpack: "fill",
|
||||
hexpand: true,
|
||||
class_name: "menu-items-container energy",
|
||||
children: [
|
||||
Brightness(),
|
||||
EnergyProfiles(),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
};
|
||||
@@ -1,58 +0,0 @@
|
||||
const powerProfiles = await Service.import("powerprofiles");
|
||||
import icons from "../../../icons/index.js";
|
||||
|
||||
const EnergyProfiles = () => {
|
||||
return Widget.Box({
|
||||
class_name: "menu-section-container energy",
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "menu-label-container",
|
||||
hpack: "fill",
|
||||
child: Widget.Label({
|
||||
class_name: "menu-label",
|
||||
hexpand: true,
|
||||
hpack: "start",
|
||||
label: "Power Profile",
|
||||
}),
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "menu-items-section",
|
||||
vpack: "fill",
|
||||
vexpand: true,
|
||||
vertical: true,
|
||||
children: powerProfiles.bind("profiles").as((profiles) => {
|
||||
return profiles.map((prof) => {
|
||||
const ProfileLabels = {
|
||||
"power-saver": "Power Saver",
|
||||
balanced: "Balanced",
|
||||
performance: "Performance",
|
||||
};
|
||||
return Widget.Button({
|
||||
on_primary_click: () => {
|
||||
powerProfiles.active_profile = prof.Profile;
|
||||
},
|
||||
class_name: powerProfiles.bind("active_profile").as((active) => {
|
||||
return `power-profile-item ${active === prof.Profile ? "active" : ""}`;
|
||||
}),
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Icon({
|
||||
class_name: "power-profile-icon",
|
||||
icon: icons.powerprofile[prof.Profile],
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "power-profile-label",
|
||||
label: ProfileLabels[prof.Profile],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export { EnergyProfiles };
|
||||
58
modules/menus/energy/profiles/index.ts
Normal file
58
modules/menus/energy/profiles/index.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
const powerProfiles = await Service.import("powerprofiles");
|
||||
import icons from "../../../icons/index.js";
|
||||
|
||||
const EnergyProfiles = () => {
|
||||
return Widget.Box({
|
||||
class_name: "menu-section-container energy",
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "menu-label-container",
|
||||
hpack: "fill",
|
||||
child: Widget.Label({
|
||||
class_name: "menu-label",
|
||||
hexpand: true,
|
||||
hpack: "start",
|
||||
label: "Power Profile",
|
||||
}),
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "menu-items-section",
|
||||
vpack: "fill",
|
||||
vexpand: true,
|
||||
vertical: true,
|
||||
children: powerProfiles.bind("profiles").as((profiles) => {
|
||||
return profiles.map((prof) => {
|
||||
const ProfileLabels = {
|
||||
"power-saver": "Power Saver",
|
||||
balanced: "Balanced",
|
||||
performance: "Performance",
|
||||
};
|
||||
return Widget.Button({
|
||||
on_primary_click: () => {
|
||||
powerProfiles.active_profile = prof.Profile;
|
||||
},
|
||||
class_name: powerProfiles.bind("active_profile").as((active) => {
|
||||
return `power-profile-item ${active === prof.Profile ? "active" : ""}`;
|
||||
}),
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Icon({
|
||||
class_name: "power-profile-icon",
|
||||
icon: icons.powerprofile[prof.Profile],
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "power-profile-label",
|
||||
label: ProfileLabels[prof.Profile],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export { EnergyProfiles };
|
||||
Reference in New Issue
Block a user