nixos-configs/devices/wim/config/ags/js/bar/buttons/brightness.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

import { Box, EventBox, Icon, Label, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import Brightness from '../../../services/brightness.js';
2023-11-16 00:48:50 -05:00
import Separator from '../../misc/separator.js';
const SPACING = 5;
2023-09-08 15:15:04 -04:00
const Indicator = (props) => Icon({
...props,
binds: [['icon', Brightness, 'screen-icon']],
});
const BrightnessPercentLabel = (props) => Label({
...props,
connections: [[Brightness, (self) => {
self.label = `${Math.round(Brightness.screen * 100)}%`;
}, 'screen']],
});
export default () => {
const rev = Revealer({
transition: 'slide_right',
child: Box({
children: [
Separator(SPACING),
BrightnessPercentLabel(),
],
}),
});
const widget = EventBox({
onHover: () => {
rev.revealChild = true;
},
onHoverLost: () => {
rev.revealChild = false;
},
child: Box({
className: 'brightness',
children: [
Indicator(),
rev,
],
}),
});
widget.rev = rev;
return widget;
};