Skip to content

Commit

Permalink
Adds 👑 to our patreons
Browse files Browse the repository at this point in the history
  • Loading branch information
klautcomputing committed May 18, 2024
1 parent 3caadf6 commit d34fa90
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
pkg
apis/target/
todos
site/

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
13 changes: 11 additions & 2 deletions apis/src/components/atoms/profile_link.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::components::molecules::hover_ratings::HoverRating;
use crate::responses::UserResponse;
use leptos::*;
use leptos_icons::*;

#[component]
pub fn ProfileLink(
#[prop(optional)] extend_tw_classes: &'static str,
#[prop(optional)] user_is_hoverable: Option<StoredValue<UserResponse>>,
username: String,
patreon: bool,
) -> impl IntoView {
let profile_link = format!("/@/{}", username);
let hover_show = RwSignal::new(false);
let patreon = RwSignal::new(patreon);
view! {
<div class="relative w-full">
<a
Expand All @@ -23,8 +26,14 @@ pub fn ProfileLink(
on:mouseleave=move |_| hover_show.set(false)
href=profile_link
>
<div class=extend_tw_classes>{username}</div>

<div class=format!(
"flex {}",
extend_tw_classes,
)>
{username} <Show when=patreon>
<Icon icon=icondata::LuCrown class="w-2 h-2"/>
</Show>
</div>
</a>
<Show when=hover_show>
<HoverRating user=user_is_hoverable.expect("Showing because it's some")/>
Expand Down
3 changes: 3 additions & 0 deletions apis/src/components/molecules/challenge_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub fn ChallengeRow(challenge: StoredValue<ChallengeResponse>, single: bool) ->
<StatusIndicator username=opponent.username.to_owned()/>
<ProfileLink
username=opponent.username
patreon=opponent.patreon
extend_tw_classes="truncate max-w-[25px] xs:max-w-[75px] sm:max-w-[150px]"
/>
</div>
Expand All @@ -90,6 +91,7 @@ pub fn ChallengeRow(challenge: StoredValue<ChallengeResponse>, single: bool) ->
<StatusIndicator username=challenge().challenger.username/>
<ProfileLink
username=challenge().challenger.username
patreon=challenge().challenger.patreon
extend_tw_classes="truncate max-w-[25px] xs:max-w-[75px] sm:max-w-[150px]"
/>
</div>
Expand All @@ -101,6 +103,7 @@ pub fn ChallengeRow(challenge: StoredValue<ChallengeResponse>, single: bool) ->
<StatusIndicator username=challenge().challenger.username/>
<ProfileLink
username=challenge().challenger.username
patreon=challenge().challenger.patreon
extend_tw_classes="truncate max-w-[25px] xs:max-w-[75px] sm:max-w-[150px]"
/>
</div>
Expand Down
10 changes: 8 additions & 2 deletions apis/src/components/molecules/game_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ pub fn GameRow(game: StoredValue<GameResponse>) -> impl IntoView {
<div class="mr-2">
<div class="flex items-center">
<StatusIndicator username=game().white_player.username/>
<ProfileLink username=game().white_player.username/>
<ProfileLink
patreon=game().white_player.patreon
username=game().white_player.username
/>
</div>
<br/>
<Show when=is_finished fallback=move || { game().white_rating() }>
Expand All @@ -120,7 +123,10 @@ pub fn GameRow(game: StoredValue<GameResponse>) -> impl IntoView {
<div class="ml-2">
<div class="flex items-center">
<StatusIndicator username=game().black_player.username/>
<ProfileLink username=game().black_player.username/>
<ProfileLink
username=game().black_player.username
patreon=game().white_player.patreon
/>
</div>
<br/>
<Show when=is_finished fallback=move || { game().black_rating() }>
Expand Down
9 changes: 8 additions & 1 deletion apis/src/components/molecules/user_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ pub fn UserRow(
};
let profile_link = move || {
if on_profile {
view! { <ProfileLink username=user().username extend_tw_classes="truncate max-w-[120px]"/> }
view! {
<ProfileLink
patreon=user().patreon
username=user().username
extend_tw_classes="truncate max-w-[120px]"
/>
}
} else {
view! {
<ProfileLink
patreon=user().patreon
username=user().username
extend_tw_classes="truncate max-w-[120px]"
user_is_hoverable=user
Expand Down
7 changes: 6 additions & 1 deletion apis/src/components/molecules/user_with_rating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn UserWithRating(
})
};
let username = move || player().map_or(String::new(), |p| p.username);
let patreon = move || player().map_or(false, |p| p.patreon);
// TODO: Display proper rating for game use <Rating/>
let rating = move || match (player(), speed()) {
(Some(player), Some(speed)) => {
Expand All @@ -59,7 +60,11 @@ pub fn UserWithRating(
view! {
<div class="flex items-center">
<StatusIndicator username=username()/>
<ProfileLink username=username() extend_tw_classes=text_color/>
<ProfileLink
patreon=patreon()
username=username()
extend_tw_classes=text_color
/>
</div>
}
}}
Expand Down
2 changes: 1 addition & 1 deletion apis/src/pages/donate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn Donate() -> impl IntoView {
Are some features reserved for Patrons?
</h3>
<p class="mt-2 text-base">
"No, because hivegame is entirely free, forever, and for everyone. That's a promise."
"No, because hivegame is entirely free, forever, and for everyone. That's a promise. You do get a 👑 though."
</p>
</div>

Expand Down
4 changes: 4 additions & 0 deletions apis/src/pages/faq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ pub fn Faq() -> impl IntoView {
"It's developed by communtity members, and 100% donation based. hivegame.com will never collect any user data, show ads or implement anything else that will distract you from the game or makes money."
</p>
</div>
<div class=div_class>
<h3 class=header_class>"How do I get a 👑 next to my username?"</h3>
<p class=paragraph_class>"By donating to the project!"</p>
</div>
<div class=div_class>
<h3 class=header_class>"What is Hive?"</h3>
<p class=paragraph_class>
Expand Down
2 changes: 1 addition & 1 deletion apis/src/pages/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn Resources() -> impl IntoView {
</li>
<li>
<a
href="https://www.instagram.com/hiveworldcommunity/"
href="https://www.instagram.com/world_hive_community/"
rel="external"
target="_blank"
class=link_class
Expand Down
3 changes: 3 additions & 0 deletions apis/src/responses/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use uuid::Uuid;
pub struct UserResponse {
pub username: String,
pub uid: Uuid,
pub patreon: bool,
pub ratings: HashMap<GameSpeed, RatingResponse>,
}

Expand All @@ -15,6 +16,7 @@ impl UserResponse {
Self {
username: uuid.to_string(),
uid: uuid,
patreon: false,
ratings: HashMap::new(),
}
}
Expand Down Expand Up @@ -103,6 +105,7 @@ impl UserResponse {
Ok(Self {
username: user.username.clone(),
uid: user.id,
patreon: user.patreon,
ratings,
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table users drop column patreon;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table users add column patreon bool not null default false;
3 changes: 3 additions & 0 deletions db/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub struct NewUser {
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub normalized_username: String,
pub patreon: bool,
}

impl NewUser {
Expand All @@ -105,6 +106,7 @@ impl NewUser {
created_at: Utc::now(),
updated_at: Utc::now(),
normalized_username: username.to_lowercase(),
patreon: false,
})
}
}
Expand All @@ -119,6 +121,7 @@ pub struct User {
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub normalized_username: String,
pub patreon: bool,
}

impl User {
Expand Down
1 change: 1 addition & 0 deletions db/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ diesel::table! {
created_at -> Timestamptz,
updated_at -> Timestamptz,
normalized_username -> Text,
patreon -> Bool,
}
}

Expand Down

0 comments on commit d34fa90

Please sign in to comment.