Skip to content

Commit 2e7ad2f

Browse files
committed
feat: implement faucet page improvements
- Add FaucetDescription component for improved faucet information display - Add label for network selection dropdown to improve accessibility - Update footer titles and button/text styles for better color contrast - Improve layout and spacing for balance components - Update placeholder text in FaucetInput for clarity - Run linter and fix formatting issues
1 parent 7ad21c3 commit 2e7ad2f

File tree

9 files changed

+71
-31
lines changed

9 files changed

+71
-31
lines changed

src/faucet/views/components/balance.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::utils::format::format_balance;
77
#[component]
88
pub fn FaucetBalance(faucet: RwSignal<FaucetController>) -> impl IntoView {
99
view! {
10-
<div>
11-
<h3 class="title">Faucet Balance:</h3>
10+
<div class="balance-content">
11+
<strong class="title">Faucet Balance:</strong>
1212
<Transition fallback=move || {
1313
view! { <p>Loading faucet balance...</p> }
1414
}>
@@ -38,8 +38,8 @@ pub fn FaucetBalance(faucet: RwSignal<FaucetController>) -> impl IntoView {
3838
#[component]
3939
pub fn TargetBalance(faucet: RwSignal<FaucetController>) -> impl IntoView {
4040
view! {
41-
<div>
42-
<h3 class="title">Target Balance:</h3>
41+
<div class="balance-content">
42+
<strong class="title">Target Balance:</strong>
4343
<Transition fallback=move || view! { <p>Loading target balance...</p> }>
4444
<p class="balance">
4545
{move || format_balance(&faucet.get().get_target_balance(), &faucet.get().get_fil_unit())}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::utils::format::format_balance;
2+
use fvm_shared::econ::TokenAmount;
3+
use leptos::prelude::*;
4+
use leptos::{component, view, IntoView};
5+
6+
#[component]
7+
pub fn FaucetDescription(
8+
drip_amount: TokenAmount,
9+
token_unit: String,
10+
rate_limit_seconds: i64,
11+
) -> impl IntoView {
12+
view! {
13+
<div class="description">
14+
<p>
15+
"This faucet distributes " {format_balance(&drip_amount, &token_unit)}
16+
" per request and is rate-limited to one request per " {rate_limit_seconds}
17+
" seconds per address. Each wallet address is subject to a daily cap, and exceeding this limit may result in temporary restrictions."
18+
</p>
19+
<p>
20+
"Farming, abuse, or automated requests are strictly prohibited and will lead to stricter rate limits, temporary suspensions, or permanent bans."
21+
</p>
22+
<p>
23+
"Faucet funds are limited and may run out. Refills are not guaranteed and occur periodically based on availability."
24+
</p>
25+
</div>
26+
}
27+
}

src/faucet/views/components/layout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn Footer() -> impl IntoView {
1919
<footer class="footer">
2020
<div class="footer-content">
2121
<div class="footer-section">
22-
<h3 class="footer-title">Learn More</h3>
22+
<strong class="footer-title">Learn More</strong>
2323
<ul class="footer-links">
2424
<li>
2525
<a
@@ -36,7 +36,7 @@ pub fn Footer() -> impl IntoView {
3636
</div>
3737

3838
<div class="footer-section">
39-
<h3 class="footer-title">Feedback & Support</h3>
39+
<strong class="footer-title">Feedback & Support</strong>
4040
<ul class="footer-links">
4141
<li>
4242
<a
@@ -75,7 +75,7 @@ pub fn Footer() -> impl IntoView {
7575
<div class="footer-bottom">
7676
<span>
7777
<a
78-
class="text-green-600"
78+
class="text-green-700"
7979
target="_blank"
8080
rel="noopener noreferrer"
8181
href="https://github.com/ChainSafe/forest-explorer"

src/faucet/views/components/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod alert;
22
pub mod balance;
3+
pub mod faucet_description;
34
pub mod icons;
45
pub mod layout;
56
pub mod nav;

src/faucet/views/faucets/calibnet.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::Faucet;
22
use crate::faucet::constants::FaucetInfo;
3-
use crate::utils::format::format_balance;
3+
use crate::faucet::views::components::faucet_description::FaucetDescription;
44
use crate::utils::rpc_context::{Provider, RpcContext};
55
use leptos::prelude::*;
66
use leptos::{component, view, IntoView};
@@ -24,11 +24,11 @@ pub fn Faucet_Calibnet() -> impl IntoView {
2424
<h1 class="header">"🧪 Filecoin Calibnet Faucet"</h1>
2525
<div class="main-container">
2626
<Faucet faucet_info=FaucetInfo::CalibnetFIL />
27-
<div class="description">
28-
"This faucet distributes " {format_balance(drip_amount, token_unit)}
29-
" per request. It is rate-limited to 1 request per " {rate_limit_seconds}
30-
" seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans."
31-
</div>
27+
<FaucetDescription
28+
drip_amount=drip_amount.clone()
29+
token_unit=token_unit.to_string()
30+
rate_limit_seconds=rate_limit_seconds
31+
/>
3232
</div>
3333
}
3434
}

src/faucet/views/faucets/mainnet.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::Faucet;
22
use crate::faucet::constants::FaucetInfo;
3-
use crate::utils::format::format_balance;
3+
use crate::faucet::views::components::faucet_description::FaucetDescription;
44
use crate::utils::rpc_context::{Provider, RpcContext};
55
use leptos::prelude::*;
66
use leptos::{component, view, IntoView};
@@ -22,11 +22,11 @@ pub fn Faucet_Mainnet() -> impl IntoView {
2222
<h1 class="header">"🌐 Filecoin Mainnet Faucet"</h1>
2323
<div class="main-container">
2424
<Faucet faucet_info=FaucetInfo::MainnetFIL />
25-
<div class="description">
26-
"This faucet distributes " {format_balance(drip_amount, token_unit)}
27-
" per request. It is rate-limited to 1 request per " {rate_limit_seconds}
28-
" seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans or service termination. Faucet funds are limited and may run out. They are replenished periodically."
29-
</div>
25+
<FaucetDescription
26+
drip_amount=drip_amount.clone()
27+
token_unit=token_unit.to_string()
28+
rate_limit_seconds=rate_limit_seconds
29+
/>
3030
</div>
3131
}
3232
}

src/faucet/views/faucets/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn Faucet(faucet_info: FaucetInfo) -> impl IntoView {
131131
().into_any()
132132
}
133133
}}
134-
<div>
134+
<div class="faucet-section">
135135
<FaucetInput faucet=faucet />
136136
<div class="balance-container">
137137
<FaucetBalance faucet=faucet />

src/faucet/views/home.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::utils::rpc_context::{Provider, RpcContext};
55
use fvm_shared::address::Network;
66
use leptos::prelude::*;
77
use leptos::{component, leptos_dom::helpers::event_target_value, view, IntoView};
8+
use leptos_meta::Title;
89

910
#[component]
1011
fn FaucetOverview() -> impl IntoView {
@@ -76,7 +77,11 @@ fn NetworkSelection(
7677
view! {
7778
<div class="network-selector">
7879
<div class="dropdown">
80+
<label for="network-select" class="sr-only">
81+
Select Network
82+
</label>
7983
<select
84+
id="network-select"
8085
on:change=move |ev| {
8186
rpc_context.set(event_target_value(&ev).parse().expect("predefined values, must succeed"))
8287
}
@@ -130,6 +135,7 @@ pub fn Explorer() -> impl IntoView {
130135

131136
view! {
132137
<main class="main-container">
138+
<Title text="Filecoin Forest Explorer Faucet" />
133139
<Header />
134140
<FaucetOverview />
135141
<NetworkSelection rpc_context=rpc_context network_name=network_name network_version=network_version />

style/tailwind.css

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
.faucet-list-items {
1919
@apply grid grid-cols-1 gap-6 text-center;
2020
}
21+
.faucet-section {
22+
@apply flex flex-col gap-8;
23+
}
2124
.input-container {
22-
@apply my-4 flex;
25+
@apply flex;
2326
}
2427
.balance-container {
25-
@apply flex justify-between my-4;
28+
@apply flex justify-between;
29+
}
30+
.balance-content {
31+
@apply flex flex-col gap-4 justify-between;
2632
}
2733
.transaction-container {
2834
@apply mt-4 space-y-2;
@@ -67,10 +73,10 @@
6773
@apply text-gray-600;
6874
}
6975
.link-text {
70-
@apply text-blue-500 hover:text-blue-600;
76+
@apply text-blue-700 hover:text-blue-700;
7177
}
7278
.description {
73-
@apply text-center mt-4;
79+
@apply text-center text-pretty space-y-4 max-w-2xl mx-auto;
7480
}
7581
.balance {
7682
@apply text-xl;
@@ -82,7 +88,7 @@
8288
@apply text-4xl font-extrabold leading-none tracking-tight text-gray-900 md:text-5xl lg:text-6xl text-center;
8389
}
8490
.footer {
85-
@apply grid gap-8 text-center pt-6 border-t border-gray-200 max-h-80;
91+
@apply grid gap-10 text-center pt-6 border-t border-gray-200 max-h-80;
8692
}
8793
.footer-content {
8894
@apply grid grid-cols-1 md:grid-cols-2 gap-6 w-4/5 mx-auto;
@@ -97,22 +103,22 @@
97103
@apply space-y-4;
98104
}
99105
.footer-links:hover {
100-
@apply text-blue-600;
106+
@apply text-blue-700;
101107
}
102108
.footer-bottom {
103109
@apply flex justify-center items-center;
104110
}
105111
.btn {
106-
@apply block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg;
112+
@apply block bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded;
107113
}
108114
.btn-enabled {
109-
@apply bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded-r;
115+
@apply bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-r;
110116
}
111117
.btn-disabled {
112-
@apply bg-gray-400 text-white font-bold py-2 px-4 rounded-r;
118+
@apply bg-gray-500 text-white font-bold py-2 px-4 rounded-r;
113119
}
114120
.btn-topup {
115-
@apply block bg-orange-500 hover:bg-orange-600 text-white font-bold text-sm py-1 px-2 rounded;
121+
@apply block bg-orange-800 hover:bg-orange-900 text-white font-bold py-2 px-4 rounded cursor-pointer;
116122
}
117123
.dropdown {
118124
@apply relative w-64;
@@ -127,7 +133,7 @@
127133
@apply h-5 w-5 text-green-500 mr-2 flex-shrink-0;
128134
}
129135
.lighting-icon {
130-
@apply h-5 w-5 text-blue-500 mr-2 flex-shrink-0;
136+
@apply h-5 w-5 text-blue-700 mr-2 flex-shrink-0;
131137
}
132138
.close-icon {
133139
@apply fill-current h-6 w-6 text-red-500;

0 commit comments

Comments
 (0)