~vpzom/hitide

aaa2e14d4f0eaebe5896edfcd4212f8b464f9924 — Colin Reeder 1 year, 2 months ago d4949e7
Rearrange community page layout
3 files changed, 62 insertions(+), 33 deletions(-)

M res/main.css
M src/resp_types.rs
M src/routes/communities.rs
M res/main.css => res/main.css +15 -0
@@ 36,3 36,18 @@ body {
	margin-top: .5em;
	margin-bottom: .5em;
}

.communitySidebar {
	float: right;
	width: 300px;
}

.communitySidebar > h2 {
	margin-bottom: 0;
}

@media (max-width: 768px) {
	.communitySidebar {
		display: none; /* TODO still show this somewhere */
	}
}

M src/resp_types.rs => src/resp_types.rs +4 -0
@@ 83,6 83,10 @@ pub struct RespYourFollow {
pub struct RespCommunityInfoMaybeYour<'a> {
    #[serde(flatten)]
    pub base: RespMinimalCommunityInfo<'a>,

    pub description: Cow<'a, str>,

    pub you_are_moderator: Option<bool>,
    pub your_follow: Option<RespYourFollow>,
}


M src/routes/communities.rs => src/routes/communities.rs +43 -33
@@ 142,42 142,52 @@ async fn page_community(

    Ok(html_response(render::html! {
        <HTPage base_data={&base_data} title>
            <h1 style={"margin-bottom: 0"}>{title}</h1>
            <em>{format!("@{}@{}", community_info.as_ref().name, community_info.as_ref().host)}</em>
            <p>
                {
                    if base_data.login.is_some() {
                        Some(match community_info.your_follow {
                            Some(RespYourFollow { accepted: true }) => {
                                render::rsx! {
                                    <form method={"POST"} action={format!("/communities/{}/unfollow", community_id)}>
                                        <button type={"submit"}>{"Unfollow"}</button>
                                    </form>
                                }
                            },
                            Some(RespYourFollow { accepted: false }) => {
                                render::rsx! {
                                    <form>
                                        <button disabled={""}>{"Follow request sent!"}</button>
                                    </form>
                                }
                            },
                            None => {
                                render::rsx! {
                                    <form method={"POST"} action={format!("/communities/{}/follow", community_id)}>
                                        <button type={"submit"}>{"Follow"}</button>
                                    </form>
            <div class={"communitySidebar"}>
                <h2>{title}</h2>
                <em>{format!("@{}@{}", community_info.as_ref().name, community_info.as_ref().host)}</em>
                <p>
                    {
                        if base_data.login.is_some() {
                            Some(match community_info.your_follow {
                                Some(RespYourFollow { accepted: true }) => {
                                    render::rsx! {
                                        <form method={"POST"} action={format!("/communities/{}/unfollow", community_id)}>
                                            <button type={"submit"}>{"Unfollow"}</button>
                                        </form>
                                    }
                                },
                                Some(RespYourFollow { accepted: false }) => {
                                    render::rsx! {
                                        <form>
                                            <button disabled={""}>{"Follow request sent!"}</button>
                                        </form>
                                    }
                                },
                                None => {
                                    render::rsx! {
                                        <form method={"POST"} action={format!("/communities/{}/follow", community_id)}>
                                            <button type={"submit"}>{"Follow"}</button>
                                        </form>
                                    }
                                }
                            }
                        })
                    } else {
                        None
                            })
                        } else {
                            None
                        }
                    }
                </p>
                <p>
                    <a href={&new_post_url}>{"New Post"}</a>
                </p>
                <p>{community_info.description.as_ref()}</p>
            </div>
            {
                if posts.is_empty() {
                    Some(render::rsx! { <p>{"Looks like there's nothing here."}</p> })
                } else {
                    None
                }
            </p>
            <p>
                <a href={&new_post_url}>{"New Post"}</a>
            </p>
            }
            <ul>
                {posts.iter().map(|post| {
                    PostItem { post, in_community: true }