|
| 1 | +use leptos::{component, view, Children, IntoView}; |
| 2 | +use std::collections::HashMap; |
| 3 | + |
| 4 | +#[component] |
| 5 | +pub fn ButtonLargeLink( |
| 6 | + #[prop(into)] href: String, |
| 7 | + #[prop(default = "primary")] color: &'static str, |
| 8 | + #[prop(default = "normal")] size: &'static str, |
| 9 | + #[prop(default = "drop")] shadow: &'static str, |
| 10 | + #[prop(into, optional)] class: String, |
| 11 | + children: Children, |
| 12 | +) -> impl IntoView { |
| 13 | + let colors = HashMap::from([ |
| 14 | + ( |
| 15 | + "primary", |
| 16 | + "bg-orange-200 dark:bg-transparent hover:bg-black hover:text-white", |
| 17 | + ), |
| 18 | + ("white", "bg-orange-100 dark:bg-transparent hover:bg-black hover:text-white"), |
| 19 | + ]); |
| 20 | + let shadows = HashMap::from([ |
| 21 | + ("drop", "drop-shadow-[4px_4px_0_rgba(0,0,0)] hover:drop-shadow-[0_0_0_rgba(0,0,0)]"), |
| 22 | + ("box", "drop-shadow-[4px_4px_0_rgba(0,0,0)] hover:drop-shadow-[0_0_0_rgba(0,0,0)] dark:drop-shadow-none shadow-sm hover:drop-shadow-none dark:hover:shadow-lg shadow-black"), |
| 23 | + ]); |
| 24 | + let sizes = HashMap::from([("tiny", "min-h-7"), ("normal", "h-9"), ("big", "h-12")]); |
| 25 | + let current_color = (*colors.get(&color).unwrap()).to_string(); |
| 26 | + let current_size = (*sizes.get(&size).unwrap()).to_string(); |
| 27 | + let shadow = (*shadows.get(&shadow).unwrap()).to_string(); |
| 28 | + |
| 29 | + view! { |
| 30 | + <a |
| 31 | + href=href |
| 32 | + target="_blank" |
| 33 | + class=format!( |
| 34 | + "tracking-wider text-center font-work-sans border border-black dark:border-white flex items-center px-4 transition w-full max-w-full sm:max-w-[20rem] gap-x-4 {} {} {} {} whitespace-nowrap", |
| 35 | + current_color, |
| 36 | + current_size, |
| 37 | + class, |
| 38 | + shadow, |
| 39 | + ) |
| 40 | + > |
| 41 | + |
| 42 | + {children()} |
| 43 | + </a> |
| 44 | + } |
| 45 | +} |
| 46 | + |
0 commit comments