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