glassy: first transparent theme

This commit is contained in:
Abdenasser 2024-11-10 23:04:28 +01:00
parent e8c22ba953
commit 60793b9834
5 changed files with 62 additions and 35 deletions

View File

@ -11,7 +11,7 @@ tauri-build = { version = "2", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "2", features = [] } tauri = { version = "2", features = ["macos-private-api"] }
sysinfo = "0.29.0" sysinfo = "0.29.0"
tauri-plugin-shell = "2" tauri-plugin-shell = "2"
window-vibrancy = "0.5.2" window-vibrancy = "0.5.2"

View File

@ -9,9 +9,7 @@ use sysinfo::{
}; };
use tauri::{Manager, State}; use tauri::{Manager, State};
use window_vibrancy::apply_vibrancy; use window_vibrancy::{apply_acrylic, apply_vibrancy, NSVisualEffectMaterial, NSVisualEffectState};
#[cfg(target_os = "windows")]
use window_vibrancy::{apply_acrylic, apply_blur, NSVisualEffectMaterial, NSVisualEffectState};
struct AppState { struct AppState {
sys: Mutex<System>, sys: Mutex<System>,
@ -299,21 +297,28 @@ async fn kill_process(pid: u32, state: State<'_, AppState>) -> Result<bool, Stri
} }
} }
#[cfg(target_os = "windows")]
fn setup_window_effects(window: &tauri::WebviewWindow) -> Result<(), Box<dyn std::error::Error>> {
apply_acrylic(window, Some((0, 0, 25, 125)))?;
Ok(())
}
#[cfg(not(target_os = "windows"))]
fn setup_window_effects(window: &tauri::WebviewWindow) -> Result<(), Box<dyn std::error::Error>> {
apply_vibrancy(
window,
NSVisualEffectMaterial::HudWindow,
Some(NSVisualEffectState::Active),
None,
)?;
Ok(())
}
fn main() { fn main() {
tauri::Builder::default() tauri::Builder::default()
.setup(|app| { .setup(|app| {
let window = app.get_webview_window("main").unwrap(); let window = app.get_webview_window("main").unwrap();
setup_window_effects(&window).expect("Failed to apply window effects");
#[cfg(target_os = "windows")]
{
// You can choose either blur or acrylic effect
apply_acrylic(&window, Some((0, 0, 25, 125))).expect("Failed to apply blur effect");
// Or use acrylic effect (Windows 10/11)
// apply_acrylic(&window, Some((18, 18, 18, 125)))
// .expect("Failed to apply acrylic effect");
}
Ok(()) Ok(())
}) })
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())

View File

@ -32,9 +32,11 @@
"identifier": "com.neohtop.dev", "identifier": "com.neohtop.dev",
"plugins": {}, "plugins": {},
"app": { "app": {
"macOSPrivateApi": true,
"windows": [ "windows": [
{ {
"fullscreen": false, "fullscreen": false,
"theme":"Dark",
"height": 900, "height": 900,
"resizable": true, "resizable": true,
"title": "NeoHtop", "title": "NeoHtop",

View File

@ -65,42 +65,58 @@ body {
background: var(--mantle); background: var(--mantle);
} }
/* Glassy theme */
[data-theme="glassy"] body { [data-theme="glassy"] body {
background: transparent !important; background: transparent !important;
} }
[data-theme="glassy"] .title-bar {
position: relative;
background: rgba(24, 24, 37, 0.5) !important;
z-index: 10;
}
[data-theme="glassy"] .toolbar { [data-theme="glassy"] .toolbar {
position: relative; position: relative;
background: rgba(24, 24, 37, 0.5) !important; background: rgba(24, 24, 37, 0.5) !important;
border: 1px solid rgba(255, 255, 255, 0.1) !important;
z-index: 9; z-index: 9;
} }
[data-theme="glassy"] .process-table { [data-theme="glassy"] .stat-panel {
position: relative; background: rgba(24, 24, 37, 0.2) !important;
background: rgba(24, 24, 37, 0.5) !important; z-index: 100;
z-index: 8;
} }
[data-theme="glassy"] .stat-panel { [data-theme="glassy"] .panel-header {
background: rgba(24, 24, 37, 0.5) !important; border-color: rgba(255, 255, 255, 0.1) !important;
}
[data-theme="glassy"] .col-actions {
background: rgba(24, 24, 37, 0.2) !important;
border-bottom: 1px solid rgba(232, 232, 232, 0.1) !important;
border-left: 1px solid rgba(232, 232, 232, 0.1) !important;
}
[data-theme="glassy"] .search-input,
[data-theme="glassy"] .btn-toggle,
[data-theme="glassy"] .btn-action,
[data-theme="glassy"] .info-button,
[data-theme="glassy"] .btn-page,
[data-theme="glassy"] .theme-button,
[data-theme="glassy"] .usage-pill,
[data-theme="glassy"] .bar-container,
[data-theme="glassy"] .select-input {
background: rgba(24, 24, 37, 0.2) !important;
z-index: 100; z-index: 100;
} }
[data-theme="glassy"] tr.pinned,
[data-theme="glassy"] tr:hover {
background: rgba(24, 24, 37, 0.3) !important;
}
[data-theme="glassy"] th { [data-theme="glassy"] th {
background: rgba(24, 24, 37, 0.5) !important; background: rgba(24, 24, 37, 0.5) !important;
} }
[data-theme="glassy"] .col-actions { [data-theme="glassy"] td {
border-bottom: 1px solid rgba(232, 232, 232, 0.1) !important;
background: rgba(24, 24, 37, 0.2) !important; background: rgba(24, 24, 37, 0.2) !important;
} }
[data-theme="glassy"] .process-table tr:hover td {
background: rgba(24, 24, 37, 0.55) !important;
}

View File

@ -13,7 +13,7 @@
const themeGroups = [ const themeGroups = [
{ {
label: "Dark", label: "Dark",
themes: ["catppuccin", "dracula", "monokaiPro", "tokyoNight", "glassy"], themes: ["catppuccin", "dracula", "monokaiPro", "tokyoNight"],
}, },
{ {
label: "Light", label: "Light",
@ -45,6 +45,10 @@
label: "Accessibility", label: "Accessibility",
themes: ["highContrast"], themes: ["highContrast"],
}, },
{
label: "Glassy",
themes: ["glassy"],
},
]; ];
</script> </script>