-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: begin implementation of cassette page
- Loading branch information
Showing
10 changed files
with
161 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use patternfly_yew::prelude::*; | ||
use uuid::Uuid; | ||
use yew::prelude::*; | ||
|
||
#[derive(Clone, Debug, PartialEq, Properties)] | ||
pub struct Props { | ||
pub id: Uuid, | ||
} | ||
|
||
#[function_component(Cassette)] | ||
pub fn cassette(props: &Props) -> Html { | ||
match () { | ||
() => html! { <CassetteFallback /> }, | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Properties)] | ||
struct FallbackProps { | ||
#[prop_or_default] | ||
pub error: Option<String>, | ||
} | ||
|
||
#[function_component(CassetteFallback)] | ||
fn cassette_fallback(props: &FallbackProps) -> Html { | ||
let title = "A Cassette"; | ||
let subtitle = "Loading..."; | ||
|
||
let error = match props.error.as_deref() { | ||
Some(error) => html! { | ||
<Alert inline=true title="Error" r#type={AlertType::Danger}> | ||
{ error } | ||
</Alert> | ||
}, | ||
None => html! {}, | ||
}; | ||
|
||
html! { | ||
<super::PageBody {title} {subtitle} > | ||
{ error } | ||
</super::PageBody> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
use cassette_core::{cassette::CassetteRef, net::fetch::FetchState}; | ||
use inflector::Inflector; | ||
use patternfly_yew::prelude::*; | ||
use yew::prelude::*; | ||
|
||
use crate::hooks::gateway::use_cassette_list; | ||
|
||
#[function_component(Home)] | ||
pub fn home() -> Html { | ||
let title = "Cassette"; | ||
let title = env!("CARGO_PKG_NAME").to_title_case(); | ||
let subtitle = env!("CARGO_PKG_DESCRIPTION"); | ||
|
||
let cassette_list = match &*use_cassette_list() { | ||
FetchState::Pending | FetchState::Fetching => html! { <p>{ "Loading..." }</p> }, | ||
FetchState::Completed(list) => render_cassette_list(list), | ||
FetchState::Error(error) => html! { <p>{ format!("Error: {error}") }</p> }, | ||
}; | ||
|
||
html! { | ||
<super::PageBody {title} {subtitle} > | ||
<div class="home"> | ||
<img class="logo" src="/assets/images/icons/logo.webp" alt="Cassette logo" style=" | ||
width: 5vw; | ||
height: 5vw; | ||
"/> | ||
{ cassette_list } | ||
</div> | ||
<Content> | ||
</Content> | ||
</super::PageBody> | ||
} | ||
} | ||
|
||
fn render_cassette_list(list: &[CassetteRef]) -> Html { | ||
html! { <p>{ format!("{list:?}") }</p> } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters