tauri-plugin-decor 1.0.1

Opinionated window decoration controls for Tauri apps.
Documentation
use crate::config;

pub(crate) fn build_scripts(height: u32) -> String {
    let height_px = format!("\"{}px\"", height);
    let width_px = format!("\"{}px\"", config::button_width());
    let close_hover = config::close_hover_bg();
    let button_hover = config::button_hover_bg();

    let titlebar = include_str!("js/titlebar.js").replace("\"32px\"", &height_px);
    let bundle = format!(
        "{}\n{}",
        include_str!("js/controls.js"),
        include_str!("js/windows.js")
    )
    .replace("\"32px\"", &height_px)
    .replace("\"46px\"", &width_px)
    .replace(config::DEFAULT_CLOSE_HOVER_BG, &close_hover)
    .replace(config::DEFAULT_BUTTON_HOVER_BG, &button_hover);

    format!("{titlebar}\n;(() => {{\n{bundle}\n}})();")
}

pub(crate) fn handle_page_load<R: tauri::Runtime>(win: &tauri::Webview<R>) {
    if !crate::overlay::contains(win.label()) && !config::auto_titlebar() {
        return;
    }
    let _ = win.eval(&build_scripts(config::titlebar_height()));
}

pub(crate) use crate::html::apply_runtime_style;