Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mo.routes() #1356

Merged
merged 6 commits into from May 22, 2024
Merged

feat: mo.routes() #1356

merged 6 commits into from May 22, 2024

Conversation

mscolnick
Copy link
Contributor

@mscolnick mscolnick commented May 10, 2024

This adds mo.routes to change the layout based on the url hash or pathname

    @app.cell
    def __():
        mo.routes({
            "#/home": mo.md("# Home"),
            "#/about": mo.md("# About"),
            "#/contact": mo.md("# Contact"),
        })
        return

    @app.cell
    def __():
        mo.sidebar(
            [
                mo.md("# marimo"),
                mo.nav_menu(
                    {
                        "#/home": f"{mo.icon('lucide:home')} Home",
                        "#/about": f"{mo.icon('lucide:user')} About",
                        "#/contact": f"{mo.icon('lucide:phone')} Contact",
                        "Links": {
                            "https://twitter.com/marimo_io": "Twitter",
                            "https://github.com/marimo-team/marimo": "GitHub",
                        },
                    },
                    orientation="vertical",
                ),
            ]
        )
        return

Copy link

vercel bot commented May 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 2:06pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 2:06pm

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments:

  1. Seeing a FunctionCallRequest error on #/home

image

  1. Is there a way to set a route for the root path? When I go to the app preview for the smoke test, I see a blank page because no route has been selected.

@mscolnick
Copy link
Contributor Author

@akshayka

  1. The first is the weakref issue in pretty sure. We can more lazy as the under the hood implementation but it's loses a lot of its benefit
  2. I can add a catch all route as an example - maybe I'll make it constant that is easy to access

@mscolnick mscolnick deleted the ms/routes branch May 22, 2024 18:40
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.6.1-dev29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants