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 and breakpoint props to Grid #473

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

namakshenas
Copy link
Contributor

PR / add type and breakpoint props to Grid / #428

Copy link

github-actions bot commented Jan 9, 2025

Test Environment for snehilvj/dash-mantine-components-473
Updated on: 2025-01-09 18:02:31 UTC

@namakshenas
Copy link
Contributor Author

Here is the test:
https://py.cafe/namakshenas/dmc-type-grid

app.py:

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",
}

component = html.Div(
    children=[
        dmc.Grid(
            children=[
                dmc.GridCol(html.Div("1", style=style), span=4),
                dmc.GridCol(html.Div("2", style=style), span=4),
                dmc.GridCol(html.Div("3", style=style), span=4),
                dmc.GridCol(html.Div("4", style=style), span=4),
                dmc.GridCol(html.Div("5", style=style), span=4),
            ],
            gutter="xl",
            type="container",
            breakpoints={
                "xs": "100px",
                "sm": "200px",
                "md": "300px",
                "lg": "400px",
                "xl": "500px",
            },
        ),
        dmc.Space(h=40),
        dmc.Grid(
            children=[
                dmc.GridCol(html.Div("1", style=style), span=4),
                dmc.GridCol(html.Div("2", style=style), span=4),
                dmc.GridCol(html.Div("3", style=style), span=4),
                dmc.GridCol(html.Div("4", style=style), span=4),
                dmc.GridCol(html.Div("5", style=style), span=4),
            ],
            gutter="xl",
            type="media",
            breakpoints={
                "xs": "100px",
                "sm": "200px",
                "md": "300px",
                "lg": "400px",
                "xl": "500px",
            },
        ),
    ]
)

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

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

I was not able to spot any diff between "media" and "container" types.

@AnnMarieW
Copy link
Collaborator

In order to see the difference, as a test it's necessary to wrap the container in a div like I mentioned in you SimpleGrid PR.

Here's what the demo should look like. When you change the size of the container, the layout changes without changing the size of the browser
container_queries_grid
window

@AnnMarieW
Copy link
Collaborator

Try changing the pycafe app to 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",
}

component = html.Div(
    dmc.Grid(
        children=[
            dmc.GridCol(html.Div("1", style=style), span={"base": 12, "md": 6, "lg": 3}),
            dmc.GridCol(html.Div("2", style=style), span={"base": 12, "md": 6, "lg": 3}),
            dmc.GridCol(html.Div("3", style=style), span={"base": 12, "md": 6, "lg": 3}),
            dmc.GridCol(html.Div("4", style=style), span={"base": 12, "md": 6, "lg": 3}),
            dmc.GridCol(html.Div("5", style=style), span={"base": 12, "md": 6, "lg": 3}),
        ],
        gutter="xl",
        type="container",
        breakpoints={
            "xs": "100px",
            "sm": "200px",
            "md": "300px",
            "lg": "400px",
            "xl": "500px",
        },
    ),
    style={"resize": 'horizontal', "overflow": 'hidden', "maxWidth": '100%', "margin": 24 },
)

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

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

@namakshenas
Copy link
Contributor Author

@AnnMarieW Thanks! Updated the app in pycafe.

@AnnMarieW
Copy link
Collaborator

@namakshenas - Looks good. Just need a changelog and this is ready to merge too. Thanks! 💃

namakshenas added a commit to namakshenas/dash-mantine-components that referenced this pull request Jan 10, 2025
namakshenas added a commit to namakshenas/dash-mantine-components that referenced this pull request Jan 10, 2025
@namakshenas namakshenas force-pushed the add-type-breakpoint-grid branch from 533f76a to 3b3fa85 Compare January 10, 2025 14:51
@namakshenas
Copy link
Contributor Author

@AnnMarieW
Changelog updated

@AnnMarieW AnnMarieW merged commit 608c832 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