From fe978092e8c13b337eb4e58b9b08b9ea5cc93413 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 25 Mar 2025 12:59:51 +1100 Subject: sidebar: create dashboard --- app.tsx | 2 + scss/common.scss | 21 --- scss/notifpopups.scss | 8 +- scss/sidebar.scss | 221 ++++++++++++++++++++++++++ src/modules/sidebar/dashboard.tsx | 123 ++++++++++++++ src/modules/sidebar/index.tsx | 34 ++++ src/modules/sidebar/modules/hwresources.tsx | 67 ++++++++ src/modules/sidebar/modules/notifications.tsx | 70 ++++++++ src/services/calendar.ts | 0 src/widgets/notification.tsx | 26 +-- src/widgets/slider.tsx | 53 ++++++ style.scss | 2 +- 12 files changed, 592 insertions(+), 35 deletions(-) create mode 100644 scss/sidebar.scss create mode 100644 src/modules/sidebar/dashboard.tsx create mode 100644 src/modules/sidebar/index.tsx create mode 100644 src/modules/sidebar/modules/hwresources.tsx create mode 100644 src/modules/sidebar/modules/notifications.tsx create mode 100644 src/services/calendar.ts create mode 100644 src/widgets/slider.tsx diff --git a/app.tsx b/app.tsx index ad9693e..5d862ca 100644 --- a/app.tsx +++ b/app.tsx @@ -4,6 +4,7 @@ import NotifPopups from "@/modules/notifpopups"; import Osds from "@/modules/osds"; import Popdowns from "@/modules/popdowns"; import Session from "@/modules/session"; +import SideBar from "@/modules/sidebar"; import Monitors from "@/services/monitors"; import Palette from "@/services/palette"; import Players from "@/services/players"; @@ -73,6 +74,7 @@ App.start({ ; ; ; + Monitors.get_default().forEach(m => ); Monitors.get_default().forEach(m => ); ; diff --git a/scss/common.scss b/scss/common.scss index 88f3326..1cf7249 100644 --- a/scss/common.scss +++ b/scss/common.scss @@ -61,25 +61,4 @@ label.icon { font-size: lib.s(14); color: scheme.$subtext0; } - - .actions { - @include lib.spacing; - - & > * { - @include lib.rounded(5); - @include lib.element-decel; - - padding: lib.s(5) lib.s(10); - background-color: scheme.$surface0; - - &:hover, - &:focus { - background-color: scheme.$surface1; - } - - &:active { - background-color: scheme.$surface2; - } - } - } } diff --git a/scss/notifpopups.scss b/scss/notifpopups.scss index c4760b7..89e5eea 100644 --- a/scss/notifpopups.scss +++ b/scss/notifpopups.scss @@ -3,7 +3,7 @@ @use "lib"; @use "font"; -@mixin popup($colour, $alpha) { +@mixin popup($colour) { .separator { background-color: $colour; } @@ -29,16 +29,16 @@ @include lib.shadow; &.low { - @include popup(scheme.$overlay0, 0.3); + @include popup(scheme.$overlay0); } &.normal { - @include popup(scheme.$primary, 0.3); + @include popup(scheme.$primary); } &.critical { @include lib.border(scheme.$error, 0.5); - @include popup(scheme.$error, 0.8); + @include popup(scheme.$error); } } } diff --git a/scss/sidebar.scss b/scss/sidebar.scss new file mode 100644 index 0000000..84d1d61 --- /dev/null +++ b/scss/sidebar.scss @@ -0,0 +1,221 @@ +@use "sass:color"; +@use "scheme"; +@use "lib"; +@use "font"; + +@mixin notification($accent) { + .separator { + background-color: $accent; + } + + .image { + @include lib.border($accent, 0.05); + } +} + +.sidebar { + @include font.mono; + + background-color: scheme.$mantle; + color: scheme.$text; + padding: lib.s(18) lib.s(20); + min-width: lib.s(380); + + .pane { + @include lib.spacing(20, true); + } + + .separator { + background-color: if(scheme.$light, scheme.$surface1, scheme.$overlay0); + margin: 0 lib.s(10); + } + + .user { + @include lib.spacing(15); + + .face { + @include lib.rounded(10); + + background-position: center; + background-repeat: no-repeat; + background-size: cover; + min-width: lib.s(96); + min-height: lib.s(96); + font-size: lib.s(48); + font-weight: bold; + background-color: scheme.$base; + } + + .details { + font-size: lib.s(14); + color: scheme.$yellow; + + @include lib.spacing(8, true); + + .name { + font-size: lib.s(18); + color: scheme.$text; + margin-bottom: lib.s(10); + } + + .uptime { + color: scheme.$blue; + } + } + } + + .media { + @include lib.spacing(15); + + .cover-art { + @include lib.rounded(10); + @include lib.element-decel; + + background-position: center; + background-repeat: no-repeat; + background-size: cover; + min-width: lib.s(128); + min-height: lib.s(128); + font-size: lib.s(64); + font-weight: bold; + background-color: scheme.$base; + } + + .details { + font-size: lib.s(14); + + .title { + font-size: lib.s(16); + color: scheme.$text; + } + + .artist { + color: scheme.$green; + } + + .controls { + margin-top: lib.s(20); + margin-bottom: lib.s(5); + font-size: lib.s(24); + + & > * { + @include lib.element-decel; + + &:disabled { + color: scheme.$overlay0; + } + + &:hover, + &:focus { + color: scheme.$subtext0; + } + + &:active { + color: scheme.$overlay2; + } + } + } + + .slider { + @include lib.rounded(5); + @include lib.fluent-decel(1000ms); + + min-height: lib.s(8); + background-color: scheme.$surface0; + color: scheme.$overlay0; + } + + .time { + margin-top: lib.s(5); + font-size: lib.s(13); + color: scheme.$subtext0; + } + } + } + + .notifications { + .header-bar { + margin-bottom: lib.s(10); + margin-right: lib.s(-10); + + @include lib.spacing; + + & > button { + @include lib.element-decel; + @include lib.rounded(10); + + padding: lib.s(3) lib.s(8); + + &:hover, + &:focus { + color: scheme.$subtext0; + } + + &:active { + color: scheme.$overlay2; + } + + &.enabled { + background-color: scheme.$primary; + color: scheme.$base; + + &:hover, + &:focus { + background-color: color.mix(scheme.$primary, scheme.$base, 80%); + } + + &:active { + background-color: color.mix(scheme.$primary, scheme.$base, 70%); + } + } + } + } + + .notification { + .wrapper { + padding-bottom: lib.s(10); + } + + .inner { + @include lib.rounded(20); + + background-color: color.change(scheme.$surface1, $alpha: 0.4); + + &.low { + @include notification(if(scheme.$light, scheme.$surface1, scheme.$overlay0)); + } + + &.normal { + @include lib.border(scheme.$primary, if(scheme.$light, 0.5, 0.3)); + @include notification(scheme.$primary); + } + + &.critical { + @include lib.border(scheme.$error, 0.8); + @include notification(scheme.$error); + } + } + + .actions { + @include lib.spacing; + + & > button { + @include lib.rounded(10); + @include lib.element-decel; + + padding: lib.s(5) lib.s(10); + background-color: color.change(scheme.$surface1, $alpha: 0.5); + + &:hover, + &:focus { + background-color: color.change(scheme.$surface2, $alpha: 0.5); + } + + &:active { + background-color: color.change(scheme.$overlay0, $alpha: 0.5); + } + } + } + } + } +} diff --git a/src/modules/sidebar/dashboard.tsx b/src/modules/sidebar/dashboard.tsx new file mode 100644 index 0000000..b7d03d0 --- /dev/null +++ b/src/modules/sidebar/dashboard.tsx @@ -0,0 +1,123 @@ +import Players from "@/services/players"; +import { osIcon, osId } from "@/utils/system"; +import Slider from "@/widgets/slider"; +import { bind, GLib, monitorFile, Variable } from "astal"; +import { Gtk } from "astal/gtk3"; +import AstalMpris from "gi://AstalMpris"; +import Notifications from "./modules/notifications"; + +const lengthStr = (length: number) => + `${Math.floor(length / 60)}:${Math.floor(length % 60) + .toString() + .padStart(2, "0")}`; + +const FaceFallback = () => ( +