feat: eww design tokens

This commit is contained in:
hesam-init 2024-07-01 18:33:10 +03:30
parent 4a088d2f91
commit 49bd527e28
9 changed files with 82 additions and 51 deletions

View file

@ -3,8 +3,6 @@
}
.reveal-on-click {
@include font("medium");
color: $surface2;
padding: 4px 0px;
}

View file

@ -1,34 +1,20 @@
@mixin font($size: "default") {
$sizes: (
"small": 16px,
"medium": 18px,
"large": 20px,
);
@if map-has-key($sizes, $size) {
font-size: map-get($sizes, $size);
} @else {
font-size: map-get($sizes, "large");
}
}
@import "tokens";
@mixin widget() {
padding: 0.6em 0.4em;
margin: 4px 2px;
border-radius: 8px;
padding: get-token(padding, small);
margin: get-token(margin);
border-radius: get-token(border-radius);
background-color: $surface0;
}
@mixin icon() {
@include font("medium");
font-size: get-token(font-sizes);
font-family: "Symbols Nerd Font";
}
@mixin popup() {
background-color: $base;
padding: 8px;
border-radius: 12px;
border-style: solid;
margin: 10px;
padding: get-token(padding, small);
border-radius: get-token(border-radius);
margin: get-token(margin);
background-color: $surface1;
}

View file

@ -1,17 +1,9 @@
.clock {
@include widget;
label {
@include font;
}
}
.language {
@include widget;
label {
@include font("small");
}
}
.logo {

View file

@ -0,0 +1,46 @@
$design-tokens: (
font-sizes: (
small: 16px,
default: 18px,
large: 20px,
),
padding: (
small: 8px,
default: 10px,
large: 12px,
),
margin: (
small: 2px,
default: 4px,
large: 6px,
),
border-radius: (
small: 6px,
default: 8px,
large: 12px,
),
);
@function get-token($category, $key: null) {
$tokens: map-get($design-tokens, $category);
@if $tokens == null {
@error "Category `#{$category}` not found in design tokens.";
}
@if $key == null {
@if map-has-key($tokens, default) {
$key: default;
} @else {
@error "Default key not found in category `#{$category}`.";
}
}
$value: map-get($tokens, $key);
@if $value == null {
@error "Token `#{$key}` not found in category `#{$category}`.";
}
@return $value;
}

View file

@ -9,7 +9,7 @@
:transition "slideleft"
(children :nth 1))))
(defwidget RevealOnHover [var varname ?class ?duration ?transition ?icon]
(defwidget RevealOnHover [var varname ?icon ?class ?duration ?transition]
(eventbox
:onhover `${EWW_CMD} update ${varname}=true`
:onhoverlost `${EWW_CMD} update ${varname}=false`
@ -22,7 +22,7 @@
(revealer
:reveal var
:transition {transition ?:"slidedown"}
:duration "500ms"
:duration animation-duration-default
(box :class "reveal-on-hover" (children :nth 0))))
))
@ -35,7 +35,7 @@
(revealer
:reveal var
:transition "slideup"
:duration "500ms"
:duration animation-duration-fast
(box (children :nth 0)))
(eventbox

View file

@ -4,7 +4,7 @@
(box
:class "widget"
:orientation "v"
:spacing defaultSpacing
:spacing spacing-default
(eventbox
:onclick "${EWW_CMD} open MusicPlayerPopup --toggle"

View file

@ -9,20 +9,20 @@
:class "workspaces"
:space-evenly false
:orientation "v"
:spacing largeSpacing
:spacing spacing-default
(for workspace in {workspacesJson}
(button
:onclick "hyprctl dispatch workspace ${workspace.id}"
(box
:height 25
:height 20
:class "workspace ${workspace.id == currentWorkspace ? "workspacethingactive" : "workspacething"}"
(revealer
:reveal { workspace.id == currentWorkspace}
:transition "slideup"
:duration 500
:transition "slidedown"
:duration animation-duration-default
(box
:height 40))))))))

View file

@ -1,9 +1,14 @@
; Global Styles
(defvar animationDuration "500ms")
(defvar defaultSpacing 8)
(defvar largeSpacing 6)
(defvar mediumSpacing 4)
(defvar smallSpacing 2)
(defvar animation-duration-default "600ms")
(defvar animation-duration-slow "1000ms")
(defvar animation-duration-fast "400ms")
(defvar animation-duration-very-fast "200ms")
(defvar spacing-default 8)
(defvar spacing-large 16)
(defvar spacing-medium 8)
(defvar spacing-small 4)
(defvar spacing-tiny 2)
; Global
(deflisten kbLayout :initial "en" "./scripts/kb-layout/get-active")

View file

@ -7,6 +7,8 @@
(revealer
:transition "slideleft"
:reveal revealControlpanel
:duration animation-duration-default
(ControlPanel))
(centerbox
@ -26,7 +28,7 @@
(Logo)
(Workspaces)
(hiddenctl)
;; (Shortcuts)
))
(defwidget Middle []
@ -34,7 +36,7 @@
:orientation "v"
:space-evenly false
:valign "center"
:height 240
:height 200
(PlayerCtl)
))
@ -90,14 +92,16 @@
:text "󱐋"))
(label :text "${EWW_BATTERY.BAT0.capacity}%" :limit-width 3 :show-truncated false)))
(defwidget hiddenctl []
(defwidget Shortcuts []
(RevealOnClick
:var reveal3
:varname "reveal3"
(box
:class "touch"
:orientation "v"
:spacing 5
:spacing spacing-default
(button :onclick "swaymsg kill"
(label :class "icon" :text "󰅙"))
(button :onclick "wofi --show=drun -i -I"
@ -111,7 +115,7 @@
:class "widget"
:orientation "v"
:space-evenly false
:spacing defaultSpacing
:spacing spacing-default
:valign "end"
(button :onclick "alacritty -e nmtui" :tooltip wifi_essid