Skip to content

Commit

Permalink
make iframe browser more realistic
Browse files Browse the repository at this point in the history
  • Loading branch information
noxware committed Mar 7, 2024
1 parent ef4ff49 commit 757f732
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions examples/demo/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use hframe::Aware;

const IFRAME: &str = r#"
<iframe src="https://www.example.com/"></iframe>
const IFRAME_TEMPLATE: &str = r#"
<iframe src="{src}"></iframe>
"#;

const IFRAME_INITIAL_URL: &str = "https://www.example.com/";

const VIDEO: &str = r#"
<video controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
Expand All @@ -25,6 +27,8 @@ const COUNTER_TEMPLATE: &str = r#"
#[derive(Default)]
pub struct App {
counter_open: bool,
iframe_current_url: String,
iframe_url_input: String,
iframe_open: bool,
yt_open: bool,
count: i32,
Expand All @@ -43,6 +47,8 @@ impl App {
Self {
video_open: true,
counter_open: true,
iframe_current_url: IFRAME_INITIAL_URL.into(),
iframe_url_input: IFRAME_INITIAL_URL.into(),
iframe_open: true,
yt_open: true,
..Default::default()
Expand Down Expand Up @@ -103,7 +109,16 @@ impl eframe::App for App {
egui::Window::new("Iframe Browser")
.open(&mut self.iframe_open)
.show(ctx, |ui| {
ui.add(hframe::BareHtml::new("iframe_browser").content(IFRAME));
ui.horizontal(|ui| {
ui.text_edit_singleline(&mut self.iframe_url_input);
if ui.button("Go").clicked() {
self.iframe_current_url = self.iframe_url_input.clone();
}
});
ui.add(
hframe::BareHtml::new("iframe_browser")
.content(&IFRAME_TEMPLATE.replace("{src}", &self.iframe_current_url)),
);
})
.aware();

Expand Down

0 comments on commit 757f732

Please sign in to comment.