This commit is contained in:
Robin Appelman 2023-11-24 22:42:25 +01:00
commit 189788a1b6
14 changed files with 599 additions and 6 deletions

53
src/pages/edit.rs Normal file
View file

@ -0,0 +1,53 @@
use crate::pages::Page;
use demostf_build::Asset;
use maud::{html, Markup};
use std::borrow::Cow;
pub struct EditorPage;
#[derive(Asset)]
#[asset(source = "script/editor.tsx", url = "/editor.js")]
pub struct EditorScript;
#[derive(Asset)]
#[asset(source = "script/edit/EditWorker.ts", url = "/edit-worker.js")]
pub struct EditWorkerScript;
#[derive(Asset)]
#[asset(source = "style/pages/editor.css", url = "/editor.css")]
pub struct EditorStyle;
#[derive(Asset)]
#[asset(
source = "node_modules/@demostf/edit/edit_bg.wasm",
url = "/tf-demo-editor.wasm"
)]
pub struct EditWasm;
impl Page for EditorPage {
fn title(&self) -> Cow<'static, str> {
"Edit - demos.tf".into()
}
fn render(&self) -> Markup {
let script = EditorScript::url();
let style_url = EditorStyle::url();
html! {
.edit-page {
p.page-note {
"To edit a demo, select a file on your computer, select the desired options and press the \"edit\" button."
}
.dropzone role = "button" {
noscript {
"Javascript is required to view a demo."
}
span.text { "Drop files or click to view" }
input type = "file" {}
}
.placeholder {}
}
script module src = (script) type = "text/javascript" {}
link rel="stylesheet" type="text/css" href=(style_url);
}
}
}

View file

@ -1,6 +1,7 @@
pub mod about;
pub mod api;
pub mod demo;
pub mod edit;
pub mod index;
mod plugin_section;
pub mod profile;