-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from AnnMarieW/fix-close-button
fix closeButtonProps and clearButtonProps
- Loading branch information
Showing
11 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MantineRadius, MantineSize } from "@mantine/core"; | ||
import React from "react"; | ||
|
||
export interface __BaseButtonProps { | ||
/** Key of `theme.radius` or any valid CSS value to set border-radius. Numbers are converted to rem. `theme.defaultRadius` by default. */ | ||
radius?: MantineRadius; | ||
/** Sets `disabled` and `data-disabled` attributes on the button element */ | ||
disabled?: boolean; | ||
/** `X` icon `width` and `height`, `80%` by default */ | ||
iconSize?: number | string; | ||
/** Content rendered inside the button, for example `VisuallyHidden` with label for screen readers */ | ||
children?: React.ReactNode; | ||
/** Replaces default close icon. If set, `iconSize` prop is ignored. */ | ||
icon?: React.ReactNode; | ||
} | ||
|
||
export interface __CloseButtonProps extends __BaseButtonProps { | ||
/** Controls width and height of the button. Numbers are converted to rem. `'md'` by default. */ | ||
size?: MantineSize | (string & {}) | number; | ||
} | ||
|
||
export interface __ClearButtonProps extends __BaseButtonProps { | ||
/** Size of the button, by default value is based on input context */ | ||
size?: MantineSize | (string & {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from dash import Dash, html, Output, Input, State, _dash_renderer | ||
import dash_mantine_components as dmc | ||
|
||
_dash_renderer._set_react_version("18.2.0") | ||
|
||
|
||
def test_001mo_modal(dash_duo): | ||
app = Dash(__name__) | ||
|
||
component = html.Div( | ||
[ | ||
dmc.Button("Open Modal", id="modal-demo-button"), | ||
dmc.Modal( | ||
title="New Modal", | ||
id="modal-simple", | ||
closeButtonProps={ | ||
"children": html.Div(" close", id="my-component"), | ||
"icon": html.Div("x", id="modal-custom-close"), | ||
}, | ||
children=[ | ||
dmc.Text("I am in a modal component."), | ||
], | ||
), | ||
] | ||
) | ||
|
||
app.layout = dmc.MantineProvider( | ||
component | ||
) | ||
|
||
@app.callback( | ||
Output("modal-simple", "opened"), | ||
Input("modal-demo-button", "n_clicks"), | ||
State("modal-simple", "opened"), | ||
prevent_initial_call=True, | ||
) | ||
def modal_demo(_, opened): | ||
return not opened | ||
|
||
dash_duo.start_server(app) | ||
|
||
# Open modal | ||
modal_btn = dash_duo.find_element("#modal-demo-button") | ||
modal_btn.click() | ||
|
||
# Close modal | ||
modal_close_btn = dash_duo.find_element("#modal-custom-close") | ||
modal_close_btn.click() | ||
|
||
assert dash_duo.get_logs() == [] |