fix: appearance

This commit is contained in:
Artemy Egorov 2024-07-29 11:38:18 +03:00
parent 1ddef2c247
commit e844525abf
6 changed files with 61 additions and 16 deletions

View file

@ -14,10 +14,10 @@ async fn process_input(input: String) -> Result<Vec<Tag>, VigiError> {
match reqwest::get(input).await { match reqwest::get(input).await {
Ok(res) => match res.text().await { Ok(res) => match res.text().await {
Ok(res) => Ok(vec![dalet::Tag::new(0, Body::Text(res), Argument::Null)]), Ok(res) => Ok(vec![Tag::new(0, Body::Text(res), Argument::Null)]),
Err(err) => Err(VigiError::ParseError(err.to_string())), Err(_) => Err(VigiError::ParseError),
}, },
Err(err) => Err(VigiError::NetworkError(err.to_string())), Err(_) => Err(VigiError::NetworkError),
} }
} }

View file

@ -2,6 +2,6 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub enum VigiError { pub enum VigiError {
NetworkError(String), NetworkError,
ParseError(String), ParseError,
} }

View file

@ -20,6 +20,12 @@ body {
.common-window { .common-window {
@apply p-3 gap-3 w-screen h-screen; @apply p-3 gap-3 w-screen h-screen;
@apply flex; @apply flex;
@apply ease-out duration-100;
}
.common-window.collapsed {
@apply gap-0;
} }
.main-window { .main-window {
@ -64,10 +70,8 @@ body {
} }
.search-input { .search-input {
@apply ms-2 px-2 py-1 rounded-lg grow; @apply ms-2 px-2 py-1 rounded-xl grow;
}
input {
@apply bg-block outline-none; @apply bg-block outline-none;
@apply focus:bg-blockLight focus:text-light; @apply focus:bg-blockLight focus:text-light;
@ -81,3 +85,25 @@ input::placeholder {
::selection { ::selection {
@apply bg-block; @apply bg-block;
} }
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
background: transparent;
}
/* Handle */
::-webkit-scrollbar-thumb {
@apply rounded-xl bg-main bg-clip-content;
border: 6px solid transparent;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
@apply bg-dark;
border: 5px solid transparent;
}

View file

@ -8,10 +8,8 @@
</script> </script>
<Block className="browser-window"> <Block className="browser-window">
{#if isLoading && data.length === 0} {#if isLoading}
<div>Loading...</div> <div>Loading...</div>
{:else if !isLoading && data.length === 0}
<div>No data</div>
{:else} {:else}
<Renderer {data} /> <Renderer {data} />
{/if} {/if}

View file

@ -14,6 +14,8 @@
export let sidebarOpen = true; export let sidebarOpen = true;
export let inputValue = ""; export let inputValue = "";
let currentInputValue = "";
let input: HTMLInputElement; let input: HTMLInputElement;
</script> </script>
@ -35,9 +37,20 @@
type="text" type="text"
placeholder="Search or enter URL" placeholder="Search or enter URL"
class="search-input" class="search-input"
bind:value={inputValue} bind:value={currentInputValue}
bind:this={input} bind:this={input}
on:keypress={(e) => e.key === "Enter" && onInput()} on:keypress={(e) => {
on:focus={() => setTimeout(() => input.select(), 1)} if (e.key === "Enter") {
inputValue = currentInputValue;
onInput();
}
}}
on:focus={() => {
currentInputValue = inputValue;
setTimeout(() => input.select(), 1);
}}
on:focusout={() => {
currentInputValue = decodeURIComponent(inputValue);
}}
/> />
</div> </div>

View file

@ -9,7 +9,9 @@
import { invoke } from "@tauri-apps/api/tauri"; import { invoke } from "@tauri-apps/api/tauri";
let sidebarOpen = true; let sidebarOpen = true;
let inputValue = ""; let inputValue = "";
let isLoading = false;
let data: Root = []; let data: Root = [];
@ -22,21 +24,27 @@
}); });
function processInput() { function processInput() {
isLoading = true;
invoke("process_input", { input: inputValue }) invoke("process_input", { input: inputValue })
.then((res) => { .then((res) => {
data = res as Root; data = res as Root;
isLoading = false;
}) })
.catch((err) => { .catch((err) => {
data = [{ id: 0, body: "Error: " + err, argument: null }]; data = [{ id: 0, body: "Error: " + err, argument: null }];
isLoading = false;
}); });
} }
</script> </script>
<div class="common-window" data-tauri-drag-region> <div
class={`common-window${sidebarOpen ? "" : " collapsed"}`}
data-tauri-drag-region
>
<Sidebar bind:sidebarOpen /> <Sidebar bind:sidebarOpen />
<div class="main-window"> <div class="main-window">
<TopBar bind:sidebarOpen bind:inputValue onInput={processInput} /> <TopBar bind:sidebarOpen bind:inputValue onInput={processInput} />
<BrowserWindow {data} /> <BrowserWindow {data} bind:isLoading />
</div> </div>
</div> </div>