This commit is contained in:
JMARyA 2025-01-26 10:52:02 +01:00
parent 5ae9b80302
commit 8daef6920c
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
9 changed files with 158 additions and 135 deletions

View file

@ -1,4 +1,5 @@
use based::request::{RequestContext, StringResponse};
use based::ui::components::Shell;
use based::ui::prelude::*;
use maud::{PreEscaped, Render, html};
use rocket::{State, get};
@ -8,14 +9,13 @@ use pacco::pkg::{Repository, arch::Architecture};
use crate::config::Config;
use crate::routes::ui::arch_card;
use super::render;
#[get("/<repo>?<arch>")]
pub async fn repo_ui(
repo: &str,
ctx: RequestContext,
arch: Option<&str>,
config: &State<Config>,
shell: &State<Shell>,
) -> StringResponse {
let arch = arch.map(|x| Architecture::parse(x).unwrap_or(Architecture::any));
@ -35,7 +35,6 @@ pub async fn repo_ui(
.push(Text(&repo.name)._3xl().bold().color(&Gray::_100))
.push_if(config.is_mirrored_repo(&repo.name), || {
Background(
Blue::_500,
Rounded(Margin(
Padding(Text("Mirrored").sm().medium().white())
.x(ScreenValue::_3)
@ -43,6 +42,7 @@ pub async fn repo_ui(
))
.size(Size::Full),
)
.color(Blue::_500)
})
.push(
Screen::medium(Margin(Nothing()).top(ScreenValue::_0)).on(Margin(
@ -81,8 +81,7 @@ pub async fn repo_ui(
Animated(
Flex(
Padding(
Hover(Background(Gray::_600, Nothing())).on(Background(
Gray::_700,
Hover(Background(Nothing()).color(Gray::_600)).on(Background(
Rounded(Shadow::medium(
Link(
&format!("/{}/{pkg}", repo.name),
@ -103,7 +102,8 @@ pub async fn repo_ui(
.use_htmx(),
))
.size(Size::Large),
)),
)
.color(Gray::_700)),
)
.all(ScreenValue::_4),
)
@ -115,7 +115,7 @@ pub async fn repo_ui(
let content = Div().vanish().push(repo_info).push(package_list).render();
render(content, &repo.name, ctx).await
shell.render_page(content, &repo.name, ctx).await
}
#[allow(non_snake_case)]
@ -123,23 +123,25 @@ pub fn FirstLetterCircle(name: &str) -> PreEscaped<String> {
Sized(
ScreenValue::_10,
ScreenValue::_10,
Rounded(Background(
Blue::_500,
Flex(
Text(
&name
.chars()
.next()
.unwrap_or_default()
.to_uppercase()
.to_string(),
Rounded(
Background(
Flex(
Text(
&name
.chars()
.next()
.unwrap_or_default()
.to_uppercase()
.to_string(),
)
.white()
.semibold(),
)
.white()
.semibold(),
.full_center()
.group(),
)
.full_center()
.group(),
))
.color(Blue::_500),
)
.size(Size::Full),
)
.render()