1
0
Fork 0

formatting

Zynh Ludwig 2024-08-28 18:55:29 -07:00
parent 391f9cfa01
commit 31bfd4d126
5 changed files with 61 additions and 18 deletions

1
.rustfmt.toml Normal file
View File

@ -0,0 +1 @@
edition = "2021"

2
leptosfmt.toml Normal file
View File

@ -0,0 +1,2 @@
[attr_values]
class = "Tailwind" # "Tailwind" is the only attribute value formatter available for now

2
rust-analyzer.toml Normal file
View File

@ -0,0 +1,2 @@
[rustfmt]
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]

View File

@ -137,9 +137,7 @@ async fn remaining(
async fn welcome() -> impl IntoResponse {
let cat_fact = views::get_cat_fact().await;
Html(ssr::render(move || {
leptos::view! {
<Welcome fact=cat_fact />
}
leptos::view! { <Welcome fact=cat_fact /> }
}))
}
@ -157,15 +155,23 @@ async fn records_links(State(state): State<AppState>) -> impl IntoResponse {
<div class="form-wrapper">
<div class="column-container">
<ul>
{records.keys().map(|key| leptos::view! {
{records
.keys()
.map(|key| {
leptos::view! {
<li class="link-wrapper">
<a href="/link/{key}">{key}</a>
<button style="margin-left: 1em;"
<button
style="margin-left: 1em;"
hx-target="closest .link-wrapper"
hx-swap="outerHTML"
hx-delete="/link/{key}">X</button>
hx-delete="/link/{key}"
>
X
</button>
</li>
})
}
})
.collect::<Vec<_>>()}
</ul>
</div>
@ -190,7 +196,7 @@ async fn link(
return Ok(Html(ssr::render({
let record = record.clone();
|| {
leptos::view! { <DownloadLinkPage id=id record=record /> }
leptos::view! { <DownloadLinkPage id=id record=record /> }
}
})));
}

View File

@ -33,11 +33,26 @@ pub fn Welcome(fact: String) -> impl IntoView {
#[component]
pub fn WelcomeView(fact: String) -> impl IntoView {
view! {
<form id="form" hx-swap="outerHTML" hx-post="/upload" hx-encoding="multipart/form-data" class="column-container">
<form
id="form"
hx-swap="outerHTML"
hx-post="/upload"
hx-encoding="multipart/form-data"
class="column-container"
>
<div class="cat-img-wrapper">
<img class="cat-img" src="https://api.thecatapi.com/v1/images/search?size=small&format=src" />
<img
class="cat-img"
src="https://api.thecatapi.com/v1/images/search?size=small&format=src"
/>
</div>
<input type="file" id="file" name="file" data-multiple-caption="{{count}} files selected" multiple />
<input
type="file"
id="file"
name="file"
data-multiple-caption="{{count}} files selected"
multiple
/>
<label for="file">Select Files</label>
<input type="submit" value="Get Link~" />
@ -72,7 +87,11 @@ pub fn HtmxPage(children: Children) -> impl IntoView {
<link href="/css/link.css" rel="stylesheet" />
<script src="/scripts/file_label.js" />
<script src="/scripts/link.js" />
<script src="https://unpkg.com/htmx.org@1.9.4" integrity="sha384-zUfuhFKKZCbHTY6aRR46gxiqszMk5tcHjsVFxnUo8VMus4kHGVdIYVbOYYNlKmHV" crossorigin="anonymous"></script>
<script
src="https://unpkg.com/htmx.org@1.9.4"
integrity="sha384-zUfuhFKKZCbHTY6aRR46gxiqszMk5tcHjsVFxnUo8VMus4kHGVdIYVbOYYNlKmHV"
crossorigin="anonymous"
></script>
</head>
<body>
@ -89,16 +108,29 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView {
view! {
<div class="column-container">
<div class="link-wrapper">
<a id="link" href="/download/{id}">Download Now!</a>
<a id="link" href="/download/{id}">
Download Now!
</a>
</div>
<div class="link-wrapper" hx-get="/link/{id}/remaining" hx-trigger="click from:#link delay:0.2s, every 10s" >
You have {record.downloads_remaining()} download{plural} remaining!
<div
class="link-wrapper"
hx-get="/link/{id}/remaining"
hx-trigger="click from:#link delay:0.2s, every 10s"
>
You have
{record.downloads_remaining()}
download
{plural}
remaining!
</div>
<button class="return-button" onclick="clipboard()">Copy to Clipboard</button>
<button class="return-button" onclick="clipboard()">
Copy to Clipboard
</button>
<a href="/" class="return-button">Return to home</a>
<a href="/" class="return-button">
Return to home
</a>
</div>
}
}