From c85a44cc8dfbbe607a3036c9c3e5d58ff6be64ca Mon Sep 17 00:00:00 2001 From: igor Date: Sun, 25 Aug 2024 08:16:30 +0200 Subject: [PATCH] wip --- .github/workflows/cd.yaml | 53 +++++++++++++++++++++++++++++++++++++ assets/livecode.css | 3 ++- assets/main.css | 3 +++ src/components/browser.rs | 4 +-- src/components/live_code.rs | 4 +-- src/index.html | 18 ------------- src/index_print.html | 48 +++++++++++++++++++++++++++++++++ src/main.rs | 10 +++++-- src/talk/dioxus_wc.rs | 18 ++++++++++++- src/talk/rust_wc.rs | 2 +- src/talk/vanilla_wc.rs | 2 +- 11 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/cd.yaml delete mode 100644 src/index.html create mode 100644 src/index_print.html diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..07e036f --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,53 @@ +name: CD + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build-deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: "true" + save-if: ${{ github.ref == 'refs/heads/main' }} + - uses: cargo-bins/cargo-binstall@main + - name: Install CLI + run: cargo binstall dioxus-cli -y --force + + - name: ⚙️ Build + run: dx build --release --features print + - name: Custom HTML page + run: cp src/index_print.html dist/index.html + - run: cat dist/index.html + + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'dist' + - name: 🚀 Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/assets/livecode.css b/assets/livecode.css index f8bb3e5..e277804 100644 --- a/assets/livecode.css +++ b/assets/livecode.css @@ -76,7 +76,8 @@ .title { text-align: center; - font-weight: 600; + font-weight: bold; + font-family: var(--pico-font-family-monospace); } } diff --git a/assets/main.css b/assets/main.css index ac6c8ae..2b1e98e 100644 --- a/assets/main.css +++ b/assets/main.css @@ -201,6 +201,9 @@ body { } /* More style */ +code { + padding: .125em .25em; +} dl dt { font-weight: bold; diff --git a/src/components/browser.rs b/src/components/browser.rs index 71b7e60..1fda87f 100644 --- a/src/components/browser.rs +++ b/src/components/browser.rs @@ -3,9 +3,9 @@ use dioxus::prelude::*; use crate::Window; #[component] -pub fn Browser(url: String) -> Element { +pub fn Browser(url: String, tools: Element) -> Element { rsx! { - Window { title: "🦊 {url}", tools: None, + Window { title: "🦊 {url}", tools, iframe { class: "browser", src: "{url}" } } } diff --git a/src/components/live_code.rs b/src/components/live_code.rs index a10bb36..87f61c2 100644 --- a/src/components/live_code.rs +++ b/src/components/live_code.rs @@ -3,10 +3,10 @@ use dioxus::prelude::*; use crate::{Browser, Terminal}; #[component] -pub fn LiveCode(url: String, workdir: Option) -> Element { +pub fn LiveCode(url: String, workdir: Option, tools: Element) -> Element { rsx! { div { class: "live-code", - Browser { url } + Browser { url, tools } Terminal { workdir } } } diff --git a/src/index.html b/src/index.html deleted file mode 100644 index 6baf66a..0000000 --- a/src/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - {app_title} - - - - - - - -
- - diff --git a/src/index_print.html b/src/index_print.html new file mode 100644 index 0000000..75b756d --- /dev/null +++ b/src/index_print.html @@ -0,0 +1,48 @@ + + + + + + + + + + + Et si on écrivait nos Web Components en Rust ? + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 235e088..09db631 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,14 @@ use dioxus::launch; use dioxus_logger::tracing::Level; -use slides_jug_summer_camp_24::App; +use slides_jug_summer_camp_24::App; fn main() { - dioxus_logger::init(Level::DEBUG).expect("failed to init logger"); + let level = if cfg!(debug_assertions) { + Level::DEBUG + } else { + Level::INFO + }; + dioxus_logger::init(level).expect("failed to init logger"); + launch(App); } diff --git a/src/talk/dioxus_wc.rs b/src/talk/dioxus_wc.rs index 6c4729e..fca95d1 100644 --- a/src/talk/dioxus_wc.rs +++ b/src/talk/dioxus_wc.rs @@ -85,9 +85,25 @@ pub(super) fn slides() -> Element { fn code() -> Element { use crate::{LiveCode, SlideKind}; + let mut port = use_signal(|| 5173_u16); + + let toggle_port = move |_| { + let new_port = if port() == 5173 { 8080 } else { 5173 }; + port.set(new_port); + }; + + let tools = rsx! { + input { + r#type: "checkbox", + role: "switch", + font_size: "100%", + oninput: toggle_port + } + }; + rsx! { Slide { id: 0x42.into(), kind: SlideKind::Full, title: "Dioxus - livecode", - LiveCode { url: "http://localhost:5173", workdir: "jug-summer-camp-24" } + LiveCode { url: "http://localhost:{port}", tools } } } } diff --git a/src/talk/rust_wc.rs b/src/talk/rust_wc.rs index 605d3a9..c02853f 100644 --- a/src/talk/rust_wc.rs +++ b/src/talk/rust_wc.rs @@ -151,7 +151,7 @@ fn code() -> Element { rsx! { Slide { id: 0x34.into(), kind: SlideKind::Full, title: "Rust - livecode", - LiveCode { url: "http://localhost:5173", workdir: "jug-summer-camp-24" } + LiveCode { url: "http://localhost:5173", tools: None } } } } diff --git a/src/talk/vanilla_wc.rs b/src/talk/vanilla_wc.rs index c0fdb3b..1b32396 100644 --- a/src/talk/vanilla_wc.rs +++ b/src/talk/vanilla_wc.rs @@ -121,7 +121,7 @@ fn code() -> Element { rsx! { Slide { id: 0x22.into(), kind: SlideKind::Full, title: "Natif - livecode", - LiveCode { url: "http://localhost:5173", workdir: "jug-summer-camp-24" } + LiveCode { url: "http://localhost:5173", tools: None } } } }