From 711531fa94aad6b87bcd33717f7973290b538670 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Sat, 23 Mar 2024 12:50:23 -0500 Subject: [PATCH] toolbar layout --- Cargo.toml | 2 +- .../miner_toolbar/miner_toolbar_active.rs | 30 +++++++++++-------- src/components/miner_toolbar/mod.rs | 2 +- src/components/stop_button.rs | 2 +- src/hooks/use_transfers_websocket.rs | 1 - src/utils.rs | 8 +++-- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6ea6e099..9cdd8c67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ readme = "./README.md" keywords = ["solana", "crypto", "mining"] [features] -default = [] +default = ["web"] bundle = [] desktop = [ "async-tungstenite", diff --git a/src/components/miner_toolbar/miner_toolbar_active.rs b/src/components/miner_toolbar/miner_toolbar_active.rs index cf5b070b..09826f08 100644 --- a/src/components/miner_toolbar/miner_toolbar_active.rs +++ b/src/components/miner_toolbar/miner_toolbar_active.rs @@ -79,7 +79,7 @@ pub fn MinerToolbarActive(cx: Scope) -> Element { _ => None } p { - class: "font-mono text-sm truncate opacity-80", + class: "font-mono text-sm truncate shrink opacity-80", "{miner_display_hash}" } } @@ -91,19 +91,22 @@ pub fn MinerToolbarActive(cx: Scope) -> Element { } else { render! { div { - class: "flex flex-row w-full justify-between my-auto px-4 sm:px-8", + class: "flex flex-row gap-2 max-w-screen w-screen justify-start my-auto px-4 sm:px-8 object-contain", div { - class: "flex flex-row gap-2 my-auto", + class: "flex-shrink-0 flex-none my-auto", ActivityIndicator {} - p { - class: "font-semibold text-white", - "Mining" - } + } + p { + class: "font-semibold text-white flex-shrink-0 flex-none my-auto", + "Mining" + } + div { + class: "flex-shrink flex-auto truncate my-auto", match miner_status_message { MinerStatusMessage::Searching => { render! { p { - class: "font-mono text-sm truncate opacity-80 my-auto ml-2", + class: "font-mono text-sm truncate flex-shrink flex-auto opacity-80 my-auto ml-2", "{miner_display_hash}" } } @@ -111,7 +114,7 @@ pub fn MinerToolbarActive(cx: Scope) -> Element { MinerStatusMessage::Submitting => { render! { p { - class: "text-sm text-white opacity-80 my-auto ml-2", + class: "truncate flex-shrink flex-auto text-sm text-white opacity-80 my-auto ml-2", "Submitting hash for validation..." } } @@ -119,7 +122,7 @@ pub fn MinerToolbarActive(cx: Scope) -> Element { MinerStatusMessage::Error => { render! { p { - class: "text-sm text-white opacity-80 my-auto ml-2", + class: "truncate flex-shrink flex-auto text-sm text-white opacity-80 my-auto ml-2", "Error submitting transaction" } } @@ -127,8 +130,11 @@ pub fn MinerToolbarActive(cx: Scope) -> Element { _ => None } } - StopButton { - miner: cx.props.miner.clone() + div { + class: "flex-shrink-0 flex-none ml-auto my-auto", + StopButton { + miner: cx.props.miner.clone() + } } } } diff --git a/src/components/miner_toolbar/mod.rs b/src/components/miner_toolbar/mod.rs index c769cfeb..648f1d35 100644 --- a/src/components/miner_toolbar/mod.rs +++ b/src/components/miner_toolbar/mod.rs @@ -149,7 +149,7 @@ pub fn MinerToolbar(cx: Scope, hidden: bool) -> Element { render! { div { - class: "{class} {height} {bg} {display}", + class: "{class} {height} {bg} {display} w-screen", onclick: move |_e| { *is_toolbar_open.write() = IsToolbarOpen(true); }, diff --git a/src/components/stop_button.rs b/src/components/stop_button.rs index 2ec0d8f3..13e2094c 100644 --- a/src/components/stop_button.rs +++ b/src/components/stop_button.rs @@ -12,7 +12,7 @@ pub fn StopButton(cx: Scope, miner: UseState) -> Element { let is_toolbar_open = use_shared_state::(cx).unwrap(); render! { button { - class: "transition transition-colors flex w-10 h-10 justify-center rounded-full hover:bg-green-600 active:bg-green-700", + class: "transition transition-colors flex-shrink-0 flex w-10 h-10 justify-center rounded-full hover:bg-green-600 active:bg-green-700", title: "Stop mining", onclick: move |_e| { track(AppEvent::StopMiner, None); diff --git a/src/hooks/use_transfers_websocket.rs b/src/hooks/use_transfers_websocket.rs index 641cd7a6..9fc58bd7 100644 --- a/src/hooks/use_transfers_websocket.rs +++ b/src/hooks/use_transfers_websocket.rs @@ -16,7 +16,6 @@ use crate::{components::ActivityFilter, gateway::AsyncResult}; use super::use_pubkey; -// const URL: &str = "ws://54.86.50.170:3001/ws"; const URL: &str = "wss://ore-websockets.onrender.com/ws"; // TODO Attempt reconnect if connection is lost diff --git a/src/utils.rs b/src/utils.rs index 86e4845e..39edae1a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,9 +1,13 @@ #[cfg(feature = "desktop")] pub fn asset_path(relative_path: &str) -> String { - format!("public/{}", relative_path) + if cfg!(feature = "bundle") { + format!("public/{}", relative_path) + } else { + relative_path.to_string() + } } -#[cfg(not(feature = "desktop"))] +#[cfg(feature = "web")] pub fn asset_path(relative_path: &str) -> String { relative_path.to_string() }