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

Implementing "Card Reveal" using ipyvuetify #628

Open
sheffier opened this issue May 2, 2024 · 3 comments
Open

Implementing "Card Reveal" using ipyvuetify #628

sheffier opened this issue May 2, 2024 · 3 comments

Comments

@sheffier
Copy link

sheffier commented May 2, 2024

Hi,

I'm trying to figure out how to implement a Card Reveal component (using ipyvuetify/reacton/solara), similar to the example shown on vuetify docs.

Thanks

@iisakkirotko
Copy link
Collaborator

Hey @sheffier!

This should do the trick:

import solara


show = solara.reactive(False)


@solara.component
def Page():
    with solara.v.Html(tag="div", style_="position: relative; top: 50px; left: calc(50% - 250px); width: 500px;"):
        with solara.Card(style={"height": "500px"}):
            solara.Markdown("# Content 1")
            solara.v.Spacer(vertical=True)
            solara.Button("Click me", color="primary", on_click=lambda: show.set(True))
            with solara.v.ExpandTransition():
                if show.value:
                    with solara.Card(style={"height": '500px' if show.value else '0', "width": "100%", "position": "absolute", "bottom": "0", "left": "0", "margin": "0 !important"}, classes=["transition-fast-in-fast-out", "v-card--reveal"]):
                            solara.Markdown("# Content 2")
                            solara.Button("click me", color="secondary", on_click=lambda: show.set(False))

Run and edit this code at PyCafe

Where did you get stuck on your first try? Is there something we could improve about the documentation that would have helped you?

@sheffier
Copy link
Author

sheffier commented May 5, 2024

Yep, this did the trick!

Where did you get stuck on your first try?

I am a data scientists with no WEB development skills.

Is there something we could improve about the documentation that would have helped you?

I don't know if any improvement to the docs would have helped me. However, a more programmatically way to implement this would have helped. For example:

with ExpandTransition():
    with Card():
        ...
    with Card():
       ....

Thanks!

@sheffier
Copy link
Author

sheffier commented May 6, 2024

BTW @iisakkirotko,

The following code snippet worked even better:

import solara


show = solara.reactive(False)


@solara.component
def Page():
    with solara.Card(style="min-height: 230px; height: 100%"):
        solara.Markdown("# Content 1")
        with solara.v.ExpandTransition():
            if show.value:
                with solara.Card(
                    style={
                        "height": "100%" if show.value else "0",
                        "width": "100%",
                        "position": "absolute",
                        "bottom": "0",
                        "left": "0",
                        "margin": "0 !important",
                    },
                    classes=["transition-fast-in-fast-out", "v-card--reveal"],
                ):
                    solara.Markdown("# Content 2")

        with solara.v.CardActions(style_="position: absolute; bottom: 0; left: 0;"):
            if not show.value:
                solara.Button("Options", color="primary", on_click=lambda: show.set(True))
            else:
                solara.Button("Close", color="secondary", on_click=lambda: show.set(False))

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

No branches or pull requests

2 participants