mirror of
https://github.com/adoyle0/thaw.git
synced 2025-03-13 05:59:49 -04:00
feat: add upload component
This commit is contained in:
parent
16f8ba13c3
commit
0f0fde49a3
7 changed files with 90 additions and 0 deletions
|
@ -40,6 +40,7 @@ pub fn App() -> impl IntoView {
|
|||
<Route path="/skeleton" view=SkeletonPage/>
|
||||
<Route path="/switch" view=SwitchPage/>
|
||||
<Route path="/tag" view=TagPage/>
|
||||
<Route path="/upload" view=UploadPage/>
|
||||
</Route>
|
||||
<Route path="/mobile/tabbar" view=TabbarDemoPage/>
|
||||
<Route path="/mobile/nav-bar" view=NavBarDemoPage/>
|
||||
|
|
|
@ -145,6 +145,10 @@ fn gen_menu_data() -> Vec<MenuGroupOption> {
|
|||
value: "switch".into(),
|
||||
label: "Switch".into(),
|
||||
},
|
||||
MenuItemOption {
|
||||
value: "upload".into(),
|
||||
label: "Upload".into(),
|
||||
},
|
||||
],
|
||||
},
|
||||
MenuGroupOption {
|
||||
|
|
|
@ -30,6 +30,7 @@ mod table;
|
|||
mod tabs;
|
||||
mod tag;
|
||||
mod toast;
|
||||
mod upload;
|
||||
|
||||
pub use alert::*;
|
||||
pub use auto_complete::*;
|
||||
|
@ -63,3 +64,4 @@ pub use table::*;
|
|||
pub use tabs::*;
|
||||
pub use tag::*;
|
||||
pub use toast::*;
|
||||
pub use upload::*;
|
||||
|
|
36
demo/src/pages/upload/mod.rs
Normal file
36
demo/src/pages/upload/mod.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use crate::components::{Demo, DemoCode};
|
||||
use leptos::*;
|
||||
use melt_ui::*;
|
||||
use prisms::highlight_str;
|
||||
|
||||
#[component]
|
||||
pub fn UploadPage() -> impl IntoView {
|
||||
view! {
|
||||
<div style="width: 896px; margin: 0 auto;">
|
||||
<h1>"Upload(TODO)"</h1>
|
||||
<Demo>
|
||||
<Upload>
|
||||
<Button>
|
||||
"upload"
|
||||
</Button>
|
||||
</Upload>
|
||||
<DemoCode
|
||||
slot
|
||||
html=highlight_str!(
|
||||
r#"
|
||||
<Upload>
|
||||
<Button>
|
||||
"upload"
|
||||
</Button>
|
||||
</Upload>
|
||||
"#,
|
||||
"rust"
|
||||
)
|
||||
>
|
||||
|
||||
""
|
||||
</DemoCode>
|
||||
</Demo>
|
||||
</div>
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ mod tabs;
|
|||
mod tag;
|
||||
mod teleport;
|
||||
mod theme;
|
||||
mod upload;
|
||||
mod utils;
|
||||
mod wave;
|
||||
|
||||
|
@ -64,5 +65,6 @@ pub use table::*;
|
|||
pub use tabs::*;
|
||||
pub use tag::*;
|
||||
pub use theme::Theme;
|
||||
pub use upload::*;
|
||||
pub use utils::{mount_style::mount_style, signal::SignalWatch};
|
||||
pub use wave::*;
|
||||
|
|
40
src/upload/mod.rs
Normal file
40
src/upload/mod.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use leptos::*;
|
||||
use crate::mount_style;
|
||||
// TODO
|
||||
|
||||
#[component]
|
||||
pub fn Upload(
|
||||
#[prop(optional, into)] accept: MaybeSignal<String>,
|
||||
#[prop(optional, into)] multiple: MaybeSignal<bool>,
|
||||
children: Children,
|
||||
) -> impl IntoView {
|
||||
mount_style("upload", include_str!("./upload.css"));
|
||||
let on_file_addition = move || {
|
||||
|
||||
};
|
||||
let input_ref = create_node_ref::<html::Input>();
|
||||
let on_change = move |_| {
|
||||
if let Some(input_ref) = input_ref.get_untracked() {
|
||||
}
|
||||
};
|
||||
let on_click= move |_| {
|
||||
if let Some(input_ref) = input_ref.get_untracked() {
|
||||
input_ref.click();
|
||||
}
|
||||
};
|
||||
view! {
|
||||
<div class="melt-upload">
|
||||
<input
|
||||
class="melt-upload__input"
|
||||
ref=input_ref
|
||||
type="file"
|
||||
accept=move || accept.get()
|
||||
multiple=move || multiple.get()
|
||||
on:change=on_change
|
||||
/>
|
||||
<div class="melt-upload__trigger" on:click=on_click>
|
||||
{children()}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
5
src/upload/upload.css
Normal file
5
src/upload/upload.css
Normal file
|
@ -0,0 +1,5 @@
|
|||
.melt-upload__input {
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue