1use dioxus::prelude::*;
5
6use crate::class::{Glass, compose};
7
8#[derive(Props, Clone, PartialEq)]
10pub struct EyebrowProps {
11 #[props(into)]
13 pub class: Option<String>,
14 #[props(extends = GlobalAttributes, extends = p)]
16 pub attributes: Vec<Attribute>,
17 pub children: Element,
19}
20
21#[component]
23pub fn Eyebrow(props: EyebrowProps) -> Element {
24 let class = compose([Some("ui-eyebrow"), props.class.as_deref()]);
25
26 rsx! {
27 p { class, ..props.attributes, {props.children} }
28 }
29}
30
31#[derive(Props, Clone, PartialEq)]
33pub struct FloatingBadgeProps {
34 #[props(into)]
36 pub class: Option<String>,
37 #[props(extends = GlobalAttributes, extends = span)]
39 pub attributes: Vec<Attribute>,
40 pub children: Element,
42}
43
44#[component]
46pub fn FloatingBadge(props: FloatingBadgeProps) -> Element {
47 let class = compose([Some("ui-floating-badge"), props.class.as_deref()]);
48
49 rsx! {
50 span { class, ..props.attributes, {props.children} }
51 }
52}
53
54#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
56#[non_exhaustive]
57pub enum ItemElement {
58 #[default]
60 Div,
61 Article,
63 Li,
65 Section,
67}
68
69#[derive(Props, Clone, PartialEq)]
71pub struct ItemProps {
72 #[props(default)]
74 pub r#as: ItemElement,
75 #[props(default, into)]
77 pub glass: Glass,
78 #[props(into)]
80 pub class: Option<String>,
81 #[props(extends = GlobalAttributes)]
83 pub attributes: Vec<Attribute>,
84 pub children: Element,
86}
87
88#[component]
90pub fn Item(props: ItemProps) -> Element {
91 let glass = props.glass.class("ui-item");
92 let class = compose([Some("ui-item"), glass.as_deref(), props.class.as_deref()]);
93
94 match props.r#as {
95 ItemElement::Div => rsx! {
96 div { class, "data-slot": "item", ..props.attributes, {props.children} }
97 },
98 ItemElement::Article => rsx! {
99 article { class, "data-slot": "item", ..props.attributes, {props.children} }
100 },
101 ItemElement::Li => rsx! {
102 li { class, "data-slot": "item", ..props.attributes, {props.children} }
103 },
104 ItemElement::Section => rsx! {
105 section { class, "data-slot": "item", ..props.attributes, {props.children} }
106 },
107 }
108}
109
110#[derive(Props, Clone, PartialEq)]
112pub struct KbdProps {
113 #[props(into)]
115 pub class: Option<String>,
116 #[props(extends = GlobalAttributes, extends = kbd)]
118 pub attributes: Vec<Attribute>,
119 pub children: Element,
121}
122
123#[component]
125pub fn Kbd(props: KbdProps) -> Element {
126 let class = compose([Some("ui-kbd"), props.class.as_deref()]);
127
128 rsx! {
129 kbd { class, ..props.attributes, {props.children} }
130 }
131}
132
133#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
135#[non_exhaustive]
136pub enum MarkerVariant {
137 #[default]
139 Default,
140 Success,
142 Warning,
144 Danger,
146}
147
148impl MarkerVariant {
149 pub fn as_str(self) -> &'static str {
151 match self {
152 Self::Default => "default",
153 Self::Success => "success",
154 Self::Warning => "warning",
155 Self::Danger => "danger",
156 }
157 }
158}
159
160#[derive(Props, Clone, PartialEq)]
162pub struct MarkerProps {
163 #[props(default)]
165 pub variant: MarkerVariant,
166 #[props(into)]
168 pub class: Option<String>,
169 #[props(extends = GlobalAttributes, extends = span)]
171 pub attributes: Vec<Attribute>,
172 pub children: Element,
174}
175
176#[component]
178pub fn Marker(props: MarkerProps) -> Element {
179 let variant = (props.variant != MarkerVariant::Default)
180 .then(|| format!("ui-marker--{}", props.variant.as_str()));
181 let class = compose([
182 Some("ui-marker"),
183 variant.as_deref(),
184 props.class.as_deref(),
185 ]);
186
187 rsx! {
188 span {
189 class,
190 "data-variant": props.variant.as_str(),
191 ..props.attributes,
192 {props.children}
193 }
194 }
195}
196
197#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
199#[non_exhaustive]
200pub enum NoteBorderPosition {
201 #[default]
203 Left,
204 Right,
206 None,
208}
209
210impl NoteBorderPosition {
211 pub fn as_str(self) -> &'static str {
213 match self {
214 Self::Left => "left",
215 Self::Right => "right",
216 Self::None => "none",
217 }
218 }
219}
220
221#[derive(Props, Clone, PartialEq)]
223pub struct NoteProps {
224 #[props(into)]
226 pub label: Option<String>,
227 #[props(default)]
229 pub border_position: NoteBorderPosition,
230 #[props(into)]
232 pub class: Option<String>,
233 #[props(extends = GlobalAttributes, extends = div)]
235 pub attributes: Vec<Attribute>,
236 pub children: Element,
238}
239
240#[component]
242pub fn Note(props: NoteProps) -> Element {
243 let border = format!("ui-note--border-{}", props.border_position.as_str());
244 let class = compose([
245 Some("ui-note"),
246 Some(border.as_str()),
247 props.class.as_deref(),
248 ]);
249 let label = props.label.filter(|label| !label.is_empty());
250
251 rsx! {
252 div { class, ..props.attributes,
253 if let Some(label) = label {
254 p { class: "ui-note__label", {label} }
255 }
256 div { class: "ui-note__content", {props.children} }
257 }
258 }
259}
260
261#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
263#[non_exhaustive]
264pub enum PillVariant {
265 #[default]
267 Neutral,
268 Brand,
270 Outline,
272}
273
274impl PillVariant {
275 pub fn as_str(self) -> &'static str {
277 match self {
278 Self::Neutral => "neutral",
279 Self::Brand => "brand",
280 Self::Outline => "outline",
281 }
282 }
283}
284
285#[derive(Props, Clone, PartialEq)]
287pub struct PillProps {
288 #[props(default)]
290 pub variant: PillVariant,
291 #[props(into)]
293 pub count: Option<String>,
294 #[props(into)]
296 pub href: Option<String>,
297 #[props(into)]
299 pub class: Option<String>,
300 #[props(extends = GlobalAttributes)]
302 pub attributes: Vec<Attribute>,
303 pub children: Element,
305}
306
307#[component]
309pub fn Pill(props: PillProps) -> Element {
310 let variant = (props.variant != PillVariant::Neutral)
311 .then(|| format!("ui-pill--{}", props.variant.as_str()));
312 let class = compose([Some("ui-pill"), variant.as_deref(), props.class.as_deref()]);
313 let content = rsx! {
314 {props.children}
315 if let Some(count) = props.count {
316 span { class: "ui-pill__count", {count} }
317 }
318 };
319
320 if let Some(href) = props.href {
321 rsx! {
322 a {
323 class,
324 "data-variant": props.variant.as_str(),
325 href,
326 ..props.attributes,
327 {content}
328 }
329 }
330 } else {
331 rsx! {
332 span {
333 class,
334 "data-variant": props.variant.as_str(),
335 ..props.attributes,
336 {content}
337 }
338 }
339 }
340}
341
342#[derive(Props, Clone, PartialEq)]
344pub struct TypographyProps {
345 #[props(into)]
347 pub class: Option<String>,
348 #[props(extends = GlobalAttributes, extends = div)]
350 pub attributes: Vec<Attribute>,
351 pub children: Element,
353}
354
355#[component]
357pub fn Typography(props: TypographyProps) -> Element {
358 let class = compose([Some("ui-typography"), props.class.as_deref()]);
359
360 rsx! {
361 div { class, ..props.attributes, {props.children} }
362 }
363}