orbital_base_components/navigation/overflow/
base.rs1use leptos::prelude::*;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
4pub enum OverflowDirection {
5 #[default]
6 Horizontal,
7 Vertical,
8 Both,
9}
10
11#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
12pub enum OverflowAxes {
13 #[default]
14 Horizontal,
15 Vertical,
16 Both,
17}
18
19#[derive(Clone, Debug, Default)]
20pub struct OverflowChangeData {
21 pub has_overflow: bool,
22}
23
24#[component]
25pub fn BaseOverflow(
26 #[prop(optional, into)] class: MaybeProp<String>,
27 #[prop(optional, into)] overflow_direction: Signal<OverflowDirection>,
28 #[prop(optional, into)] has_overflow: Signal<bool>,
29 children: Children,
30) -> impl IntoView {
31 view! {
32 <div
33 class=move || {
34 let mut parts = vec![
35 "orbital-overflow".to_string(),
36 format!(
37 "orbital-overflow--{}",
38 direction_as_str(overflow_direction.get())
39 ),
40 ];
41 if has_overflow.get() {
42 parts.push("orbital-overflow--clipped".to_string());
43 }
44 if let Some(extra) = class.get() {
45 if !extra.is_empty() {
46 parts.push(extra);
47 }
48 }
49 parts.join(" ")
50 }
51 data-overflow=move || has_overflow.get().to_string()
52 >
53 {children()}
54 </div>
55 }
56}
57
58fn direction_as_str(direction: OverflowDirection) -> &'static str {
59 match direction {
60 OverflowDirection::Horizontal => "horizontal",
61 OverflowDirection::Vertical => "vertical",
62 OverflowDirection::Both => "both",
63 }
64}