Serve the demo artwork in each build (#1494)

* Serve local demo artwork

* Disable restricted import lint

* Revert

* Switch approach to vite-multiple-assets plugin

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-12-11 09:06:00 +00:00
committed by GitHub
parent b60736c2c6
commit af4c793f43
7 changed files with 85 additions and 22 deletions

View File

@@ -4,17 +4,10 @@ use crate::messages::prelude::*;
/// A dialog to let the user browse a gallery of demo artwork that can be opened.
pub struct DemoArtworkDialog;
/// `(name, thumbnail, filename)`
const ARTWORK: [(&str, &str, &str); 2] = [
(
"Valley of Spires",
"ThumbnailValleyOfSpires",
"https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/valley-of-spires-v2.graphite",
),
(
"Just a Potted Cactus",
"ThumbnailJustAPottedCactus",
"https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/just-a-potted-cactus-v2.graphite",
),
("Valley of Spires", "ThumbnailValleyOfSpires", "valley-of-spires-v2.graphite"),
("Just a Potted Cactus", "ThumbnailJustAPottedCactus", "just-a-potted-cactus-v2.graphite"),
];
impl DialogLayoutHolder for DemoArtworkDialog {
@@ -37,12 +30,16 @@ impl LayoutHolder for DemoArtworkDialog {
let buttons = ARTWORK
.into_iter()
.map(|(label, _, url)| {
TextButton::new(label)
.map(|(name, _, filename)| {
TextButton::new(name)
.min_width(256)
.on_update(|_| {
DialogMessage::CloseDialogAndThen {
followups: vec![FrontendMessage::TriggerFetchAndOpenDocument { url: url.to_string() }.into()],
followups: vec![FrontendMessage::TriggerFetchAndOpenDocument {
name: name.to_string(),
filename: filename.to_string(),
}
.into()],
}
.into()
})

View File

@@ -67,7 +67,8 @@ pub enum FrontendMessage {
name: String,
},
TriggerFetchAndOpenDocument {
url: String,
name: String,
filename: String,
},
TriggerFontLoad {
font: Font,