Skip to content

Commit

Permalink
leptosfmt files
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBiscardi committed Feb 27, 2024
1 parent 931c541 commit 8753851
Show file tree
Hide file tree
Showing 8 changed files with 499 additions and 333 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ fn Wrapper(children: Children) -> impl IntoView {
</div>
</div>
</footer>
<div class="fixed inset-x-0 bottom-0 z-10 lg:left-112 xl:left-120">// <AudioPlayer />
</div>
// <AudioPlayer />
<div class="fixed inset-x-0 bottom-0 z-10 lg:left-112 xl:left-120"></div>
</div>
}
}
Expand Down
69 changes: 45 additions & 24 deletions src/app/routes/admin/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ pub fn Image() -> impl IntoView {
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
<ActionForm class="isolate -space-y-px rounded-md shadow-sm" action=add_image>
<div class="relative rounded-md px-3 pb-1.5 pt-2.5 ring-1 ring-inset ring-gray-300 focus-within:z-10 focus-within:ring-2 focus-within:ring-indigo-600">
<label for="cloudinary_public_id" class="block text-xs font-medium text-gray-900">
<label
for="cloudinary_public_id"
class="block text-xs font-medium text-gray-900"
>
cloudinary_public_id
</label>
<input
Expand Down Expand Up @@ -90,24 +93,36 @@ fn Images() -> impl IntoView {
let images = create_resource(move || {}, |_| fetch_images());

view! {
<Suspense fallback=move || view! { <p>"Loading (Suspense Fallback)..."</p> }>
{images.get().map(|data| match data {
Err(e) => view!{ <div>{e.to_string()}</div> }.into_view(),
Ok(images) => {
view! {
<ul role="list" class="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8">
<For
each=move || images.clone()
key=|image| image.id.clone()
let:image
>
<ImageLi id=image.id url=image.url description=image.description/>
</For>
</ul>
}.into_view()
}
})
}
<Suspense fallback=move || {
view! { <p>"Loading (Suspense Fallback)..."</p> }
}>
{images
.get()
.map(|data| match data {
Err(e) => view! { <div>{e.to_string()}</div> }.into_view(),
Ok(images) => {
view! {
<ul
role="list"
class="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8"
>
<For
each=move || images.clone()
key=|image| image.id.clone()
let:image
>
<ImageLi
id=image.id
url=image.url
description=image.description
/>
</For>
</ul>
}
.into_view()
}
})}

</Suspense>
}
}
Expand All @@ -117,12 +132,18 @@ fn ImageLi(id: String, url: String, description: String) -> impl IntoView {
view! {
<li class="relative">
<div class="group aspect-h-7 aspect-w-10 block w-full overflow-hidden rounded-lg bg-gray-100 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100">
<img src=url alt="" class="pointer-events-none object-cover group-hover:opacity-75"/>
<button type="button" class="absolute inset-0 focus:outline-none">
<span class="sr-only">View details</span>
</button>
<img
src=url
alt=""
class="pointer-events-none object-cover group-hover:opacity-75"
/>
<button type="button" class="absolute inset-0 focus:outline-none">
<span class="sr-only">View details</span>
</button>
</div>
<p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">{id}</p>
<p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">
{id}
</p>
<p class="pointer-events-none block text-sm font-medium text-gray-500">{description}</p>
</li>
}
Expand Down
113 changes: 68 additions & 45 deletions src/app/routes/admin/issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub fn Issue() -> impl IntoView {
}}

</Suspense>
<Divider title="Showcases" />
<Showcases />
<Divider title="Showcases"/>
<Showcases/>
</div>
}
}
Expand Down Expand Up @@ -295,20 +295,30 @@ fn Showcases() -> impl IntoView {
);

