From a148c2e253a42dc3d5719edd1307fad182584639 Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Fri, 17 Nov 2023 16:11:22 +0100 Subject: [PATCH 1/2] feat: add example for truncate --- Cargo.lock | 7 ++--- Cargo.toml | 6 ++-- src/app/mod.rs | 7 +++-- src/components/mod.rs | 4 ++- src/components/truncate/mod.rs | 32 ++++++++++++++++++++++ src/components/truncate/truncate.1.example | 7 +++++ src/components/truncate/truncate.2.example | 7 +++++ src/components/truncate/truncate.3.example | 7 +++++ src/components/truncate/truncate.4.example | 10 +++++++ 9 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 src/components/truncate/mod.rs create mode 100644 src/components/truncate/truncate.1.example create mode 100644 src/components/truncate/truncate.2.example create mode 100644 src/components/truncate/truncate.3.example create mode 100644 src/components/truncate/truncate.4.example diff --git a/Cargo.lock b/Cargo.lock index 91f874d..65d7cc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -814,9 +814,8 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "patternfly-yew" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd262727f48be6b92a924fab966bed3d4fb219d00355eb78adb800adb1e18ad3" +version = "0.5.1" +source = "git+https://github.com/ctron/patternfly-yew?rev=ef507153eabf2dd3ab4dff2ece3325896510daba#ef507153eabf2dd3ab4dff2ece3325896510daba" dependencies = [ "chrono", "gloo-events 0.2.0", @@ -842,7 +841,7 @@ dependencies = [ [[package]] name = "patternfly-yew-quickstart" -version = "0.5.0-rc.1" +version = "0.5.1" dependencies = [ "browser-panic-hook", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2be6d8c..4a2e0d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "patternfly-yew-quickstart" -version = "0.5.0" +version = "0.5.1" authors = ["Jens Reimann "] edition = "2021" license = "Apache-2.0" @@ -13,7 +13,7 @@ browser-panic-hook = "0.2" chrono = { version = "0.4.30", default-features = false, features = ["wasmbind"] } gloo-utils = "0.2" log = "0.4" -patternfly-yew = { version = "0.5.0", features = ["tree", "dual_list_selector", "icons-fab"] } +patternfly-yew = { version = "0.5.1", features = ["tree", "dual_list_selector", "icons-fab"] } popper-rs = { version = "0.3.0", features = ["yew", "debug"] } serde_json = "1" strum = { version = "0.25", features = ["derive"] } @@ -35,7 +35,7 @@ features = [ [patch.crates-io] #patternfly-yew = { path = "../patternfly-yew" } -#patternfly-yew = { git = "https://github.com/ctron/patternfly-yew", rev = "4b5025843efe1c9fce5c85168f5f5971005a0886" } # FIXME: awaiting release +patternfly-yew = { git = "https://github.com/ctron/patternfly-yew", rev = "ef507153eabf2dd3ab4dff2ece3325896510daba" } # FIXME: awaiting release #yew-nested-router = { path = "../yew-nested-router" } #yew-more-hooks = { git = "https://github.com/ctron/yew-more-hooks", rev = "f535bb2e7b227aac7010035215c11d4aeae6cb62" } # FIXME: awaiting release #yew-more-hooks = { path = "../yew-more-hooks" } diff --git a/src/app/mod.rs b/src/app/mod.rs index 560c9dc..5f44e63 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -58,6 +58,7 @@ pub enum Component { Toast, Tooltip, Tree, + Truncate, } #[derive(Debug, Clone, Default, PartialEq, Eq, Target)] @@ -177,6 +178,7 @@ fn switch_app_route(target: AppRoute) -> Html { Component::Toast => html! {}, Component::Tooltip => html! {}, Component::Tree => html! {}, + Component::Truncate => html! {}, }; let layout = |target: Layout| match target { @@ -314,6 +316,7 @@ fn page(props: &PageProps) -> Html { to={AppRoute::Component(Component::Toast)}>{"Toast"}> to={AppRoute::Component(Component::Tooltip)}>{"Tooltip"}> to={AppRoute::Component(Component::Tree)}>{"Tree"}> + to={AppRoute::Component(Component::Truncate)}>{"Truncate"}> to={AppRoute::Layout(Layout::Bullseye)}>{"Bullseye"}> @@ -344,13 +347,13 @@ fn page(props: &PageProps) -> Html { let backdropper = use_backdrop(); - let onabout = Callback::from(move |_| { + let onabout = use_callback((), move |_, ()| { if let Some(backdropper) = &backdropper { backdropper.open(html!()); } }); - let onthemeswitch = Callback::from(|state| match state { + let onthemeswitch = use_callback((), |state, ()| match state { true => gloo_utils::document_element().set_class_name("pf-v5-theme-dark"), false => gloo_utils::document_element().set_class_name(""), }); diff --git a/src/components/mod.rs b/src/components/mod.rs index dbe182c..eeb6315 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -14,8 +14,8 @@ mod date; mod description_list; mod divider; mod drawer; -mod dual_list_selector; mod dropdown; +mod dual_list_selector; mod empty; mod expandable_section; mod file_upload; @@ -41,6 +41,7 @@ mod title; mod toast; mod tooltip; mod tree; +mod truncate; pub use accordion::*; pub use alert::*; @@ -85,3 +86,4 @@ pub use title::*; pub use toast::*; pub use tooltip::*; pub use tree::*; +pub use truncate::*; diff --git a/src/components/truncate/mod.rs b/src/components/truncate/mod.rs new file mode 100644 index 0000000..b6eb355 --- /dev/null +++ b/src/components/truncate/mod.rs @@ -0,0 +1,32 @@ +use crate::example; +use crate::example::ExamplePage; +use patternfly_yew::prelude::*; +use yew::prelude::*; + +#[function_component(TruncateExample)] +pub fn truncate_example() -> Html { + let example1 = example! ("Default" => "truncate.1.example"); + let example2 = example! ("Start" => "truncate.2.example"); + let example3 = example! ("Middle" => "truncate.3.example"); + let example4 = example! ("Middle (explicit)" => "truncate.4.example"); + + #[function_component(Resize)] + fn resize(props: &ChildrenProperties) -> Html { + html!( +
+ { props.children.clone() } +
+ ) + } + + html! ( + <> + + {example1} + {example2} + {example3} + {example4} + + + ) +} diff --git a/src/components/truncate/truncate.1.example b/src/components/truncate/truncate.1.example new file mode 100644 index 0000000..48d7924 --- /dev/null +++ b/src/components/truncate/truncate.1.example @@ -0,0 +1,7 @@ +{ + html!( + + + + ) +} \ No newline at end of file diff --git a/src/components/truncate/truncate.2.example b/src/components/truncate/truncate.2.example new file mode 100644 index 0000000..b277fa2 --- /dev/null +++ b/src/components/truncate/truncate.2.example @@ -0,0 +1,7 @@ +{ + html!( + + + + ) +} \ No newline at end of file diff --git a/src/components/truncate/truncate.3.example b/src/components/truncate/truncate.3.example new file mode 100644 index 0000000..28e99cd --- /dev/null +++ b/src/components/truncate/truncate.3.example @@ -0,0 +1,7 @@ +{ + html!( + + + + ) +} \ No newline at end of file diff --git a/src/components/truncate/truncate.4.example b/src/components/truncate/truncate.4.example new file mode 100644 index 0000000..43aea0f --- /dev/null +++ b/src/components/truncate/truncate.4.example @@ -0,0 +1,10 @@ +{ + html!( + + + + ) +} \ No newline at end of file From e68dea1b3d410a3626b52abef787cd949652c26a Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Fri, 17 Nov 2023 16:28:28 +0100 Subject: [PATCH 2/2] ci: try fixing the preview --- .github/workflows/pr-preview-deploy.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr-preview-deploy.yml b/.github/workflows/pr-preview-deploy.yml index 17d3be5..4eb5923 100644 --- a/.github/workflows/pr-preview-deploy.yml +++ b/.github/workflows/pr-preview-deploy.yml @@ -13,10 +13,10 @@ jobs: github.event.workflow_run.conclusion == 'success' steps: - name: Download dist - uses: actions/github-script@v3 + uses: actions/github-script@v6 with: script: | - var artifacts = await github.actions.listWorkflowRunArtifacts({ + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, run_id: ${{github.event.workflow_run.id }}, @@ -24,7 +24,7 @@ jobs: var matchArtifact = artifacts.data.artifacts.filter((artifact) => { return artifact.name == "dist" })[0]; - var download = await github.actions.downloadArtifact({ + var download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: matchArtifact.id, @@ -33,10 +33,10 @@ jobs: var fs = require('fs'); fs.writeFileSync('${{github.workspace}}/dist.zip', Buffer.from(download.data)); - name: Download PR number - uses: actions/github-script@v3 + uses: actions/github-script@v6 with: script: | - var artifacts = await github.actions.listWorkflowRunArtifacts({ + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, run_id: ${{github.event.workflow_run.id }}, @@ -44,7 +44,7 @@ jobs: var matchArtifact = artifacts.data.artifacts.filter((artifact) => { return artifact.name == "pr" })[0]; - var download = await github.actions.downloadArtifact({ + var download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: matchArtifact.id, @@ -57,7 +57,7 @@ jobs: - run: unzip pr.zip - name: Generate issue_number - uses: actions/github-script@v3 + uses: actions/github-script@v6 id: issue_number with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -67,13 +67,13 @@ jobs: result-encoding: string - name: Generate Surge URL - uses: actions/github-script@v3 + uses: actions/github-script@v6 id: surge-url with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const issue_number = ${{steps.issue_number.outputs.result}}; - return `patternfly-yew-quickstarts-pr-${issue_number}-preview.surge.sh`; + return `patternfly-yew-quickstart-pr-${issue_number}-preview.surge.sh`; result-encoding: string - name: Install Surge run: npm install -g surge @@ -83,6 +83,6 @@ jobs: - name: Post URL as PR comment uses: mshick/add-pr-comment@v2 with: - message: "🚀 Deployed Preview: http://${{steps.surge-url.outputs.result}} ✨" + message: "🚀 Deployed Preview: https://${{steps.surge-url.outputs.result}} ✨" repo-token: ${{ secrets.BOT_TOKEN }} issue: ${{steps.issue_number.outputs.result}}