Skip to content

Commit

Permalink
Minor: Ran leptosfmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfrances107 committed Oct 21, 2024
1 parent 1437750 commit 262fd82
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 147 deletions.
74 changes: 37 additions & 37 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,57 @@ pub fn App() -> impl IntoView {
provide_context(sidebar_signal);

view! {
<Html lang="en"/>
<Meta name="description" content="Search images metadata."/>
<Meta name="viewport" content="width=device-width, initial-scale=1"/>
<Meta name="theme-color" content="#319197"/>
<Link rel="icon" type_="image/svg+xml" href="/mag.svg"/>
<Link rel="manifest" href="/manifest.json"/>
<Title text="Photo Indexer"/>
<Html lang="en" />
<Meta name="description" content="Search images metadata." />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta name="theme-color" content="#319197" />
<Link rel="icon" type_="image/svg+xml" href="/mag.svg" />
<Link rel="manifest" href="/manifest.json" />
<Title text="Photo Indexer" />

<Stylesheet id="leptos" href="/pkg/pi.css"/>
<Body class="dark:bg-slate-950 dark:text-white font-roboto"/>
<Stylesheet id="leptos" href="/pkg/pi.css" />
<Body class="dark:bg-slate-950 dark:text-white font-roboto" />
<Router>

<Routes>

<Route
path=""
view=|| {
view! {
// TODO work out wrapping for mobile nav is below the header
// for desktop nav is right justified.
<header class="flex gap-8 item-center justify-between m-none px-6 ">
<h1 class="font-light grow" style="font-size: clamp(1rem, 8vw, 4rem);">
"SEARCH"
</h1>
<nav class="self-center" style="font-size: clamp(.75rem, 4vw, 2rem);">
<A href="/about">"ABOUT"</A>
</nav>
<SettingsButton/>
</header>
<Search/>
}
view! {
// TODO work out wrapping for mobile nav is below the header
// for desktop nav is right justified.
<header class="flex gap-8 item-center justify-between m-none px-6 ">
<h1 class="font-light grow" style="font-size: clamp(1rem, 8vw, 4rem);">
"SEARCH"
</h1>
<nav class="self-center" style="font-size: clamp(.75rem, 4vw, 2rem);">
<A href="/about">"ABOUT"</A>
</nav>
<SettingsButton />
</header>
<Search />
}
}
/>

<Route
path="/about"
view=|| {
view! {
// TODO work out wrapping for mobile nav is below the header
// for desktop nav is right justified.
<header class="border-none flex gap-8 item-center justify-between m-none px-6 ">
<h1 class="font-light grow" style="font-size: clamp(1rem, 8vw, 4rem);">
"ABOUT"
</h1>
<nav class="self-center" style="font-size: clamp(.75rem, 4vw, 2rem);">
<A href="/">"SEARCH"</A>
</nav>
<SettingsButton/>
</header>
<About/>
}
view! {
// TODO work out wrapping for mobile nav is below the header
// for desktop nav is right justified.
<header class="border-none flex gap-8 item-center justify-between m-none px-6 ">
<h1 class="font-light grow" style="font-size: clamp(1rem, 8vw, 4rem);">
"ABOUT"
</h1>
<nav class="self-center" style="font-size: clamp(.75rem, 4vw, 2rem);">
<A href="/">"SEARCH"</A>
</nav>
<SettingsButton />
</header>
<About />
}
}
/>

Expand Down
93 changes: 45 additions & 48 deletions src/component/file_lister/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,53 +107,50 @@ pub fn Lister() -> impl IntoView {
};

view! {
<h2 class="mp-2 text-center">"Select a directory to index"</h2>
<p>{move || current_selection.get()}</p>
<ol class="flex flex-wrap gap-2 p-2 " on:click=selection_click>
<Transition fallback=move || {
view! {
<li>
<button on:click=refresh_click>"Refresh"</button>
</li>
}
}>
<For each=move || { list_url.get().into_iter() } key=|(i, _)| { *i } let:data>
<li>
<!-- "css issue - Want to set hover on input element, but conventional css fails" -->
<input
class="cursor-grab dark:bg-neutral-400 dark:focus:bg-neutral-300 dark:hover:bg-neutral-300 p-2 rounded"
name="dir"
readonly
type="text"
value=data.1
/>
</li>
</For>
</Transition>
</ol>

<form
on:submit=on_submit
class="dark:text-slate-700 p-2"
>
<label class="hidden" for="fl">
Search
</label>
<input
class="block"
id="fl"
placeholder="select directory"
node_ref=input_element
value={select_value}
type="text"
/>

<input
class="bg-sky-700 block cursor-grab dark:text-white rounded mt-3 p-2 hover:bg-sky-600"
type="submit"
title="Select"
value="UPDATE"
/>
</form>
<h2 class="mp-2 text-center">"Select a directory to index"</h2>
<p>{move || current_selection.get()}</p>
<ol class="flex flex-wrap gap-2 p-2 " on:click=selection_click>
<Transition fallback=move || {
view! {
<li>
<button on:click=refresh_click>"Refresh"</button>
</li>
}
}>
<For each=move || { list_url.get().into_iter() } key=|(i, _)| { *i } let:data>
<li>
<!-- "css issue - Want to set hover on input element, but conventional css fails" -->
<input
class="cursor-grab dark:bg-neutral-400 dark:focus:bg-neutral-300 dark:hover:bg-neutral-300 p-2 rounded"
name="dir"
readonly
type="text"
value=data.1
/>
</li>
</For>
</Transition>
</ol>

<form on:submit=on_submit class="dark:text-slate-700 p-2">
<label class="hidden" for="fl">
Search
</label>
<input
class="block"
id="fl"
placeholder="select directory"
node_ref=input_element
value=select_value
type="text"
/>

<input
class="bg-sky-700 block cursor-grab dark:text-white rounded mt-3 p-2 hover:bg-sky-600"
type="submit"
title="Select"
value="UPDATE"
/>
</form>
}
}
110 changes: 56 additions & 54 deletions src/component/image_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,46 +73,44 @@ pub fn ImageGallery(entries: Signal<Vec<SRElem>>) -> impl IntoView {
});