view! {
<ul role="list" class="divide-y divide-gray-100 overflow-hidden bg-white shadow-sm ring-1 ring-gray-900/5 sm:rounded-xl">
<Suspense fallback=move || {
view! { <p>"Loading (Suspense Fallback)..."</p> }
}>
{move || {
showcases.read().map(|data| match data {
Err(e) => view! { <pre>{e.to_string()}</pre> }.into_view(),
Ok(showcases) => showcases
.iter()
.map(|showcase| view! { <ShowcaseLi showcase=showcase.clone()/> })
.collect_view()
})
}}
</Suspense>
<ul
role="list"
class="divide-y divide-gray-100 overflow-hidden bg-white shadow-sm ring-1 ring-gray-900/5 sm:rounded-xl"
>
<Suspense fallback=move || {
view! { <p>"Loading (Suspense Fallback)..."</p> }
}>
{move || {
showcases
.read()
.map(|data| match data {
Err(e) => view! { <pre>{e.to_string()}</pre> }.into_view(),
Ok(showcases) => {
showcases
.iter()
.map(|showcase| {
view! { <ShowcaseLi showcase=showcase.clone()/> }
})
.collect_view()
}
})
}}

</Suspense>
</ul>
}
}
Expand All @@ -317,35 +327,48 @@ fn Showcases() -> impl IntoView {
fn ShowcaseLi(showcase: ShowcaseData) -> impl IntoView {
view! {
<li class="relative flex justify-between gap-x-6 px-4 py-5 hover:bg-gray-50 sm:px-6">
<div class="flex min-w-0 gap-x-4">
<div class="min-w-0 flex-auto">
<p class="text-sm font-semibold leading-6 text-gray-900">
<a href=format!("/admin/showcase/{}",showcase.id)>
<span class="absolute inset-x-0 -top-px bottom-0"></span>
{showcase.title}
</a>
</p>
{showcase.posted_date.map(|posted_date| view! {
<p class="mt-1 flex text-xs leading-5 text-gray-500">
<span>"posted at"</span>
<time
datetime={posted_date.to_string()}
class="ml-1"
>{posted_date.to_string()}</time>
</p>
})}
</div>
</div>
<div class="flex shrink-0 items-center gap-x-4">
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">{showcase.image_count} images</p>
// <p class="mt-1 text-xs leading-5 text-gray-500">Last seen <time datetime="2023-01-23T13:23Z">3h ago</time></p>
</div>
<svg class="h-5 w-5 flex-none text-gray-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
</svg>
</div>
</li>
<div class="flex min-w-0 gap-x-4">
<div class="min-w-0 flex-auto">
<p class="text-sm font-semibold leading-6 text-gray-900">
<a href=format!("/admin/showcase/{}", showcase.id)>
<span class="absolute inset-x-0 -top-px bottom-0"></span>
{showcase.title}
</a>
</p>
{showcase
.posted_date
.map(|posted_date| {
view! {
<p class="mt-1 flex text-xs leading-5 text-gray-500">
<span>"posted at"</span>
<time datetime=posted_date.to_string() class="ml-1">
{posted_date.to_string()}
</time>
</p>
}
})}

</div>
</div>
<div class="flex shrink-0 items-center gap-x-4">
<div class="hidden sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">{showcase.image_count} images</p>
// <p class="mt-1 text-xs leading-5 text-gray-500">Last seen <time datetime="2023-01-23T13:23Z">3h ago</time></p>
</div>
<svg
class="h-5 w-5 flex-none text-gray-400"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fill-rule="evenodd"
d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
clip-rule="evenodd"
></path>
</svg>
</div>
</li>
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/routes/admin/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub fn Issues() -> impl IntoView {
>
{&issue.display_name}
</a>
<p class="flex-none text-xs text-gray-600">// <time datetime={&issue.issue_date}>{&issue.issue_date}</time>
</p>
// <time datetime={&issue.issue_date}>{&issue.issue_date}</time>
<p class="flex-none text-xs text-gray-600"></p>
</div>
<p class="mt-1 line-clamp-2 text-sm leading-6 text-gray-600">
"trimmed description without markdown render"
Expand Down
116 changes: 76 additions & 40 deletions src/app/routes/admin/showcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,47 @@ pub fn Showcase() -> impl IntoView {
</button>
</ActionForm>
<Divider title="Showcases without an issue"/>
<Suspense fallback=move || view! { <p>"Loading (Suspense Fallback)..."</p> }>
{showcases.get().map(|data| match data {
(Err(e), Err(e2)) => view!{ <div><div>{e.to_string()}</div><div>{e2.to_string()}</div></div> },
(_, Err(e)) | (Err(e), _) => view!{ <div><div>{e.to_string()}</div></div> },
(Ok(showcases), Ok(issues)) => {
view! {
<div>
<ul role="list" class="divide-y divide-gray-100">
<For
each=move || showcases.clone()
key=|showcase| showcase.id.clone()
let:showcase
>
<AddShowcaseToIssueForm showcase=showcase issue_id=issues.first().map(|issue| issue.id.clone())/>
</For>
</ul>
<Suspense fallback=move || {
view! { <p>"Loading (Suspense Fallback)..."</p> }
}>
{showcases
.get()
.map(|data| match data {
(Err(e), Err(e2)) => {
view! {
<div>
<div>{e.to_string()}</div>
<div>{e2.to_string()}</div>
</div>
}
}
}
)}
(_, Err(e)) | (Err(e), _) => {
view! {
<div>
<div>{e.to_string()}</div>
</div>
}
}
(Ok(showcases), Ok(issues)) => {
view! {
<div>
<ul role="list" class="divide-y divide-gray-100">
<For
each=move || showcases.clone()
key=|showcase| showcase.id.clone()
let:showcase
>
<AddShowcaseToIssueForm
showcase=showcase
issue_id=issues.first().map(|issue| issue.id.clone())
/>
</For>
</ul>
</div>
}
}
})}

</Suspense>
</div>
}
Expand All @@ -151,28 +171,44 @@ fn AddShowcaseToIssueForm(showcase: ShowcaseData, issue_id: Option<String>) -> i

view! {
<li class="flex items-center justify-between gap-x-6 py-5">
<div class="min-w-0">
<div class="flex items-start gap-x-3">
<p class="text-sm font-semibold leading-6 text-gray-900">{showcase.title}</p>
</div>
<div class="mt-1 flex items-center gap-x-2 text-xs leading-5 text-gray-500">
<p class="whitespace-nowrap">posted on <time datetime=showcase.posted_date.as_ref().unwrap().to_string()>{showcase.posted_date.as_ref().unwrap().to_string()}</time></p>
<svg viewBox="0 0 2 2" class="h-0.5 w-0.5 fill-current">
<circle cx="1" cy="1" r="1" />
</svg>
// <p class="truncate">Submitted by {showcase.submitted_by}</p>
</div>
</div>
{issue_id.map(|issue_id| view!{
<div class="flex flex-none items-center gap-x-4">
<ActionForm action=associate_showcase_with_issue>
<input type="hidden" value=showcase.id name="showcase_id"/>
<input type="hidden" value=issue_id name="issue_id"/>
<button type="submit" class="hidden rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:block">Add to current draft</button>
</ActionForm>
</div>
})}
</li>
<div class="min-w-0">
<div class="flex items-start gap-x-3">
<p class="text-sm font-semibold leading-6 text-gray-900">{showcase.title}</p>
</div>
<div class="mt-1 flex items-center gap-x-2 text-xs leading-5 text-gray-500">
<p class="whitespace-nowrap">
posted on
<time datetime=showcase
.posted_date
.as_ref()
.unwrap()
.to_string()>{showcase.posted_date.as_ref().unwrap().to_string()}</time>
</p>
<svg viewBox="0 0 2 2" class="h-0.5 w-0.5 fill-current">
<circle cx="1" cy="1" r="1"></circle>
</svg>
// <p class="truncate">Submitted by {showcase.submitted_by}</p>
</div>
</div>
{issue_id
.map(|issue_id| {
view! {
<div class="flex flex-none items-center gap-x-4">
<ActionForm action=associate_showcase_with_issue>
<input type="hidden" value=showcase.id name="showcase_id"/>
<input type="hidden" value=issue_id name="issue_id"/>
<button
type="submit"
class="hidden rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:block"
>
Add to current draft
</button>
</ActionForm>
</div>
}
})}

</li>
}
}

Expand Down
Loading

0 comments on commit 8753851

Please sign in to comment.