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 active prop to carousel #354

Merged
merged 7 commits into from
Oct 16, 2024

Conversation

AnnMarieW
Copy link
Collaborator

@AnnMarieW AnnMarieW commented Oct 14, 2024

closes #292
To do:

  • add tests
  • add changelog

Will update docs with new examples after release and doc PR #69

Copy link

Generated link: snehilvj/dash-mantine-components-354

@AnnMarieW AnnMarieW marked this pull request as ready for review October 15, 2024 19:48
@AnnMarieW
Copy link
Collaborator Author

Here is a sample app:

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

_dash_renderer._set_react_version("18.2.0")

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


component = dmc.Carousel(
    [
        dmc.CarouselSlide(dmc.Center("Slide-0", bg="blue", c="white", p=60)),
        dmc.CarouselSlide(dmc.Center("Slide-1", bg="blue", c="white", p=60)),
        dmc.CarouselSlide(dmc.Center("Slide-2", bg="blue", c="white", p=60)),
    ],
    id="carousel",
   # initialSlide=1,
    autoplay={"delay": 200, "stopOnMouseEnter": True, "stopOnInteraction":False},
)


app.layout = dmc.MantineProvider(
    html.Div([
        component,
        dmc.Text(id="output")
    ])
)

@app.callback(
    Output("output", "children"),
    Input("carousel", "active")
)
def update(n):
    return f"slide index {n}"


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

dmc.CarouselSlide(dmc.Center("Slide-2", bg="blue", c="white", p=60)),
],
id="carousel",
autoplay={"delay": 500, "stopOnMouseEnter": True, "stopOnInteraction": False, "stopOnLastSnap": True},
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe disable stopOnMouseEnter just so people don't accidentally halt the test when running it locally?

@@ -3,12 +3,14 @@ import { MantineSpacing, StyleProp } from "@mantine/core";
import { BoxProps } from "props/box";
import { DashBaseProps } from "props/dash";
import { StylesApiProps } from "props/styles";
import React from "react";
import React, { useEffect, useState } from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you use useState?

Copy link
Collaborator Author

@AnnMarieW AnnMarieW Oct 16, 2024

Choose a reason for hiding this comment

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

did you use useState?

...only while messing around with things that didn't work haha
Need to add linting and formatting to this project in order to clean up stuff like this automatically,

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 Very nice - just two minor comments.

@AnnMarieW AnnMarieW merged commit f64bf24 into snehilvj:master Oct 16, 2024
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.

[Feature Request] Add "active" prop to DMC Carousel
2 participants