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

chore: add lineSize prop to Burger #432

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Added

- Added `disabled` prop to `Radio` #425 by @namakshenas
- Added `lineSize` prop to `Burger` #432 by @ChinoUkaegbu

### Fixed
- Fixed closing of Popovers when clicking outside. #423 by @magicmq
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ app = Dash(__name__, external_stylesheets=dmc.styles.ALL)

app.layout = dmc.MantineProvider(
[
dmc.DatePicker(
dmc.DatePickerInput(
id="date-picker",
label="Start Date",
description="You can also provide a description",
Expand Down
4 changes: 3 additions & 1 deletion src/ts/components/core/Burger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ interface Props
size?: MantineSize | (string & {}) | number;
/** Key of `theme.colors` of any valid CSS value, by default `theme.white` in dark color scheme and `theme.black` in light */
color?: MantineColor;
/** Height of the burger lines */
lineSize?: string | number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As @AnnMarieW commented:

Based on the Mantine Docs, the lineSize prop is a number. For example lineSize=5 or as text lineSize="5" but the Mantine named sizes like xl is not valid

If named sizes like xl are in fact valid, let's put one in the test. If not, let's remove string | here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't work with the named sizes. I tried it in a code sandbox with the Mantine react component too, and it can either be lineSize={5} or lineSize="5" but nothing renders if you do lineSize="sm"

@ChinoUkaegbu would you like to update to the prop so it's just

 lineSize?: number;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
lineSize?: string | number;
lineSize?: number;

/** State of the burger, when `true` burger is transformed into X, `false` by default */
opened?: boolean;
/** `transition-duration` property value in ms, `300` by default */
Expand All @@ -25,7 +27,7 @@ interface Props
transitionTimingFunction?: string;
}

/** Burger */
/** The Burger component renders a customizable hamburger menu button which can toggle between open and closed states. */
const Burger = (props: Props) => {
const {
setProps,
Expand Down
39 changes: 39 additions & 0 deletions tests/test_burger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from dash import Dash, html, Output, Input, _dash_renderer, callback
import dash_mantine_components as dmc

_dash_renderer._set_react_version("18.2.0")


def test_001bu_burger(dash_duo):
app = Dash(__name__)

app.layout = dmc.MantineProvider(
html.Div(
[dmc.Burger(id="burger-button", opened=False, lineSize=2, ), dmc.Text(id="burger-state", mt="md")]
)
)

@callback(Output("burger-state", "children"), Input("burger-button", "opened"))
def is_open(opened):
return str(opened)

dash_duo.start_server(app)

# Wait for the app to load
dash_duo.wait_for_text_to_equal("#burger-state", "False")

# Open Burger
burger = dash_duo.find_element("#burger-button")
burger.click()

# Verify the Burger opens when clicking the button
dash_duo.wait_for_text_to_equal("#burger-state", "True")

# Close Popover
burger.click()

# Verify the Burger closes when clicked again
dash_duo.wait_for_text_to_equal("#burger-state", "False")

assert dash_duo.get_logs() == []