Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] refactoring use new design style #52

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/assets/Icon/Dark/GitHub.svg

This file was deleted.

3 changes: 0 additions & 3 deletions app/assets/Vector.svg

This file was deleted.

Binary file added app/assets/zzhack-logo.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/zzhack-logo.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/components.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod card;
pub mod load_more;
pub mod nav;
pub mod post_item;
Expand Down
1 change: 1 addition & 0 deletions app/src/components/card.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod outline_card;
19 changes: 19 additions & 0 deletions app/src/components/card/outline_card.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use yew::prelude::*;

#[derive(Properties, PartialEq, Clone)]
pub struct LoadMoreProps {
pub children: Html,
#[prop_or_default]
pub class: String,
}

#[function_component]
pub fn OutlineCard(props: &LoadMoreProps) -> Html {
html! {
<div class={format!("rounded-6xl bg-white-600 p-3 dark:bg-gray-600 {}", props.class)}>
<div class="rounded-4xl bg-white dark:bg-white-dark">
{props.children.clone()}
</div>
</div>
}
}
16 changes: 10 additions & 6 deletions app/src/components/post_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ pub fn PostItem(props: &PostItemProps) -> Html {

html! {
<a href={format!("/post/{}", post.id)}>
<div class="my-5">
<div class="text-xl font-bold text-black">
{&post.title}
<div>{tags}</div>
<div class="mt-5">
<div class="flex items-center">
<div class="font-semibold text-lg text-black dark:text-black-dark">{&post.title}</div>
{for tags}
</div>
<div class="text-sm text-black-400 dark:text-gray-900 mt-1.5 mb-2">
{&post.spoiler}
</div>
<div class="text-xs text-gray-500 dark:text-gray-450">
{&post.created_at}
</div>
<div class="text-black-700 text-sm mt-0.5 mb-1">{&post.spoiler}</div>
<div class="text-xs text-black-500">{&post.created_at}</div>
</div>
</a>
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ pub struct TagProps {
#[function_component]
pub fn Tag(props: &TagProps) -> Html {
html! {
<span class="pixel-badge mr-2 px-2 py-0.5 text-xs text-black-500 text-white bg-black">{props.children.clone()}</span>
<div class="text-xs px-2 rounded flex justify-center items-center">{props.children.clone()}</div>
}
}
1 change: 0 additions & 1 deletion app/src/pages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod dynamic;
pub mod home;
pub mod links;
pub mod not_found;
pub mod post;
Expand Down
30 changes: 0 additions & 30 deletions app/src/pages/home.rs

This file was deleted.

15 changes: 9 additions & 6 deletions app/src/pages/posts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::rc::Rc;

use crate::components::card::outline_card::OutlineCard;
use crate::components::{load_more::LoadMore, post_item::PostItem};
use crate::http::HTTP;
use shared::post::{PaginationPostsRes, Post};
Expand Down Expand Up @@ -67,12 +68,14 @@ pub fn Content() -> HtmlResult {
});

Ok(html! {
<div class="mt-12">
{for rendered_posts}
if *has_load_more {
<LoadMore onload={handle_load_more_click} />
}
</div>
<OutlineCard class="mt-8">
<div class="pb-7 pt-1 px-6 grid gap-5 divide-y md:divide-solid divide-gray-200 dark:divide-gray-100">
{for rendered_posts}
if *has_load_more {
<LoadMore onload={handle_load_more_click} />
}
</div>
</OutlineCard>
})
}

Expand Down
58 changes: 26 additions & 32 deletions app/src/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,35 @@ pub struct BrowserAppProps {
pub config: Config,
}

#[function_component]
pub fn App() -> Html {
let cb = Callback::from(|_| {
let document = web_sys::window()
.unwrap()
.document()
.unwrap()
.document_element()
.unwrap();

document.set_class_name("dark");
});

html! {
<main class="p-4 h-full w-full flex justify-center bg-white-200 dark:bg-black-900">
<div class="h-full w-[655px]">
<Nav />
<Switch<Routes> render={switch} />
</div>
<button onclick={cb}>{"Dark"}</button>
</main>
}
}

#[function_component]
pub fn BrowserApp() -> Html {
html! {
<BrowserRouter>
<main class="p-4 h-full w-full flex justify-center">
<div class="h-full w-[768px]">
<Nav />
<Switch<Routes> render={switch} />
</div>
</main>
<footer class="footer">
<div class="content has-text-centered">
{ "Powered by " }
<a href="https://yew.rs">{ "Yew" }</a>
{ " using " }
<a href="https://bulma.io">{ "Bulma" }</a>
{ " and images from " }
<a href="https://unsplash.com">{ "Unsplash" }</a>
</div>
</footer>
<App />
</BrowserRouter>
}
}
Expand All @@ -54,22 +63,7 @@ pub fn ServerApp(props: &ServerAppProps) -> Html {

html! {
<Router history={history}>
<main class="p-4 h-full w-full flex justify-center">
<div class="h-full w-[768px]">
<Nav />
<Switch<Routes> render={switch} />
</div>
</main>
<footer class="footer">
<div class="content has-text-centered">
{ "Powered by " }
<a href="https://yew.rs">{ "Yew" }</a>
{ " using " }
<a href="https://bulma.io">{ "Bulma" }</a>
{ " and images from " }
<a href="https://unsplash.com">{ "Unsplash" }</a>
</div>
</footer>
<App />
</Router>
}
}
6 changes: 2 additions & 4 deletions app/src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use yew::prelude::*;
use yew_router::prelude::*;

use crate::pages::{
dynamic::Dynamic, home::Home, links::Links, not_found::NotFound, post::Post, posts::Posts,
};
use crate::pages::{dynamic::Dynamic, links::Links, not_found::NotFound, post::Post, posts::Posts};

#[derive(Routable, PartialEq, Eq, Clone, Debug)]
pub enum Routes {
Expand All @@ -28,7 +26,7 @@ pub fn switch(routes: Routes) -> Html {
Routes::Posts => {
html! {<Posts />}
}
Routes::Home => html! {<Home />},
Routes::Home => html! {<Redirect<Routes> to={Routes::Posts} />},
Routes::NotFound => html! {<NotFound />},
Routes::Links => html! {<Links />},
Routes::Dynamic { path } => html! {<Dynamic path={path} />},
Expand Down
2 changes: 1 addition & 1 deletion entry/styles/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@layer base {
body,
html {
min-height: 100%;
height: 100%;
}
}

Expand Down
Loading