view! {
<Transition fallback=|| view! { <p>"SideBar..."</p> } >
<Transition fallback=|| {
view! { <p>"SideBar..."</p> }
}>
// Sidebar
{move || {
metadata
.get()
.map_or_else(
|| view! { <div id="side-menu-empty" class="w-0"></div> },
|data| {
view! {
<div
class="bg-slate-800 inline-block rounded shadow-inner shadow-slate-700"
id="side-menu"
>
<button
class="font-medium pr-4 pt-2 text-right text-lg w-full"
on:click=move |_| metadata_action.dispatch(AddMetaData { url: None })
title="close"
>
"X"
</button>
<hr class="m-1"/>
<div class="
[&>*:nth-child(even)]:bg-gray-400
[&>*:nth-child(even)]:text-black
overflow-hidden
w-[240px]
}}">
<For
each=move || data.clone()
key=|field| { field.ifd_num }
let:field
>
<p class="ps-0.5">{field.tag.to_string()}</p>
<p class="pe-2.5 text-right">{field.display_value().to_string()}</p>
</For>
</div>
</div>
}
},
)
metadata
.get()
.map_or_else(
|| view! { <div id="side-menu-empty" class="w-0"></div> },
|data| {
view! {
<div
class="bg-slate-800 inline-block rounded shadow-inner shadow-slate-700"
id="side-menu"
>
<button
class="font-medium pr-4 pt-2 text-right text-lg w-full"
on:click=move |_| metadata_action.dispatch(AddMetaData { url: None })
title="close"
>
"X"
</button>
<hr class="m-1" />
<div class="
[&>*:nth-child(even)]:bg-gray-400
[&>*:nth-child(even)]:text-black
overflow-hidden
w-[240px]
}}">
<For each=move || data.clone() key=|field| { field.ifd_num } let:field>
<p class="ps-0.5">{field.tag.to_string()}</p>
<p class="pe-2.5 text-right">{field.display_value().to_string()}</p>
</For>
</div>
</div>
}
},
)
}}

</Transition>
Expand All @@ -136,32 +134,36 @@ pub fn ImageGallery(entries: Signal<Vec<SRElem>>) -> impl IntoView {

<div class="hover:bg-slate-600 mx-2 my-4 relative rounded text-left w-[280px]">
<figure class="bg-slate-100 pt-2 rounded-t">
{
let description_escaped = data.description.replace('"', "");
view!{
<img
alt={&description_escaped}
class="aspect-square mx-auto w-[274px] h-[160px]"
src={&data.url}
title={description_escaped}
/>
{
let description_escaped = data.description.replace('"', "");
view! {
<img
alt=&description_escaped
class="aspect-square mx-auto w-[274px] h-[160px]"
src=&data.url
title=description_escaped
/>
}
}
}
<figcaption>
{if data.description.is_empty() {
view! { <p class="break-words line-clamp-3 min-h-12 pt-4">"No description"</p> }
view! { <p class="break-words line-clamp-3 min-h-12 pt-4">"No description"</p> }
} else {
view! { <p class="break-words line-clamp-3 min-h-12 pt-4">{data.description}</p> }
view! {
<p class="break-words line-clamp-3 min-h-12 pt-4">{data.description}</p>
}
}}

</figcaption>
</figure>
<button
class="absolute bg-black/50 font-mono p-3 rounded-full right-4 text-white text-right top-4"
on:click=move |_| metadata_action
.dispatch(AddMetaData {
url: Some(data.url.clone()),
})
on:click=move |_| {
metadata_action
.dispatch(AddMetaData {
url: Some(data.url.clone()),
})
}

title="Open metadata"
>
Expand Down
2 changes: 1 addition & 1 deletion src/component/settings/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn Button() -> impl IntoView {
<button
class="text-white"
on:click=move |_| {
sidebar_state_setter.update(|state| *state = state.toggle());
sidebar_state_setter.update(|state| *state = state.toggle());
}

title="Open settings"
Expand Down
2 changes: 1 addition & 1 deletion src/component/settings/pannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn Pannel() -> impl IntoView {
class="dark:bg-slate-800 p-2 max-w-80 mr-2 rounded shadow-inner shadow-slate-700"
>
<h1 class="mb-2">"Settings Pannel"</h1>
<FileLister/>
<FileLister />
</div>
}
}
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async fn main() -> std::io::Result<()> {
};

// Generate the list of routes in your Leptos App
let routes = generate_route_list(|| view! { <App/> });
let routes = generate_route_list(|| view! { <App /> });

let addr = conf.leptos_options.site_addr;
match HttpServer::new(move || {
Expand All @@ -108,7 +108,7 @@ async fn main() -> std::io::Result<()> {
.leptos_routes(
leptos_options.to_owned(),
routes.to_owned(),
|| view! { <App/> },
|| view! { <App /> },
)
// TODO can I filter by extension rather than expose
// all files from this directory.
Expand Down
2 changes: 1 addition & 1 deletion src/pages/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn About() -> impl IntoView {
<p>"Search a directory for images query exif-meta data"</p>
<p>"Subdirectories are included."</p>
</div>
<SettingsPannel/>
<SettingsPannel />
</div>
}
}
6 changes: 3 additions & 3 deletions src/pages/search/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn Search() -> impl IntoView {
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
>
<path d="m -610.98815,-246.28042 c 68.31986,0 247.34788,0 247.34788,0 0,0 0,185.290321 0,256.0000039 0,70.7096771 0,255.9999961 0,255.9999961 0,0 -179.02802,0 -247.34788,0 -68.31988,0 -247.34788,0 -247.34788,0 0,0 0,-185.290319 0,-255.9999961 0,-70.7096829 0,-256.0000039 0,-256.0000039 0,0 179.028,0 247.34788,0 z M -726.68312,55.138934 h 115.69497 v 73.187106 c 0,11.04518 12.96582,16.61935 20.4461,8.77419 L -476.54262,18.493776 c 4.68766,-4.851603 4.68766,-12.593542 0,-17.4451634 L -590.54205,-117.66106 c -7.58001,-7.84517 -20.4461,-2.27098 -20.4461,8.7742 v 73.187082 h -115.69497 c -6.58265,0 -11.96845,5.574196 -11.96845,12.387102 V 42.75184 c 0,6.812915 5.3858,12.387094 11.96845,12.387094 z"/>
<path d="m -610.98815,-246.28042 c 68.31986,0 247.34788,0 247.34788,0 0,0 0,185.290321 0,256.0000039 0,70.7096771 0,255.9999961 0,255.9999961 0,0 -179.02802,0 -247.34788,0 -68.31988,0 -247.34788,0 -247.34788,0 0,0 0,-185.290319 0,-255.9999961 0,-70.7096829 0,-256.0000039 0,-256.0000039 0,0 179.028,0 247.34788,0 z M -726.68312,55.138934 h 115.69497 v 73.187106 c 0,11.04518 12.96582,16.61935 20.4461,8.77419 L -476.54262,18.493776 c 4.68766,-4.851603 4.68766,-12.593542 0,-17.4451634 L -590.54205,-117.66106 c -7.58001,-7.84517 -20.4461,-2.27098 -20.4461,8.7742 v 73.187082 h -115.69497 c -6.58265,0 -11.96845,5.574196 -11.96845,12.387102 V 42.75184 c 0,6.812915 5.3858,12.387094 11.96845,12.387094 z" />
</svg>
</button>
</form>
Expand All @@ -106,8 +106,8 @@ pub fn Search() -> impl IntoView {
</Transition>

<div class="flex gap-2">
<ImageGallery entries/>
<SettingsPannel/>
<ImageGallery entries />
<SettingsPannel />
</div>

</div>
Expand Down

0 comments on commit 262fd82

Please sign in to comment.