2023-10-22 22:48:17 +08:00
|
|
|
use crate::components::{Demo, DemoCode};
|
|
|
|
use leptos::*;
|
|
|
|
use prisms::highlight_str;
|
2023-11-16 10:26:32 +08:00
|
|
|
use thaw::*;
|
2023-10-22 22:48:17 +08:00
|
|
|
|
|
|
|
#[component]
|
|
|
|
pub fn UploadPage() -> impl IntoView {
|
2023-10-26 11:17:27 +08:00
|
|
|
let message = use_message();
|
|
|
|
let custom_request = move |file_list: FileList| {
|
|
|
|
message.create(
|
|
|
|
format!("Number of uploaded files: {}", file_list.length()),
|
|
|
|
MessageVariant::Success,
|
|
|
|
Default::default(),
|
|
|
|
);
|
|
|
|
};
|
2023-10-22 22:48:17 +08:00
|
|
|
view! {
|
|
|
|
<div style="width: 896px; margin: 0 auto;">
|
2023-10-26 11:17:27 +08:00
|
|
|
<h1>"Upload"</h1>
|
2023-10-22 22:48:17 +08:00
|
|
|
<Demo>
|
2023-10-26 11:17:27 +08:00
|
|
|
<Upload custom_request>
|
2023-10-22 22:48:17 +08:00
|
|
|
<Button>
|
2023-10-26 11:17:27 +08:00
|
|
|
"Upload"
|
2023-10-22 22:48:17 +08:00
|
|
|
</Button>
|
|
|
|
</Upload>
|
2023-10-26 11:17:27 +08:00
|
|
|
<DemoCode
|
|
|
|
slot
|
|
|
|
html=highlight_str!(
|
|
|
|
r#"
|
|
|
|
let message = use_message();
|
|
|
|
let custom_request = move |file_list: FileList| {
|
|
|
|
message.create(
|
|
|
|
format!("Number of uploaded files: {}", file_list.length()),
|
|
|
|
MessageVariant::Success,
|
|
|
|
Default::default(),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
view!{
|
|
|
|
<Upload>
|
|
|
|
<Button>
|
|
|
|
"upload"
|
|
|
|
</Button>
|
|
|
|
</Upload>
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
"rust"
|
|
|
|
)
|
|
|
|
>
|
|
|
|
|
|
|
|
""
|
|
|
|
</DemoCode>
|
|
|
|
</Demo>
|
|
|
|
<h3>"Drag to upload"</h3>
|
|
|
|
<Demo>
|
2023-11-05 20:10:21 +08:00
|
|
|
<Upload custom_request>
|
2023-10-26 11:17:27 +08:00
|
|
|
<UploadDragger>
|
|
|
|
"Click or drag a file to this area to upload"
|
|
|
|
</UploadDragger>
|
|
|
|
</Upload>
|
2023-10-22 22:48:17 +08:00
|
|
|
<DemoCode
|
|
|
|
slot
|
|
|
|
html=highlight_str!(
|
|
|
|
r#"
|
2023-11-05 20:10:21 +08:00
|
|
|
let message = use_message();
|
|
|
|
let custom_request = move |file_list: FileList| {
|
|
|
|
message.create(
|
|
|
|
format!("Number of uploaded files: {}", file_list.length()),
|
|
|
|
MessageVariant::Success,
|
|
|
|
Default::default(),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
view! {
|
|
|
|
<Upload custom_request>
|
|
|
|
<UploadDragger>
|
|
|
|
"Click or drag a file to this area to upload"
|
|
|
|
</UploadDragger>
|
|
|
|
</Upload>
|
|
|
|
}
|
2023-10-22 22:48:17 +08:00
|
|
|
"#,
|
|
|
|
"rust"
|
|
|
|
)
|
|
|
|
>
|
|
|
|
|
|
|
|
""
|
|
|
|
</DemoCode>
|
|
|
|
</Demo>
|
2023-11-16 10:26:32 +08:00
|
|
|
<h3>"Upload Props"</h3>
|
|
|
|
<Table single_column=true>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>"Name"</th>
|
|
|
|
<th>"Type"</th>
|
|
|
|
<th>"Default"</th>
|
|
|
|
<th>"Description"</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>"accept"</td>
|
|
|
|
<td>"MaybeSignal<String>"</td>
|
|
|
|
<td>r#""""#</td>
|
|
|
|
<td>"The accept type of upload."</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>"multiple"</td>
|
|
|
|
<td>"MaybeSignal<bool>"</td>
|
|
|
|
<td>"false"</td>
|
|
|
|
<td>"Allow multiple files to be selected."</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>"custom_request"</td>
|
|
|
|
<td>"Option<Callback<FileList, ()>>"</td>
|
|
|
|
<td>r#""""#</td>
|
|
|
|
<td>"Customize upload request."</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>"children"</td>
|
|
|
|
<td>"Children"</td>
|
|
|
|
<td></td>
|
|
|
|
<td>"Upload's content."</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</Table>
|
|
|
|
<h3>"UploadDragger Props"</h3>
|
|
|
|
<Table single_column=true>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>"Name"</th>
|
|
|
|
<th>"Type"</th>
|
|
|
|
<th>"Default"</th>
|
|
|
|
<th>"Description"</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>"children"</td>
|
|
|
|
<td>"Children"</td>
|
|
|
|
<td></td>
|
|
|
|
<td>"UploadDragger's content."</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</Table>
|
2023-10-22 22:48:17 +08:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|