Skip to content

Commit

Permalink
better footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Kharel committed May 7, 2024
1 parent 369123f commit ec21365
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
30 changes: 30 additions & 0 deletions src/custom_widgets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pub fn powered_by_egui_and_eframe(ui: &mut egui::Ui) {
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("Powered by ");
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
ui.label(", ");
ui.hyperlink_to(
"eframe",
"https://github.com/emilk/egui/tree/master/crates/eframe",
);
ui.label(", ");
ui.hyperlink_to("cloudflare", "https://cloudflare.com");
ui.label(" and ");
ui.hyperlink_to("github pages", "https://pages.github.com/");

ui.label(".");
});
egui::warn_if_debug_build(ui);
});
}

pub fn footer(ui: &mut egui::Ui) {
ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| {
ui.horizontal(|ui| {
ui.label("© Ruben Kharel, 2024");
});
});
}

3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pub use pages::*;
mod wrap_pages;
pub use wrap_pages::WrapPages;

mod custom_widgets;
pub use custom_widgets::*;

#[cfg(target_arch = "wasm32")]
mod web;

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ fn main() {
.await
.expect("failed to start eframe");
});
}
}
10 changes: 4 additions & 6 deletions src/pages/blog.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
use include_dir::{include_dir, Dir};

use crate::custom_widgets::{powered_by_egui_and_eframe, footer};

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Blogs {
pub all_blogs: Vec<Blog>,
Expand Down Expand Up @@ -130,13 +132,9 @@ impl eframe::App for BlogPage {

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
egui::CollapsingHeader::new("Info").show(ui, |ui| {
ui.heading(format!(
"Blog Count: {}",
&self.blogs.all_blogs.len().to_string()
));
});
footer(ui);

powered_by_egui_and_eframe(ui);
// let mut cache = CommonMarkCache::default();
for blog in &mut self.blogs.all_blogs {
egui::Window::new(blog.title.clone())
Expand Down
8 changes: 6 additions & 2 deletions src/pages/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mod interests;
pub use self::links::Links;
mod links;

pub use crate::custom_widgets::powered_by_egui_and_eframe;

#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct Resume {
header: Header,
Expand Down Expand Up @@ -173,9 +175,11 @@ impl eframe::App for ResumePage {
}

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |_ui| {
// insert everything inside drag and drop

egui::CentralPanel::default().show(ctx, |ui| {
powered_by_egui_and_eframe(ui);
// insert everything inside drag and drop

egui::Window::new(format!(
"{} | {}",
self.resume.header.name, self.resume.header.current_title
Expand Down
1 change: 1 addition & 0 deletions src/wrap_pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct WrapPages {
}

impl WrapPages {

pub fn new(_cc: &eframe::CreationContext<'_>) -> Self {
#[allow(unused_mut)]
let mut slf = Self {
Expand Down

0 comments on commit ec21365

Please sign in to comment.