Function bodies 1,000 total
chevron_down_dom function · rust · L259-L272 (14 LOC)crates/rinch-components/src/icons.rs
pub fn chevron_down_dom(class: &str, scope: &mut RenderScope) -> NodeHandle {
let svg = scope.create_element("svg");
svg.set_attribute("class", class);
svg.set_attribute("viewBox", "0 0 24 24");
svg.set_attribute("fill", "none");
svg.set_attribute("stroke", "currentColor");
svg.set_attribute("stroke-width", "2");
let polyline = scope.create_element("polyline");
polyline.set_attribute("points", "6 9 12 15 18 9");
svg.append_child(&polyline);
svg
}class_name function · rust · L20-L28 (9 LOC)crates/rinch-components/src/image.rs
pub fn class_name(&self) -> &'static str {
match self {
ImageFit::Cover => "rinch-image--fit-cover",
ImageFit::Contain => "rinch-image--fit-contain",
ImageFit::Fill => "rinch-image--fit-fill",
ImageFit::None => "rinch-image--fit-none",
ImageFit::ScaleDown => "rinch-image--fit-scale-down",
}
}from_str function · rust · L33-L42 (10 LOC)crates/rinch-components/src/image.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"cover" => Ok(ImageFit::Cover),
"contain" => Ok(ImageFit::Contain),
"fill" => Ok(ImageFit::Fill),
"none" => Ok(ImageFit::None),
"scale-down" | "scaledown" => Ok(ImageFit::ScaleDown),
_ => Err(()),
}
}class_string function · rust · L76-L99 (24 LOC)crates/rinch-components/src/image.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-image"];
let fit: ImageFit = if self.fit.is_empty() {
ImageFit::default()
} else {
self.fit.parse().unwrap_or_default()
};
classes.push(fit.class_name());
if !self.radius.is_empty() {
let r = &self.radius;
classes.push(match r.as_str() {
"xs" => "rinch-image--radius-xs",
"sm" => "rinch-image--radius-sm",
"md" => "rinch-image--radius-md",
"lg" => "rinch-image--radius-lg",
"xl" => "rinch-image--radius-xl",
_ => "",
});
}
classes.join(" ")
}render function · rust · L103-L154 (52 LOC)crates/rinch-components/src/image.rs
fn render(&self, __scope: &mut RenderScope, _children: &[NodeHandle]) -> NodeHandle {
let src = if self.src.is_empty() { "" } else { &self.src };
let alt = if self.alt.is_empty() { "" } else { &self.alt };
let mut styles = Vec::new();
if !self.width.is_empty() {
let w = &self.width;
let w = if w.chars().all(|c| c.is_ascii_digit()) {
format!("{}px", w)
} else {
w.clone()
};
styles.push(format!("width: {}", w));
}
if !self.height.is_empty() {
let h = &self.height;
let h = if h.chars().all(|c| c.is_ascii_digit()) {
format!("{}px", h)
} else {
h.clone()
};
styles.push(format!("height: {}", h));
}
let figure = rinch_macros::rsx! { figure { class: "rinch-image__wrapper" } };
if !styles.is_empty() {
figure.set_attribute("sclass_string function · rust · L17-L31 (15 LOC)crates/rinch-components/src/kbd.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-kbd"];
if !self.size.is_empty() {
match self.size.as_str() {
"xs" => classes.push("rinch-kbd--xs"),
"sm" => classes.push("rinch-kbd--sm"),
"md" => classes.push("rinch-kbd--md"),
"lg" => classes.push("rinch-kbd--lg"),
_ => {}
}
}
classes.join(" ")
}render function · rust · L35-L42 (8 LOC)crates/rinch-components/src/kbd.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
let container = rinch_macros::rsx! { kbd { class: "rinch-kbd" } };
container.set_attribute("class", &self.class_string());
for child in children {
container.append_child(child);
}
container
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
class_name function · rust · L18-L23 (6 LOC)crates/rinch-components/src/list.rs
pub fn class_name(&self) -> &'static str {
match self {
ListType::Unordered => "rinch-list--unordered",
ListType::Ordered => "rinch-list--ordered",
}
}from_str function · rust · L28-L34 (7 LOC)crates/rinch-components/src/list.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"unordered" | "ul" => Ok(ListType::Unordered),
"ordered" | "ol" => Ok(ListType::Ordered),
_ => Err(()),
}
}class_name function · rust · L49-L57 (9 LOC)crates/rinch-components/src/list.rs
pub fn class_name(&self) -> &'static str {
match self {
ListSize::Xs => "rinch-list--xs",
ListSize::Sm => "rinch-list--sm",
ListSize::Md => "rinch-list--md",
ListSize::Lg => "rinch-list--lg",
ListSize::Xl => "rinch-list--xl",
}
}from_str function · rust · L62-L71 (10 LOC)crates/rinch-components/src/list.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"xs" => Ok(ListSize::Xs),
"sm" => Ok(ListSize::Sm),
"md" => Ok(ListSize::Md),
"lg" => Ok(ListSize::Lg),
"xl" => Ok(ListSize::Xl),
_ => Err(()),
}
}class_string function · rust · L108-L146 (39 LOC)crates/rinch-components/src/list.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-list"];
let list_type: ListType = if self.r#type.is_empty() {
ListType::default()
} else {
self.r#type.parse().unwrap_or_default()
};
classes.push(list_type.class_name());
let size: ListSize = if self.size.is_empty() {
ListSize::default()
} else {
self.size.parse().unwrap_or_default()
};
classes.push(size.class_name());
if !self.spacing.is_empty() {
let spacing = &self.spacing;
classes.push(match spacing.as_str() {
"xs" => "rinch-list--spacing-xs",
"sm" => "rinch-list--spacing-sm",
"md" => "rinch-list--spacing-md",
"lg" => "rinch-list--spacing-lg",
"xl" => "rinch-list--spacing-xl",
_ => "",
});
}
if self.center {
classes.push("render function · rust · L150-L169 (20 LOC)crates/rinch-components/src/list.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
let class = self.class_string();
let list_type: ListType = if self.r#type.is_empty() {
ListType::default()
} else {
self.r#type.parse().unwrap_or_default()
};
let container = match list_type {
ListType::Ordered => rinch_macros::rsx! { ol { class: "rinch-list" } },
ListType::Unordered => rinch_macros::rsx! { ul { class: "rinch-list" } },
};
container.set_attribute("class", &class);
for child in children {
container.append_child(child);
}
container
}render function · rust · L180-L203 (24 LOC)crates/rinch-components/src/list.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
let container = rinch_macros::rsx! { li { class: "rinch-list__item" } };
if let Some(icon) = self.icon {
container.set_attribute("class", "rinch-list__item rinch-list__item--with-icon");
let icon_span = rinch_macros::rsx! { span { class: "rinch-list__item-icon" } };
let icon_el = render_tabler_icon(__scope, icon, TablerIconStyle::Outline);
icon_span.append_child(&icon_el);
container.append_child(&icon_span);
let content_span = rinch_macros::rsx! { span { class: "rinch-list__item-content" } };
for child in children {
content_span.append_child(child);
}
container.append_child(&content_span);
} else {
for child in children {
container.append_child(child);
}
}
container
}class_name function · rust · L22-L28 (7 LOC)crates/rinch-components/src/loader.rs
pub fn class_name(&self) -> &'static str {
match self {
LoaderType::Oval => "rinch-loader--oval",
LoaderType::Bars => "rinch-loader--bars",
LoaderType::Dots => "rinch-loader--dots",
}
}Repobility · open methodology · https://repobility.com/research/
from_str function · rust · L33-L41 (9 LOC)crates/rinch-components/src/loader.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"oval" | "spinner" | "circle" => Ok(LoaderType::Oval),
"bars" => Ok(LoaderType::Bars),
"dots" => Ok(LoaderType::Dots),
_ => Err(()),
}
}class_name function · rust · L57-L65 (9 LOC)crates/rinch-components/src/loader.rs
pub fn class_name(&self) -> &'static str {
match self {
LoaderSize::Xs => "rinch-loader--xs",
LoaderSize::Sm => "rinch-loader--sm",
LoaderSize::Md => "rinch-loader--md",
LoaderSize::Lg => "rinch-loader--lg",
LoaderSize::Xl => "rinch-loader--xl",
}
}from_str function · rust · L70-L80 (11 LOC)crates/rinch-components/src/loader.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"xs" => Ok(LoaderSize::Xs),
"sm" => Ok(LoaderSize::Sm),
"md" => Ok(LoaderSize::Md),
"lg" => Ok(LoaderSize::Lg),
"xl" => Ok(LoaderSize::Xl),
_ => Err(()),
}
}class_string function · rust · L108-L120 (13 LOC)crates/rinch-components/src/loader.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-loader"];
// Type class
let loader_type: LoaderType = self.r#type.parse().unwrap_or_default();
classes.push(loader_type.class_name());
// Size class
let size: LoaderSize = self.size.parse().unwrap_or_default();
classes.push(size.class_name());
classes.join(" ")
}render function · rust · L124-L162 (39 LOC)crates/rinch-components/src/loader.rs
fn render(&self, __scope: &mut RenderScope, _children: &[NodeHandle]) -> NodeHandle {
let container = rinch_macros::rsx! { span { class: "rinch-loader", role: "status" } };
container.set_attribute("class", &self.class_string());
container.set_attribute("aria-label", "Loading");
// Color style attribute
if !self.color.is_empty() {
let c = &self.color;
let style = if c.starts_with('#') || c.starts_with("rgb") || c.starts_with("hsl") {
format!("--rinch-loader-color: {}", c)
} else {
format!("--rinch-loader-color: var(--rinch-color-{}-6)", c)
};
container.set_attribute("style", &style);
}
let loader_type: LoaderType = self.r#type.parse().unwrap_or_default();
match loader_type {
LoaderType::Oval => {
let svg_placeholder = rinch_macros::rsx! { span { class: "rinch-loader__oval" } };
contaclass_string function · rust · L52-L71 (20 LOC)crates/rinch-components/src/loading_overlay.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-loading-overlay"];
if self.visible {
classes.push("rinch-loading-overlay--visible");
}
if !self.radius.is_empty() {
match self.radius.as_str() {
"xs" => classes.push("rinch-loading-overlay--radius-xs"),
"sm" => classes.push("rinch-loading-overlay--radius-sm"),
"md" => classes.push("rinch-loading-overlay--radius-md"),
"lg" => classes.push("rinch-loading-overlay--radius-lg"),
"xl" => classes.push("rinch-loading-overlay--radius-xl"),
_ => {}
}
}
classes.join(" ")
}render function · rust · L75-L151 (77 LOC)crates/rinch-components/src/loading_overlay.rs
fn render(&self, __scope: &mut RenderScope, _children: &[NodeHandle]) -> NodeHandle {
let class = self.class_string();
let mut style_parts = Vec::new();
if let Some(opacity) = self.overlay_opacity {
style_parts.push(format!("--rinch-loading-overlay-opacity: {}", opacity));
}
if !self.overlay_blur.is_empty() {
style_parts.push(format!(
"--rinch-loading-overlay-blur: {}",
self.overlay_blur
));
}
if !self.loader_color.is_empty() {
let color = &self.loader_color;
if color.starts_with('#') || color.starts_with("rgb") || color.starts_with("hsl") {
style_parts.push(format!("--rinch-loading-overlay-loader-color: {}", color));
} else {
style_parts.push(format!(
"--rinch-loading-overlay-loader-color: var(--rinch-color-{}-6)",
color
));
render function · rust · L27-L44 (18 LOC)crates/rinch-components/src/mark.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
let container = rinch_macros::rsx! { mark { class: "rinch-mark" } };
if !self.color.is_empty() {
let c = &self.color;
let style = if c.starts_with('#') || c.starts_with("rgb") || c.starts_with("hsl") {
format!("--rinch-mark-color: {}", c)
} else {
format!("--rinch-mark-color: var(--rinch-color-{}-2)", c)
};
container.set_attribute("style", &style);
}
for child in children {
container.append_child(child);
}
container
}Open data scored by Repobility · https://repobility.com
class_name function · rust · L39-L48 (10 LOC)crates/rinch-components/src/modal.rs
pub fn class_name(&self) -> &'static str {
match self {
ModalSize::Xs => "rinch-modal--xs",
ModalSize::Sm => "rinch-modal--sm",
ModalSize::Md => "rinch-modal--md",
ModalSize::Lg => "rinch-modal--lg",
ModalSize::Xl => "rinch-modal--xl",
ModalSize::Full => "rinch-modal--full",
}
}from_str function · rust · L53-L63 (11 LOC)crates/rinch-components/src/modal.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"xs" => Ok(ModalSize::Xs),
"sm" => Ok(ModalSize::Sm),
"md" => Ok(ModalSize::Md),
"lg" => Ok(ModalSize::Lg),
"xl" => Ok(ModalSize::Xl),
"full" => Ok(ModalSize::Full),
_ => Err(()),
}
}fmt function · rust · L133-L153 (21 LOC)crates/rinch-components/src/modal.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Modal")
.field("opened", &self.opened)
.field("opened_fn", &self.opened_fn.as_ref().map(|_| "<reactive>"))
.field("title", &self.title)
.field("size", &self.size)
.field("radius", &self.radius)
.field("with_overlay", &self.with_overlay)
.field("overlay_opacity", &self.overlay_opacity)
.field("overlay_blur", &self.overlay_blur)
.field("centered", &self.centered)
.field("close_on_click_outside", &self.close_on_click_outside)
.field("close_on_escape", &self.close_on_escape)
.field("with_close_button", &self.with_close_button)
.field("padding", &self.padding)
.field("z_index", &self.z_index)
.field("lock_scroll", &self.lock_scroll)
.field("trap_focus", &self.trap_focus)
.field("onclose", &self.default function · rust · L157-L177 (21 LOC)crates/rinch-components/src/modal.rs
fn default() -> Self {
Self {
opened: false,
opened_fn: None,
title: String::new(),
size: String::new(),
radius: String::new(),
with_overlay: true,
overlay_opacity: None,
overlay_blur: String::new(),
centered: false,
close_on_click_outside: true,
close_on_escape: true,
with_close_button: true,
padding: String::new(),
z_index: None,
lock_scroll: true,
trap_focus: true,
onclose: None,
}
}class_string function · rust · L181-L206 (26 LOC)crates/rinch-components/src/modal.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-modal"];
if !self.size.is_empty() {
if let Ok(size) = self.size.parse::<ModalSize>() {
classes.push(size.class_name());
}
}
if !self.radius.is_empty() {
match self.radius.as_str() {
"xs" => classes.push("rinch-modal--radius-xs"),
"sm" => classes.push("rinch-modal--radius-sm"),
"md" => classes.push("rinch-modal--radius-md"),
"lg" => classes.push("rinch-modal--radius-lg"),
"xl" => classes.push("rinch-modal--radius-xl"),
_ => {}
}
}
if self.centered {
classes.push("rinch-modal--centered");
}
classes.join(" ")
}render function · rust · L210-L328 (119 LOC)crates/rinch-components/src/modal.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
// Determine initial opened state
let is_opened = if let Some(ref opened_fn) = self.opened_fn {
opened_fn()
} else {
self.opened
};
// Build overlay styles
let overlay_style = {
let mut styles = Vec::new();
if let Some(opacity) = self.overlay_opacity {
styles.push(format!("--rinch-modal-overlay-opacity: {}", opacity));
}
if !self.overlay_blur.is_empty() {
styles.push(format!("--rinch-modal-overlay-blur: {}", self.overlay_blur));
}
if styles.is_empty() {
None
} else {
Some(styles.join("; "))
}
};
// Build modal content styles
let content_style = if self.padding.is_empty() {
None
} else {
Some(format!("padding: {}",class_name function · rust · L40-L47 (8 LOC)crates/rinch-components/src/navlink.rs
pub fn class_name(&self) -> &'static str {
match self {
NavLinkVariant::Default => "rinch-navlink--default",
NavLinkVariant::Light => "rinch-navlink--light",
NavLinkVariant::Filled => "rinch-navlink--filled",
NavLinkVariant::Subtle => "rinch-navlink--subtle",
}
}from_str function · rust · L52-L60 (9 LOC)crates/rinch-components/src/navlink.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"default" => Ok(NavLinkVariant::Default),
"light" => Ok(NavLinkVariant::Light),
"filled" => Ok(NavLinkVariant::Filled),
"subtle" => Ok(NavLinkVariant::Subtle),
_ => Err(()),
}
}Repobility · code-quality intelligence platform · https://repobility.com
fmt function · rust · L118-L136 (19 LOC)crates/rinch-components/src/navlink.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("NavLink")
.field("label", &self.label)
.field("description", &self.description)
.field("href", &self.href)
.field("active", &self.active)
.field("active_fn", &self.active_fn.as_ref().map(|_| "<reactive>"))
.field("variant", &self.variant)
.field("color", &self.color)
.field("left_section", &self.left_section)
.field("right_section", &self.right_section)
.field("disabled", &self.disabled)
.field("children_offset", &self.children_offset)
.field("opened", &self.opened)
.field("default_opened", &self.default_opened)
.field("no_wrap", &self.no_wrap)
.field("onclick", &self.onclick.as_ref().map(|_| "<callback>"))
.finish()
}base_class_string function · rust · L141-L161 (21 LOC)crates/rinch-components/src/navlink.rs
fn base_class_string(&self) -> String {
let mut classes = vec!["rinch-navlink"];
if !self.variant.is_empty() {
if let Ok(variant) = self.variant.parse::<NavLinkVariant>() {
classes.push(variant.class_name());
}
} else {
classes.push(NavLinkVariant::Default.class_name());
}
if self.disabled {
classes.push("rinch-navlink--disabled");
}
if self.no_wrap {
classes.push("rinch-navlink--no-wrap");
}
classes.join(" ")
}class_string function · rust · L164-L170 (7 LOC)crates/rinch-components/src/navlink.rs
pub fn class_string(&self) -> String {
let mut class = self.base_class_string();
if self.active {
class.push_str(" rinch-navlink--active");
}
class
}class_name function · rust · L43-L52 (10 LOC)crates/rinch-components/src/notification.rs
pub fn class_name(&self) -> &'static str {
match self {
NotificationPosition::TopLeft => "rinch-notification--top-left",
NotificationPosition::TopCenter => "rinch-notification--top-center",
NotificationPosition::TopRight => "rinch-notification--top-right",
NotificationPosition::BottomLeft => "rinch-notification--bottom-left",
NotificationPosition::BottomCenter => "rinch-notification--bottom-center",
NotificationPosition::BottomRight => "rinch-notification--bottom-right",
}
}from_str function · rust · L57-L67 (11 LOC)crates/rinch-components/src/notification.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().replace('-', "_").as_str() {
"top_left" | "topleft" => Ok(NotificationPosition::TopLeft),
"top_center" | "topcenter" => Ok(NotificationPosition::TopCenter),
"top_right" | "topright" => Ok(NotificationPosition::TopRight),
"bottom_left" | "bottomleft" => Ok(NotificationPosition::BottomLeft),
"bottom_center" | "bottomcenter" => Ok(NotificationPosition::BottomCenter),
"bottom_right" | "bottomright" => Ok(NotificationPosition::BottomRight),
_ => Err(()),
}
}fmt function · rust · L124-L140 (17 LOC)crates/rinch-components/src/notification.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Notification")
.field("opened", &self.opened)
.field("opened_fn", &self.opened_fn.as_ref().map(|_| "<reactive>"))
.field("title", &self.title)
.field("color", &self.color)
.field("position", &self.position)
.field("radius", &self.radius)
.field("with_close_button", &self.with_close_button)
.field("with_border", &self.with_border)
.field("icon", &self.icon)
.field("auto_close", &self.auto_close)
.field("loading", &self.loading)
.field("z_index", &self.z_index)
.field("onclose", &self.onclose.as_ref().map(|_| "<callback>"))
.finish()
}default function · rust · L144-L160 (17 LOC)crates/rinch-components/src/notification.rs
fn default() -> Self {
Self {
opened: false,
opened_fn: None,
title: String::new(),
color: String::new(),
position: String::new(),
radius: String::new(),
with_close_button: true,
with_border: false,
icon: None,
auto_close: 0,
loading: false,
z_index: None,
onclose: None,
}
}class_string function · rust · L164-L195 (32 LOC)crates/rinch-components/src/notification.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-notification"];
if !self.position.is_empty() {
if let Ok(pos) = self.position.parse::<NotificationPosition>() {
classes.push(pos.class_name());
}
} else {
classes.push(NotificationPosition::TopRight.class_name());
}
if !self.radius.is_empty() {
match self.radius.as_str() {
"xs" => classes.push("rinch-notification--radius-xs"),
"sm" => classes.push("rinch-notification--radius-sm"),
"md" => classes.push("rinch-notification--radius-md"),
"lg" => classes.push("rinch-notification--radius-lg"),
"xl" => classes.push("rinch-notification--radius-xl"),
_ => {}
}
}
if self.with_border {
classes.push("rinch-notification--with-border");
}
if self.loading {
claGenerated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
render function · rust · L199-L307 (109 LOC)crates/rinch-components/src/notification.rs
fn render(&self, __scope: &mut RenderScope, children: &[NodeHandle]) -> NodeHandle {
// Determine initial opened state
let is_opened = if let Some(ref opened_fn) = self.opened_fn {
opened_fn()
} else {
self.opened
};
// Color style
let color_style = if self.color.is_empty() {
None
} else {
let c = &self.color;
if c.starts_with('#') || c.starts_with("rgb") || c.starts_with("hsl") {
Some(format!("--rinch-notification-color: {}", c))
} else {
Some(format!(
"--rinch-notification-color: var(--rinch-color-{}-6)",
c
))
}
};
// Close handler
let close_handler_id = self.onclose.as_ref().map(|cb| {
__scope.register_handler({
let cb = cb.clone();
move || cb.invoke()
})
});
class_name function · rust · L21-L29 (9 LOC)crates/rinch-components/src/number_input.rs
pub fn class_name(&self) -> &'static str {
match self {
NumberInputSize::Xs => "rinch-number-input--xs",
NumberInputSize::Sm => "rinch-number-input--sm",
NumberInputSize::Md => "rinch-number-input--md",
NumberInputSize::Lg => "rinch-number-input--lg",
NumberInputSize::Xl => "rinch-number-input--xl",
}
}from_str function · rust · L34-L44 (11 LOC)crates/rinch-components/src/number_input.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"xs" => Ok(NumberInputSize::Xs),
"sm" => Ok(NumberInputSize::Sm),
"md" => Ok(NumberInputSize::Md),
"lg" => Ok(NumberInputSize::Lg),
"xl" => Ok(NumberInputSize::Xl),
_ => Err(()),
}
}fmt function · rust · L104-L133 (30 LOC)crates/rinch-components/src/number_input.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("NumberInput")
.field("label", &self.label)
.field("description", &self.description)
.field("error", &self.error)
.field("placeholder", &self.placeholder)
.field("value", &self.value)
.field("default_value", &self.default_value)
.field("min", &self.min)
.field("max", &self.max)
.field("step", &self.step)
.field("decimal_scale", &self.decimal_scale)
.field("prefix", &self.prefix)
.field("suffix", &self.suffix)
.field("disabled", &self.disabled)
.field("hide_controls", &self.hide_controls)
.field("required", &self.required)
.field("size", &self.size)
.field("radius", &self.radius)
.field(
"onincrement",
&self.onincrement.as_ref().map(|_| "<callback>"class_string function · rust · L138-L160 (23 LOC)crates/rinch-components/src/number_input.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-number-input"];
// Size class
let size: NumberInputSize = if self.size.is_empty() {
NumberInputSize::default()
} else {
self.size.parse().unwrap_or_default()
};
classes.push(size.class_name());
if !self.error.is_empty() {
classes.push("rinch-number-input--error");
}
if self.disabled {
classes.push("rinch-number-input--disabled");
}
if self.hide_controls {
classes.push("rinch-number-input--no-controls");
}
classes.join(" ")
}render function · rust · L164-L306 (143 LOC)crates/rinch-components/src/number_input.rs
fn render(&self, __scope: &mut RenderScope, _children: &[NodeHandle]) -> NodeHandle {
let container = rinch_macros::rsx! { div { class: "rinch-number-input" } };
container.set_attribute("class", &self.class_string());
// Label
if !self.label.is_empty() {
let label_text = &self.label;
let required_mark = if self.required { " *" } else { "" };
let label = rinch_macros::rsx! { label { class: "rinch-number-input__label" } };
let label_text_node = __scope.create_text(&format!("{}{}", label_text, required_mark));
label.append_child(&label_text_node);
container.append_child(&label);
}
// Description
if !self.description.is_empty() {
let desc = &self.description;
let desc_div = rinch_macros::rsx! { div { class: "rinch-number-input__description" } };
let desc_text = __scope.create_text(desc);
desc_div.append_child(&class_name function · rust · L20-L28 (9 LOC)crates/rinch-components/src/pagination.rs
pub fn class_name(&self) -> &'static str {
match self {
PaginationSize::Xs => "rinch-pagination--xs",
PaginationSize::Sm => "rinch-pagination--sm",
PaginationSize::Md => "rinch-pagination--md",
PaginationSize::Lg => "rinch-pagination--lg",
PaginationSize::Xl => "rinch-pagination--xl",
}
}from_str function · rust · L33-L42 (10 LOC)crates/rinch-components/src/pagination.rs
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"xs" => Ok(PaginationSize::Xs),
"sm" => Ok(PaginationSize::Sm),
"md" => Ok(PaginationSize::Md),
"lg" => Ok(PaginationSize::Lg),
"xl" => Ok(PaginationSize::Xl),
_ => Err(()),
}
}Repobility · open methodology · https://repobility.com/research/
default function · rust · L88-L103 (16 LOC)crates/rinch-components/src/pagination.rs
fn default() -> Self {
Self {
total: 1,
value: 1,
siblings: 1,
boundaries: 1,
size: String::new(),
radius: String::new(),
with_edges: false,
with_controls: true,
color: String::new(),
disabled: false,
gap: String::new(),
onchange: None,
}
}class_string function · rust · L107-L132 (26 LOC)crates/rinch-components/src/pagination.rs
pub fn class_string(&self) -> String {
let mut classes = vec!["rinch-pagination"];
if !self.size.is_empty()
&& let Ok(size) = self.size.parse::<PaginationSize>()
{
classes.push(size.class_name());
}
if !self.radius.is_empty() {
match self.radius.as_str() {
"xs" => classes.push("rinch-pagination--radius-xs"),
"sm" => classes.push("rinch-pagination--radius-sm"),
"md" => classes.push("rinch-pagination--radius-md"),
"lg" => classes.push("rinch-pagination--radius-lg"),
"xl" => classes.push("rinch-pagination--radius-xl"),
_ => {}
}
}
if self.disabled {
classes.push("rinch-pagination--disabled");
}
classes.join(" ")
}generate_pages function · rust · L133-L206 (74 LOC)crates/rinch-components/src/pagination.rs
fn generate_pages(&self) -> Vec<PageItem> {
let total = self.total.max(1);
let current = self.value.clamp(1, total);
let siblings = self.siblings;
let boundaries = self.boundaries;
let mut pages = Vec::new();
// Calculate range
let left_siblings = (current as i32 - siblings as i32).max(boundaries as i32 + 2);
let right_siblings =
(current as i32 + siblings as i32).min(total as i32 - boundaries as i32 - 1);
let show_left_dots = left_siblings > (boundaries as i32 + 2);
let show_right_dots = right_siblings < (total as i32 - boundaries as i32 - 1);
// Left boundary pages
for i in 1..=boundaries.min(total) {
pages.push(PageItem::Page(i));
}
// Left dots
if show_left_dots {
pages.push(PageItem::Dots);
} else if boundaries + 1 < left_siblings as u32 {
for i in (boundaries + 1)..(left_siblings as u32) {