Skip to content

Commit

Permalink
💻(App): load code based on selected sample
Browse files Browse the repository at this point in the history
Adds a check to load the `code` field from `SAMPLE_CODES_LIST` if `selected_sample` is not empty, ensuring the correct sample code is displayed.

Signed-off-by: Benign X <[email protected]>
  • Loading branch information
W-Mai committed Nov 21, 2024
1 parent 11f0476 commit bb35a33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vegravis"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
homepage = "https://w-mai.github.io/vegravis"
repository = "https://github.com/W-Mai/vegravis"
Expand Down
11 changes: 11 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ impl eframe::App for MainApp {
self.is_loaded_from_url = true;
}

if !self.selected_sample.is_empty() {
self.code = AnyData::new(
SAMPLE_CODES_LIST
.iter()
.find(|x| x.0 == self.selected_sample)
.unwrap()
.1
.to_owned(),
)
}

egui::TopBottomPanel::top("top").show(ctx, |ui| {
self.ui_about(ui);
});
Expand Down

0 comments on commit bb35a33

Please sign in to comment.