1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use yew::prelude::*;

use super::CardContext;

#[derive(Debug, Clone, PartialEq, Properties)]
pub struct CardExpandableContentProperties {
    /// Content rendered inside the expanded section.
    #[prop_or_default]
    pub children: Html,
    /// Additional classes added to the expanded section.
    #[prop_or_default]
    pub class: Classes,
}

#[function_component(CardExpandableContent)]
pub fn expandable_content(props: &CardExpandableContentProperties) -> Html {
    let CardContext { expanded, .. } = use_context().expect("Could not get card context");
    if !expanded {
        return html!();
    }
    let class = classes!(props.class.clone(), "pf-v5-c-card__expandable-content");
    html! {
        <div {class}>
            {props.children.clone()}
        </div>
    }
}