navbar: config show labels

Hide labels by default
This commit is contained in:
2 * r + 2 * t 2025-04-11 22:25:27 +10:00
parent 1ad2446e0a
commit cbf613e42c
3 changed files with 38 additions and 23 deletions

View file

@ -120,6 +120,7 @@ export default {
navbar: { navbar: {
persistent: false, // Whether to show all the time or only on hover persistent: false, // Whether to show all the time or only on hover
appearWidth: 10, // The width in pixels of the hover area for the navbar to show up appearWidth: 10, // The width in pixels of the hover area for the navbar to show up
showLabels: false, // Whether to show labels for active buttons
}, },
// Services // Services
math: { math: {

View file

@ -61,6 +61,7 @@ export default {
// Navbar // Navbar
"navbar.persistent": BOOL, "navbar.persistent": BOOL,
"navbar.appearWidth": NUM, "navbar.appearWidth": NUM,
"navbar.showLabels": BOOL,
// Services // Services
"math.maxHistory": NUM, "math.maxHistory": NUM,
"updates.interval": NUM, "updates.interval": NUM,

View file

@ -61,7 +61,14 @@ const PaneButton = ({
<revealer <revealer
transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN} transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN}
transitionDuration={150} transitionDuration={150}
setup={self => hookIsCurrent(self, sidebar, name, c => self.set_reveal_child(c))} setup={self => {
let isCurrent = false;
hookIsCurrent(self, sidebar, name, c => {
isCurrent = c;
self.set_reveal_child(config.showLabels.get() && c);
});
self.hook(config.showLabels, (_, v) => self.set_reveal_child(v && isCurrent));
}}
> >
<label truncate wrapMode={Pango.WrapMode.WORD_CHAR} className="label" label={capitalize(name)} /> <label truncate wrapMode={Pango.WrapMode.WORD_CHAR} className="label" label={capitalize(name)} />
</revealer> </revealer>
@ -69,28 +76,34 @@ const PaneButton = ({
</button> </button>
); );
const SpecialWsButton = ({ name }: { name: SpecialWsName }) => ( const SpecialWsButton = ({ name }: { name: SpecialWsName }) => {
<button const revealChild = Variable.derive(
className={bind(AstalHyprland.get_default(), "focusedClient").as(c => [config.showLabels, bind(AstalHyprland.get_default(), "focusedClient")],
c?.get_workspace().get_name() === `special:${name}` ? "current" : "" (l, c) => l && c?.get_workspace().get_name() === `special:${name}`
)} );
cursor="pointer"
onClicked={() => execAsync(`caelestia toggle ${name}`).catch(console.error)} return (
> <button
<box vertical className="nav-button"> className={bind(AstalHyprland.get_default(), "focusedClient").as(c =>
<label className="icon" label={getSpecialWsIcon(name)} /> c?.get_workspace().get_name() === `special:${name}` ? "current" : ""
<revealer )}
transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN} cursor="pointer"
transitionDuration={150} onClicked={() => execAsync(`caelestia toggle ${name}`).catch(console.error)}
revealChild={bind(AstalHyprland.get_default(), "focusedClient").as( >
c => c?.get_workspace().get_name() === `special:${name}` <box vertical className="nav-button">
)} <label className="icon" label={getSpecialWsIcon(name)} />
> <revealer
<label truncate wrapMode={Pango.WrapMode.WORD_CHAR} className="label" label={capitalize(name)} /> transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN}
</revealer> transitionDuration={150}
</box> revealChild={bind(revealChild)}
</button> onDestroy={() => revealChild.drop()}
); >
<label truncate wrapMode={Pango.WrapMode.WORD_CHAR} className="label" label={capitalize(name)} />
</revealer>
</box>
</button>
);
};
export default ({ monitor }: { monitor: Monitor }) => { export default ({ monitor }: { monitor: Monitor }) => {
const sidebar = Variable<SideBar | null>(null); const sidebar = Variable<SideBar | null>(null);