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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Gallery

use crate::prelude::wrap::wrapper_div_with_attributes;
use yew::prelude::*;
use yew::virtual_dom::ApplyAttributeAs;

#[derive(Clone, PartialEq, Properties)]
pub struct GalleryProperties {
    pub children: Children,
    #[prop_or_default]
    pub gutter: bool,
    #[prop_or_default]
    pub style: AttrValue,
}

/// Gallery layout
///
/// > Use a **Gallery** layout to arrange content in a responsive grid. Content will wrap responsively to create uniform rows and columns.
///
/// See: <https://www.patternfly.org/layouts/gallery>
///
/// ## Properties
///
/// Defined by [`GalleryProperties`].
#[function_component(Gallery)]
pub fn gallery(props: &GalleryProperties) -> Html {
    let mut classes = classes!("pf-v5-l-gallery");

    if props.gutter {
        classes.push(classes!("pf-m-gutter"));
    }

    html! (
        <div
            class={classes}
            style={&props.style}
        >
        { for props.children.iter().map(|child|{
            wrapper_div_with_attributes(child, &[("class", "pf-v5-l-gallery__item", ApplyAttributeAs::Attribute)])
        }) }
        </div>
    )
}