patternfly_yew/core/
orientation.rs1use crate::core::AsClasses;
2use popper_rs::state::AttributesMap;
3use yew::{classes, Classes};
4
5#[derive(Copy, Clone, PartialEq, Eq, Debug)]
7pub enum Orientation {
8 Left,
9 Right,
10 Top,
11 Bottom,
12}
13
14impl AsClasses for Orientation {
15 fn extend_classes(&self, classes: &mut Classes) {
16 match self {
17 Self::Left => classes.extend(classes!("pf-m-left")),
18 Self::Right => classes.extend(classes!("pf-m-right")),
19 Self::Top => classes.extend(classes!("pf-m-top")),
20 Self::Bottom => classes.extend(classes!("pf-m-bottom")),
21 }
22 }
23}
24
25impl Orientation {
26 pub fn from_popper_data(attributes: &AttributesMap) -> Self {
27 match attributes.get("data-popper-placement").map(|v| v.as_str()) {
28 Some("top") => Self::Top,
29 Some("left") => Self::Left,
30 Some("right") => Self::Right,
31 None | Some(_) => Self::Bottom,
32 }
33 }
34}