Added iframe html element
This commit is contained in:
@@ -390,3 +390,115 @@ impl AnchorBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Iframe {
|
||||||
|
id: String,
|
||||||
|
classes: Vec<String>,
|
||||||
|
src: String,
|
||||||
|
title: String,
|
||||||
|
width: usize,
|
||||||
|
height: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Render for Iframe {
|
||||||
|
fn render(&self) -> String {
|
||||||
|
let classes = self.classes.join(" ");
|
||||||
|
format!(
|
||||||
|
"<iframe id=\"{}\" classes=\"{}\" title=\"{}\" width=\"{}\" height=\"{}\" src=\"{}\"></iframe>",
|
||||||
|
self.id, classes, self.title, self.width, self.height, self.src
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct IframeBuilder {
|
||||||
|
id: Option<String>,
|
||||||
|
classes: Option<Vec<String>>,
|
||||||
|
src: Option<String>,
|
||||||
|
title: Option<String>,
|
||||||
|
width: Option<usize>,
|
||||||
|
height: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IframeBuilder {
|
||||||
|
pub(crate) fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
id: None,
|
||||||
|
classes: None,
|
||||||
|
src: None,
|
||||||
|
title: None,
|
||||||
|
width: None,
|
||||||
|
height: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn id<T>(self, id: T) -> Self
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
id: Some(id.into()),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn classes<T>(self, classes: Vec<T>) -> Self
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
classes: Some(classes.into_iter().map(|x| x.into()).collect()),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn src<T>(self, src: T) -> Self
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
src: Some(src.into()),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn title<T>(self, title: T) -> Self
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
title: Some(title.into()),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn width(self, width: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
width: Some(width),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn height(self, height: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
height: Some(height),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn build(self) -> Iframe {
|
||||||
|
let id = self.id.unwrap_or(String::new());
|
||||||
|
let classes = self.classes.unwrap_or(Vec::new());
|
||||||
|
let title = self.title.unwrap_or(String::new());
|
||||||
|
let width = self.width.unwrap_or(0);
|
||||||
|
let height = self.height.unwrap_or(0);
|
||||||
|
let src = self.src.unwrap_or(String::new());
|
||||||
|
Iframe {
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
classes,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
src,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user