Skip to main content

vizia_core/views/
card.rs

1use crate::prelude::*;
2
3/// A container view used to group related content.
4pub struct Card;
5
6impl Card {
7    /// Creates a new [Card] view.
8    pub fn new(cx: &mut Context, content: impl FnOnce(&mut Context)) -> Handle<Self> {
9        Self.build(cx, content)
10    }
11}
12
13impl View for Card {
14    fn element(&self) -> Option<&'static str> {
15        Some("card")
16    }
17}
18
19/// The header section of a [Card].
20pub struct CardHeader;
21
22impl CardHeader {
23    /// Creates a new [CardHeader] view.
24    pub fn new(cx: &mut Context, content: impl FnOnce(&mut Context)) -> Handle<Self> {
25        Self.build(cx, content)
26    }
27}
28
29impl View for CardHeader {
30    fn element(&self) -> Option<&'static str> {
31        Some("card-header")
32    }
33}
34
35/// The content section of a [Card].
36pub struct CardContent;
37
38impl CardContent {
39    /// Creates a new [CardContent] view.
40    pub fn new(cx: &mut Context, content: impl FnOnce(&mut Context)) -> Handle<Self> {
41        Self.build(cx, content)
42    }
43}
44
45impl View for CardContent {
46    fn element(&self) -> Option<&'static str> {
47        Some("card-content")
48    }
49}
50
51/// The footer section of a [Card].
52pub struct CardFooter;
53
54impl CardFooter {
55    /// Creates a new [CardFooter] view.
56    pub fn new(cx: &mut Context, content: impl FnOnce(&mut Context)) -> Handle<Self> {
57        Self.build(cx, content)
58    }
59}
60
61impl View for CardFooter {
62    fn element(&self) -> Option<&'static str> {
63        Some("card-footer")
64    }
65}