39 lines
853 B
Rust
39 lines
853 B
Rust
#[derive(Debug, Default)]
|
|
pub struct Card {
|
|
pub(crate) full_width: bool,
|
|
pub(crate) classes: Vec<String>,
|
|
}
|
|
|
|
impl Card {
|
|
pub fn new() -> Self {
|
|
Default::default()
|
|
}
|
|
|
|
pub fn full_width() -> Self {
|
|
Card {
|
|
full_width: true,
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
pub fn centered(&mut self) -> &mut Self {
|
|
self.classes.push("toolkit-centered".to_owned());
|
|
self
|
|
}
|
|
|
|
pub fn classes(&mut self, classes: &[&str]) -> &mut Self {
|
|
self.classes = classes.into_iter().map(|s| s.to_string()).collect();
|
|
self
|
|
}
|
|
|
|
pub(crate) fn class_string(&self) -> String {
|
|
let classes = self.classes.join(" ");
|
|
|
|
if self.full_width {
|
|
return classes + " toolkit-card toolkit-card__full-width";
|
|
}
|
|
|
|
classes + " toolkit-card"
|
|
}
|
|
}
|