From 3fefc8d7449b128a6370acaab2f7bfb5760c6de3 Mon Sep 17 00:00:00 2001 From: Ryan Morshead Date: Mon, 17 Jul 2023 13:16:42 -0600 Subject: [PATCH 1/4] Fix link usages (#21) * Fix link usages. * remove run() --- docs/src/usage.md | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/src/usage.md b/docs/src/usage.md index 0bf0387..e0f7bb2 100644 --- a/docs/src/usage.md +++ b/docs/src/usage.md @@ -92,16 +92,21 @@ This will allow ReactPy to handle the transition between routes more quickly by the cost of a full page load. ```python -from reactpy import component, html, run -from reactpy_router import link, route, simple, use_location +from reactpy import component, html, run, use_location +from reactpy_router import link, route, simple @component def root(): - location = use_location() + use_location() return simple.router( - route("/", html.h1("Home Page 🏠")), + route( + "/", + html.div( + html.h1("Home Page 🏠"), + link(html.button("About"), to="/about"), + ), + ), route("/about", html.h1("About Page 📖")), - link("/about", html.button("About")), ) ``` @@ -127,10 +132,16 @@ from reactpy_router import link, route, simple, use_query @component def root(): + use_location() return simple.router( - route("/", html.h1("Home Page 🏠")), - route("/search", search()), - link("Search", to="/search?q=reactpy"), + route( + "/", + html.div( + html.h1("Home Page 🏠"), + link("Search", to="/search?q=reactpy"), + ), + ), + route("/about", html.h1("About Page 📖")), ) @component @@ -152,9 +163,14 @@ from reactpy_router import link, route, simple, use_params @component def root(): return simple.router( - route("/", html.h1("Home Page 🏠")), + route( + "/", + html.div( + html.h1("Home Page 🏠"), + link("User 123", to="/user/123"), + ), + ), route("/user/{id:int}", user()), - link("User 123", to="/user/123"), ) @component From 5336360dd353a58de8d329274f5ecece0ac6b209 Mon Sep 17 00:00:00 2001 From: Ryan Morshead Date: Mon, 17 Jul 2023 13:43:40 -0600 Subject: [PATCH 2/4] Publish docs via GH actions (#22) * Publish docs via GH actions * Update publish-docs.yaml --- .github/workflows/publish-docs.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/publish-docs.yaml diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml new file mode 100644 index 0000000..2d6aa80 --- /dev/null +++ b/.github/workflows/publish-docs.yaml @@ -0,0 +1,21 @@ +name: publish-docs + +on: + push: + branches: + - main + +jobs: + build: + name: Deploy docs + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v2 + - name: Deploy docs + # Use mhausenblas/mkdocs-deploy-gh-pages@nomaterial to exclude mkdocs-material theme + uses: mhausenblas/mkdocs-deploy-gh-pages@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CONFIG_FILE: docs/mkdocs.yml + REQUIREMENTS: requirements/build-docs.txt From 475e3578bceae4733ea48860d3ae2a7fe9b376eb Mon Sep 17 00:00:00 2001 From: Denis Povod Date: Thu, 14 Sep 2023 19:50:23 +0200 Subject: [PATCH 3/4] fix: fix relative navigation (#24) --- js/src/index.js | 2 +- tests/test_core.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/js/src/index.js b/js/src/index.js index 2c06733..1f43092 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -33,7 +33,7 @@ export function History({ onChange }) { export function Link({ to, onClick, children, ...props }) { const handleClick = (event) => { event.preventDefault(); - window.history.pushState({}, to, window.location.origin + to); + window.history.pushState({}, to, new URL(to, window.location)); onClick({ pathname: window.location.pathname, search: window.location.search, diff --git a/tests/test_core.py b/tests/test_core.py index 47ca951..5f05f5c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -183,3 +183,43 @@ def sample(): await display.page.go_back() await display.page.wait_for_selector("#root") + + +async def test_relative_links(display: DisplayFixture): + @component + def sample(): + return simple.router( + route("/", link("Root", to="/a", id="root")), + route("/a", link("A", to="/a/b", id="a")), + route("/a/b", link("B", to="../a/b/c", id="b")), + route("/a/b/c", link("C", to="../d", id="c")), + route("/a/d", link("D", to="e", id="d")), + route("/a/e", link("E", to="../default", id="e")), + route("*", html.h1({"id": "default"}, "Default")), + ) + + await display.show(sample) + + for link_selector in ["#root", "#a", "#b", "#c", "#d", "#e"]: + lnk = await display.page.wait_for_selector(link_selector) + await lnk.click() + + await display.page.wait_for_selector("#default") + + await display.page.go_back() + await display.page.wait_for_selector("#e") + + await display.page.go_back() + await display.page.wait_for_selector("#d") + + await display.page.go_back() + await display.page.wait_for_selector("#c") + + await display.page.go_back() + await display.page.wait_for_selector("#b") + + await display.page.go_back() + await display.page.wait_for_selector("#a") + + await display.page.go_back() + await display.page.wait_for_selector("#root") From 3dd9777e6cad5347600ca4b6fc8d725c203dc3c4 Mon Sep 17 00:00:00 2001 From: Ryan Morshead Date: Wed, 13 Dec 2023 14:53:13 -0700 Subject: [PATCH 4/4] version 0.1.1 (#25) --- reactpy_router/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactpy_router/__init__.py b/reactpy_router/__init__.py index 0fa3ea1..cb2fcbc 100644 --- a/reactpy_router/__init__.py +++ b/reactpy_router/__init__.py @@ -1,5 +1,5 @@ # the version is statically loaded by setup.py -__version__ = "0.1.0" +__version__ = "0.1.1" from . import simple from .core import create_router, link, route, router_component, use_params, use_query