yew_bs/components/
link.rs1use yew::prelude::*;
2#[derive(Clone, Copy, PartialEq, Debug)]
3pub enum TextDecoration {
4 None,
5 Underline,
6}
7impl TextDecoration {
8 pub fn as_str(&self) -> &'static str {
9 match self {
10 TextDecoration::None => "text-decoration-none",
11 TextDecoration::Underline => "text-decoration-underline",
12 }
13 }
14}
15#[derive(Clone, Copy, PartialEq, Debug)]
17pub enum LinkOpacity {
18 Opacity10,
19 Opacity25,
20 Opacity50,
21 Opacity75,
22 Opacity100,
23}
24impl LinkOpacity {
25 pub fn as_str(&self) -> &'static str {
26 match self {
27 LinkOpacity::Opacity10 => "link-opacity-10",
28 LinkOpacity::Opacity25 => "link-opacity-25",
29 LinkOpacity::Opacity50 => "link-opacity-50",
30 LinkOpacity::Opacity75 => "link-opacity-75",
31 LinkOpacity::Opacity100 => "link-opacity-100",
32 }
33 }
34}
35#[derive(Clone, Copy, PartialEq, Debug)]
36pub enum LinkOffset {
37 Offset1,
38 Offset2,
39 Offset3,
40}
41impl LinkOffset {
42 pub fn as_str(&self) -> &'static str {
43 match self {
44 LinkOffset::Offset1 => "link-offset-1",
45 LinkOffset::Offset2 => "link-offset-2",
46 LinkOffset::Offset3 => "link-offset-3",
47 }
48 }
49}
50#[derive(Properties, PartialEq)]
52pub struct LinkProps {
53 #[prop_or_default]
55 pub text_decoration: Option<TextDecoration>,
56 #[prop_or_default]
58 pub link_opacity: Option<LinkOpacity>,
59 #[prop_or_default]
61 pub link_offset: Option<LinkOffset>,
62 #[prop_or_default]
64 pub children: Children,
65 #[prop_or_default]
67 pub class: Option<AttrValue>,
68}
69#[function_component(Link)]
73pub fn link(props: &LinkProps) -> Html {
74 let mut classes = Classes::new();
75 if let Some(text_decoration) = &props.text_decoration {
76 classes.push(text_decoration.as_str());
77 }
78 if let Some(link_opacity) = &props.link_opacity {
79 classes.push(link_opacity.as_str());
80 }
81 if let Some(link_offset) = &props.link_offset {
82 classes.push(link_offset.as_str());
83 }
84 if let Some(custom_class) = &props.class {
85 classes.push(custom_class.to_string());
86 }
87 html! {
88 < div class = { classes } > { for props.children.iter() } </ div >
89 }
90}