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

Add type prop to SimpleGrid #472

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

namakshenas
Copy link
Contributor

PR / add type prop to SimpleGrid / #428

Copy link

github-actions bot commented Jan 9, 2025

Test Environment for snehilvj/dash-mantine-components-472
Updated on: 2025-01-09 17:32:59 UTC

@namakshenas
Copy link
Contributor Author

@AnnMarieW
Copy link
Collaborator

Looks good! Is it running for you locally now too?

For the example, it's nice to be able to dynamically change the dimensions of the container like in the Mantine docs: https://mantine.dev/core/simple-grid/#container-queries

Can you update the component with the container query to wrap it in the div like this?:

import dash_mantine_components as dmc
from dash import Dash, html, _dash_renderer

_dash_renderer._set_react_version("18.2.0")

app = Dash(external_stylesheets=dmc.styles.ALL)

style = {
    "border": f"1px solid {dmc.DEFAULT_THEME['colors']['indigo'][4]}",
    "textAlign": "center",
}

html.Div(
    dmc.SimpleGrid(
        type="container",
        cols={"base": 1, "300px": 2, "500px": 5},
        spacing={"base": 10, "300px": "xl"},
        children=[
            html.Div("1", style=style),
            html.Div("2", style=style),
            html.Div("3", style=style),
            html.Div("4", style=style),
            html.Div("5", style=style),
        ],
        p="lg"
    ),
    style={"resize": 'horizontal', "overflow": 'hidden', "maxWidth": '100%' }
)


app.layout = dmc.MantineProvider([component])


if __name__ == "__main__":
    app.run(debug=True)

@namakshenas
Copy link
Contributor Author

Looks good! Is it running for you locally now too?

For the example, it's nice to be able to dynamically change the dimensions of the container like in the Mantine docs: https://mantine.dev/core/simple-grid/#container-queries

Can you update the component with the container query to wrap it in the div like this?:

import dash_mantine_components as dmc
from dash import Dash, html, _dash_renderer

_dash_renderer._set_react_version("18.2.0")

app = Dash(external_stylesheets=dmc.styles.ALL)

style = {
    "border": f"1px solid {dmc.DEFAULT_THEME['colors']['indigo'][4]}",
    "textAlign": "center",
}

html.Div(
    dmc.SimpleGrid(
        type="container",
        cols={"base": 1, "300px": 2, "500px": 5},
        spacing={"base": 10, "300px": "xl"},
        children=[
            html.Div("1", style=style),
            html.Div("2", style=style),
            html.Div("3", style=style),
            html.Div("4", style=style),
            html.Div("5", style=style),
        ],
        p="lg"
    ),
    style={"resize": 'horizontal', "overflow": 'hidden', "maxWidth": '100%' }
)


app.layout = dmc.MantineProvider([component])


if __name__ == "__main__":
    app.run(debug=True)

Have you checked this?: https://py.cafe/namakshenas/dmc-type-simplegrid

ps. I'm unable to run it locally.

@AnnMarieW
Copy link
Collaborator

AnnMarieW commented Jan 9, 2025

Yes, I saw your pycafe example, but it doesn't demonstrate the feature of container queries:

With container queries, grid columns and spacing will be adjusted based on the container width, not the viewport width.

Adding the extra div like I showed allows you to dynamically change the size of the container and the layout changes based on the container. Your example shows the columns changing based on the viewport.

But I did try it out with my change and it works fine. So if you add a changelog, I can merge this.

@namakshenas
Copy link
Contributor Author

@AnnMarieW I updated the pycafe app according to your comment.

Also, updated the changelog.

@AnnMarieW
Copy link
Collaborator

Looks great! Thanks 💃

@AnnMarieW AnnMarieW merged commit 49b88c3 into snehilvj:master Jan 10, 2025
1 check passed
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.

2 participants