use yew::prelude::*;
pub enum Msg {}
pub struct FileAssets {
pub props: Props,
}
#[derive(Clone, Properties)]
pub struct Props {
pub icon: FileIcon,
#[prop_or(("24".to_string(),"24".to_string()))]
pub size: (String, String),
#[prop_or(("0".to_string(),"0".to_string(),"24".to_string(),"24".to_string()))]
pub view_box: (String, String, String, String),
#[prop_or("none".to_string())]
pub fill: String,
#[prop_or_default]
pub class_name: String,
#[prop_or_default]
pub id: String,
}
impl Component for FileAssets {
type Properties = Props;
type Message = Msg;
fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self {
Self { props }
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
false
}
fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.props = props;
true
}
fn view(&self) -> Html {
get_icon(
self.props.icon.clone(),
self.props.size.clone(),
self.props.view_box.clone(),
self.props.fill.clone(),
self.props.class_name.clone(),
self.props.id.clone(),
)
}
}
#[derive(Clone)]
pub enum FileIcon {
FileMinus,
Image,
FileText,
FilePlus,
File,
FolderMinus,
FolderPlus,
Folder,
}
fn get_icon(
icon: FileIcon,
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
match icon {
FileIcon::FileMinus => get_fileminus(size, view_box, fill, class_name, id),
FileIcon::Image => get_image(size, view_box, fill, class_name, id),
FileIcon::FileText => get_filetext(size, view_box, fill, class_name, id),
FileIcon::FilePlus => get_fileplus(size, view_box, fill, class_name, id),
FileIcon::File => get_file(size, view_box, fill, class_name, id),
FileIcon::FolderMinus => get_folderminus(size, view_box, fill, class_name, id),
FileIcon::FolderPlus => get_folderplus(size, view_box, fill, class_name, id),
FileIcon::Folder => get_folder(size, view_box, fill, class_name, id),
}
}
fn get_fileminus(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="9" y1="15" x2="15" y2="15"></line></svg>
}
}
fn get_image(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
}
}
fn get_filetext(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
}
}
fn get_fileplus(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="12" y1="18" x2="12" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line></svg>
}
}
fn get_file(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline></svg>
}
}
fn get_folderminus(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path><line x1="9" y1="14" x2="15" y2="14"></line></svg>
}
}
fn get_folderplus(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path><line x1="12" y1="11" x2="12" y2="17"></line><line x1="9" y1="14" x2="15" y2="14"></line></svg>
}
}
fn get_folder(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.0,
view_box.1,
view_box.2,
view_box.3,
) fill=fill id=id stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=class_name><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>
}
}