|
1 | 1 | use components_core::{BASE_CLASS, concat}; |
2 | 2 | use leptos::prelude::*; |
3 | 3 |
|
| 4 | +#[derive(Default, Debug, PartialEq)] |
| 5 | +pub enum Variant { |
| 6 | + #[default] |
| 7 | + Normal, |
| 8 | + Resource, |
| 9 | +} |
| 10 | + |
4 | 11 | #[component] |
5 | 12 | pub fn Card( |
6 | 13 | children: Children, |
| 14 | + #[prop(into, optional, default = Variant::Normal)] variant: Variant, |
7 | 15 | #[prop(into, optional)] class: String, |
8 | 16 | #[prop(into, optional, default = false)] clickable: bool, |
9 | 17 | #[prop(into, optional, default = false)] disabled: bool, |
10 | 18 | ) -> impl IntoView { |
11 | | - let class = crate::tw!( |
| 19 | + let mut class = crate::tw!( |
12 | 20 | concat!(BASE_CLASS, "-card"), |
13 | 21 | clickable.then_some(concat!(BASE_CLASS, "-card--clickable")), |
14 | 22 | disabled.then_some(concat!("disabled ", BASE_CLASS, "-card--disabled")), |
15 | 23 | class |
16 | 24 | ); |
17 | 25 |
|
| 26 | + if variant == Variant::Resource { |
| 27 | + class = format!("{}-card--resource relative", BASE_CLASS); |
| 28 | + |
| 29 | + return view! { |
| 30 | + <div class={class}> |
| 31 | + <svg viewBox="0 0 334 444" fill="none" xmlns="http://www.w3.org/2000/svg" class="drop-shadow-resource-card"> |
| 32 | + <path d="M267.221 2C275.589 2 283.519 5.74306 288.838 12.2038L325.617 56.8794C329.744 61.892 332 68.1829 332 74.6756V414C332 429.464 319.464 442 304 442H30C14.536 442 2 429.464 2 414V30C2 14.536 14.536 2 30 2H267.221Z" fill="#3D3D3D" stroke="black" stroke-width="2"/> |
| 33 | + </svg> |
| 34 | + <div class="rustlanges-card--resource-body"> |
| 35 | + {children()} |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + }.into_any(); |
| 39 | + } |
| 40 | + |
18 | 41 | view! { |
19 | 42 | <div class={class}> |
20 | 43 | {children()} |
21 | 44 | </div> |
22 | 45 | } |
| 46 | + .into_any() |
23 | 47 | } |
0 commit comments