-
Notifications
You must be signed in to change notification settings - Fork 0
feat: white-label branding support #18
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a5426ae
feat: add white-label branding support
pthmas 83f68e9
fix: add branding fields to AppState constructors in test helpers
pthmas d8c6c8d
fix: address CodeRabbit review comments and CI failure
pthmas ac3e2ad
fix: cache branding config in localStorage to prevent flash on load
pthmas a8c57b5
feat: add neutral loading screen while branding config is fetched
pthmas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| use axum::{extract::State, Json}; | ||
| use serde::Serialize; | ||
| use std::sync::Arc; | ||
|
|
||
| use crate::api::AppState; | ||
|
|
||
| #[derive(Serialize)] | ||
| pub struct BrandingConfig { | ||
| pub chain_name: String, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub logo_url: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub accent_color: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub background_color_dark: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub background_color_light: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub success_color: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub error_color: Option<String>, | ||
| } | ||
|
|
||
| /// GET /api/config - Returns white-label branding configuration | ||
| /// No DB access, no auth — returns static config from environment variables | ||
| pub async fn get_config(State(state): State<Arc<AppState>>) -> Json<BrandingConfig> { | ||
| Json(BrandingConfig { | ||
| chain_name: state.chain_name.clone(), | ||
| logo_url: state.chain_logo_url.clone(), | ||
| accent_color: state.accent_color.clone(), | ||
| background_color_dark: state.background_color_dark.clone(), | ||
| background_color_light: state.background_color_light.clone(), | ||
| success_color: state.success_color.clone(), | ||
| error_color: state.error_color.clone(), | ||
| }) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn branding_config_skips_none_fields() { | ||
| let config = BrandingConfig { | ||
| chain_name: "TestChain".to_string(), | ||
| logo_url: None, | ||
| accent_color: Some("#3b82f6".to_string()), | ||
| background_color_dark: None, | ||
| background_color_light: None, | ||
| success_color: None, | ||
| error_color: None, | ||
| }; | ||
|
|
||
| let json = serde_json::to_value(&config).unwrap(); | ||
| assert_eq!(json["chain_name"], "TestChain"); | ||
| assert_eq!(json["accent_color"], "#3b82f6"); | ||
| assert!(json.get("logo_url").is_none()); | ||
| assert!(json.get("background_color_dark").is_none()); | ||
| assert!(json.get("success_color").is_none()); | ||
| assert!(json.get("error_color").is_none()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn branding_config_includes_all_fields_when_set() { | ||
| let config = BrandingConfig { | ||
| chain_name: "MyChain".to_string(), | ||
| logo_url: Some("/branding/logo.svg".to_string()), | ||
| accent_color: Some("#3b82f6".to_string()), | ||
| background_color_dark: Some("#0a0a0f".to_string()), | ||
| background_color_light: Some("#faf5ef".to_string()), | ||
| success_color: Some("#10b981".to_string()), | ||
| error_color: Some("#ef4444".to_string()), | ||
| }; | ||
|
|
||
| let json = serde_json::to_value(&config).unwrap(); | ||
| assert_eq!(json["chain_name"], "MyChain"); | ||
| assert_eq!(json["logo_url"], "/branding/logo.svg"); | ||
| assert_eq!(json["accent_color"], "#3b82f6"); | ||
| assert_eq!(json["background_color_dark"], "#0a0a0f"); | ||
| assert_eq!(json["background_color_light"], "#faf5ef"); | ||
| assert_eq!(json["success_color"], "#10b981"); | ||
| assert_eq!(json["error_color"], "#ef4444"); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,5 +1,6 @@ | ||
| pub mod addresses; | ||
| pub mod blocks; | ||
| pub mod config; | ||
| pub mod etherscan; | ||
| pub mod faucet; | ||
| pub mod logs; | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Empty file.
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.