Skip to content

Commit 3dc1e2e

Browse files
committed
fix(card): add variant support and resource styling to Card component
fix(chip): update variant class formatting and condition for label display style(card): enhance resource card styles with drop shadow and layout adjustments chore: bump package versions for leptos and styles
1 parent 17104f7 commit 3dc1e2e

File tree

7 files changed

+43
-7
lines changed

7 files changed

+43
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustlanges-components"
33
description = "RustLangES components library"
4-
version = "0.1.1"
4+
version = "0.2.2"
55
edition = "2024"
66
license = "MIT"
77

@@ -16,4 +16,4 @@ members = [ "crates/core", "crates/leptos" ]
1616

1717
[dependencies]
1818
components-core = { package = "rustlanges-components-core", version = "0.1", path = "./crates/core" }
19-
leptos-components = { path = "./crates/leptos", version = "0.1", optional = true }
19+
leptos-components = { path = "./crates/leptos", version = "0.2", optional = true }

crates/leptos/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "leptos-components"
33
description = "RustLangES leptos components"
4-
version = "0.1.2"
4+
version = "0.2.2"
55
edition = "2024"
66
license = "MIT"
77

crates/leptos/src/card.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
use components_core::{BASE_CLASS, concat};
22
use leptos::prelude::*;
33

4+
#[derive(Default, Debug, PartialEq)]
5+
pub enum Variant {
6+
#[default]
7+
Normal,
8+
Resource,
9+
}
10+
411
#[component]
512
pub fn Card(
613
children: Children,
14+
#[prop(into, optional, default = Variant::Normal)] variant: Variant,
715
#[prop(into, optional)] class: String,
816
#[prop(into, optional, default = false)] clickable: bool,
917
#[prop(into, optional, default = false)] disabled: bool,
1018
) -> impl IntoView {
11-
let class = crate::tw!(
19+
let mut class = crate::tw!(
1220
concat!(BASE_CLASS, "-card"),
1321
clickable.then_some(concat!(BASE_CLASS, "-card--clickable")),
1422
disabled.then_some(concat!("disabled ", BASE_CLASS, "-card--disabled")),
1523
class
1624
);
1725

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+
1841
view! {
1942
<div class={class}>
2043
{children()}
2144
</div>
2245
}
46+
.into_any()
2347
}

crates/leptos/src/chip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ pub fn Chip(
3232
) -> impl IntoView {
3333
let class = crate::tw!(
3434
concat!(BASE_CLASS, "-chip"),
35-
format!("{BASE_CLASS}-chip--{variant:?}"),
35+
format!("{BASE_CLASS}-chip--{variant:?}").to_lowercase(),
3636
class
3737
);
3838

3939
view! {
4040
<div class=class>
4141
{variant.icon()}
42-
{(variant != Variant::Numeric).then_some(format!("#{label}")).unwrap_or(label)}
42+
{(variant == Variant::Numeric).then_some(format!("#{label}")).unwrap_or(label)}
4343
</div>
4444
}
4545
}

js/react/lib/components/card/card.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export type CardProps = PropsWithChildren & {
1111
export const Card = withAs((Component, props: CardProps) => {
1212
const { clickable = false, disabled = false, className, ...attr } = props;
1313

14+
// TODO: Add parity with the leptos version | e.g. variants like 'normal' and 'resource'
15+
// TODO: If 'resource', add the svg of the card with the drop shadow effect
16+
1417
return (
1518
<Component
1619
className={cn(

styles/components/card.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@
2020
@apply border-neutral-200;
2121
@apply dark:border-neutral-600;
2222
}
23+
24+
.rustlanges-card--resource > svg {
25+
filter: drop-shadow(0px 0px 0px #000000) drop-shadow(4px 4px 0px #000000) url(#inset-shadow);
26+
@apply w-full h-auto;
27+
}
28+
29+
.rustlanges-card--resource-body {
30+
@apply absolute inset-0 flex justify-center items-center p-10;
31+
}
2332
}

styles/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@rustlanges/styles",
33
"private": false,
4-
"version": "0.0.3",
4+
"version": "0.0.4",
55
"type": "module",
66
"exports": {
77
".": "./tailwindcss.css",

0 commit comments

Comments
 (0)