-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement Reusable Component Structure for Leptos SSR Apps #568
Labels
enhancement
New feature or request
Comments
|
Contributor
@siyara-m-yral to share the images and branding of all the app
|
vishnu-shankar-yral
assigned vishnu-shankar-yral and unassigned siyara-m-yral and vishnu-shankar-yral
Jan 21, 2025
harshita-srivastava-yral
assigned harsh-mn-yral and harsh-mahajan-yral and unassigned harsh-mn-yral
Jan 22, 2025
|
approach
// src/apps/common/types.rs
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum AppType {
IcPump,
Yral,
}
// src/shared/components/ui/button.rs
#[component]
pub fn Button(
#[prop(into)] text: String,
#[prop(optional)] variant: Option<String>,
#[prop(optional)] on_click: Option<Callback<MouseEvent>>,
) -> impl IntoView {
// Shared button implementation
}
// src/apps/icpump/components/custom_button.rs
use crate::shared::components::ui::Button;
#[component]
pub fn IcPumpButton(
#[prop(into)] text: String,
#[prop(optional)] on_click: Option<Callback<MouseEvent>>,
) -> impl IntoView {
view! {
<Button
text=text
variant="icpump-primary"
on_click=on_click
/>
}
}
// src/apps/yral/components/custom_button.rs
use crate::shared::components::ui::Button;
#[component]
pub fn YralButton(
#[prop(into)] text: String,
#[prop(optional)] on_click: Option<Callback<MouseEvent>>,
) -> impl IntoView {
view! {
<Button
text=text
variant="yral-primary"
on_click=on_click
/>
}
} // src/app.rs
use crate::apps::common::types::AppType;
use crate::shared::utils::determine_app_from_host;
#[component]
pub fn App() -> impl IntoView {
let app_type = determine_app_from_host();
view! {
<Router>
<AppContextProvider app_type=app_type>
<SharedLayout>
<Routes>
{match app_type {
AppType::IcPump => view! { <IcPumpRoutes/> },
AppType::Yral => view! { <YralRoutes/> },
}}
</Routes>
</SharedLayout>
</AppContextProvider>
</Router>
}
} |
|
|
|
Open
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc @harshita-srivastava-yral
Icons mapping
Icpump: https://drive.google.com/file/d/1koFbT_jLb1EPuTAT7mi3oQhjbTrW-WMk/view
PND: https://drive.google.com/file/d/1HEjbZn7UN8ZtRqYBNYQGgsgCVi1T_Dyr/view
HON: https://drive.google.com/file/d/1Z-vHCSVwnfWtrP81ENsyCcmNCVT8v2qq/view
The text was updated successfully, but these errors were encountered: