Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ilaborie committed Aug 25, 2024
1 parent 348cd59 commit c85a44c
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 28 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion assets/livecode.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@

.title {
text-align: center;
font-weight: 600;
font-weight: bold;
font-family: var(--pico-font-family-monospace);
}

}
Expand Down
3 changes: 3 additions & 0 deletions assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ body {
}

/* More style */
code {
padding: .125em .25em;
}

dl dt {
font-weight: bold;
Expand Down
4 changes: 2 additions & 2 deletions src/components/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/live_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use dioxus::prelude::*;
use crate::{Browser, Terminal};

#[component]
pub fn LiveCode(url: String, workdir: Option<String>) -> Element {
pub fn LiveCode(url: String, workdir: Option<String>, tools: Element) -> Element {
rsx! {
div { class: "live-code",
Browser { url }
Browser { url, tools }
Terminal { workdir }
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/index.html

This file was deleted.

48 changes: 48 additions & 0 deletions src/index_print.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>

<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8" />

<base href="https://ilaborie.github.io/slides-jug-summer-camp-24/" target="_blank" />

<title>Et si on écrivait nos Web Components en Rust ?</title>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@200..900&family=Mulish:ital,wght@0,200..1000;1,200..1000&family=Quicksand:wght@300..700&display=swap">
<link rel="stylesheet" href="/pico.min.css">
<link rel="stylesheet" href="/pico.colors.min.css">
<link rel="stylesheet" href="/prismjs/prism.css">
<!-- <link rel="stylesheet" href="/xtermjs/xterm.css"> -->
<link rel="stylesheet" href="/main.css">
<!-- <link rel="stylesheet" href="/livecode.css"> -->
<link rel="stylesheet" href="/jugsummercamp.css">
<link rel="stylesheet" href="/print.css">
</head>

<body>
<div id="main"></div>
<script type="module">
import init from "/./assets/dioxus/slides-jug-summer-camp-24.js";
init("/./assets/dioxus/slides-jug-summer-camp-24_bg.wasm").then(wasm => {
if (wasm.__wbindgen_start == undefined) {
wasm.main();
}
});
</script>
<script src="/prismjs/prism.js"></script>
<!-- <script src="/xtermjs/xterm.js"></script> -->
<!-- <script src="/xtermjs/addon-attach.js"></script> -->
<!-- <script src="/xtermjs/addon-clipboard.js"></script> -->
<!-- <script src="/xtermjs/addon-fit.js"></script> -->
<!-- <script src="/xtermjs/addon-ligatures.js"></script> -->
<!-- <script src="/xtermjs/addon-unicode11.js"></script> -->
<!-- <script src="/xtermjs/addon-web-links.js"></script> -->

</body>

</html>
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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);
}
18 changes: 17 additions & 1 deletion src/talk/dioxus_wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/talk/rust_wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/talk/vanilla_wc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
}
Expand Down

0 comments on commit c85a44c

Please sign in to comment.