Skip to main content

rustmotion_components/
card.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use skia_safe::Canvas;
4
5use rustmotion_core::css::CssStyle;
6use rustmotion_core::engine::layout_pass::BoxLayout;
7use rustmotion_core::schema::TimelineStep;
8use rustmotion_core::traits::{PaintCtx, Painter, TimingConfig};
9
10use crate::ChildComponent;
11
12/// Card container — backward-compatible with v1 `"type": "card"`.
13/// Supports both flex and grid display modes via the `display` style field.
14#[derive(Debug, Serialize, Deserialize, JsonSchema)]
15pub struct Card {
16    #[serde(default)]
17    pub children: Vec<ChildComponent>,
18    #[serde(flatten)]
19    pub timing: TimingConfig,
20    #[serde(default)]
21    pub style: CssStyle,
22    #[serde(default)]
23    pub timeline: Vec<TimelineStep>,
24    #[serde(default)]
25    pub stagger: Option<f32>,
26    #[serde(default)]
27    pub time_scale: Option<f64>,
28    #[serde(default)]
29    pub time_offset: Option<f64>,
30}
31
32rustmotion_core::impl_traits!(Card {
33    Animatable => animation,
34    Timed => timing,
35    Styled => style,
36});
37
38impl Painter for Card {
39    fn paint_content(
40        &self,
41        _canvas: &Canvas,
42        _layout: &BoxLayout,
43        _props: &rustmotion_core::engine::animator::AnimatedProperties,
44        _ctx: &PaintCtx,
45    ) {
46    }
47}