-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Components as props in labels #940
Merged
+93
−14
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
78e2622
added support for components in labels
AnnMarieW 0b669c9
added test and updated docs
AnnMarieW bb319a4
Update tests/test_components_as_props
AnnMarieW e56baaf
Update tests/test_components_as_props
AnnMarieW a535504
Update tests/test_components_as_props
AnnMarieW bb1afce
Update tests/test_components_as_props
AnnMarieW a5fa121
Update tests/test_components_as_props
AnnMarieW a1b27ea
Update tests/test_components_as_props
AnnMarieW f55c79d
update after review
AnnMarieW 5fc729c
Update Bootstrap icons css
tcbegley ea479ea
Add tests to nox sources
tcbegley 8fae7f0
Format
tcbegley f2fd714
Unused import
tcbegley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
docs/components_page/components/input/components_in_labels.py
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,31 @@ | ||
from dash import Dash, html | ||
import dash_bootstrap_components as dbc | ||
|
||
flights = html.Div([html.Div(className="fa fa-plane pe-1"), "Flights"]) | ||
car = html.Div([html.Div(className="fa fa-car pe-1"), "Rental Car"]) | ||
hotel = html.Div([html.Div(className="fa fa-hotel pe-1"), "Hotel"]) | ||
|
||
radioitems = html.Div( | ||
[ | ||
dbc.Label("Booking"), | ||
dbc.RadioItems( | ||
options=[ | ||
{"label": flights, "value": 1}, | ||
{"label": car, "value": 2}, | ||
{"label": hotel, "value": 3}, | ||
], | ||
value=1, | ||
id="radioitems-input", | ||
), | ||
] | ||
) | ||
|
||
checkbox = dbc.Checkbox( | ||
id="standalone-checkbox", | ||
label=html.Div( | ||
["I agree to the ", html.A("Terms and Conditions", href="#")] | ||
), | ||
value=False, | ||
) | ||
|
||
components_in_labels = html.Div([radioitems, html.Hr(), checkbox]) |
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,40 @@ | ||
from dash import Dash, dcc, html | ||
tcbegley marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also drop |
||
from dash_bootstrap_components import Checklist, Checkbox, RadioButton, RadioItems, Switch | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def test_mdcap001_components_as_props(dash_dcc): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
app = Dash(__name__) | ||
|
||
app.layout = html.Div( | ||
[ | ||
dbc.Checklist( | ||
[ | ||
{"label": html.H2("H2 label"), "value": "h2"}, | ||
{"label": html.A("Link in checklist", href="#"), "value": "a"}, | ||
], | ||
id="checklist", | ||
), | ||
dbc.RadioItems( | ||
[ | ||
{"label": html.H3("on"), "value": "on"}, | ||
{"label": html.P("off"), "value": "off"}, | ||
], | ||
id="radio-items", | ||
), | ||
dbc.Checkbox(label= html.H4("h4"), value= "h4", id="checkbox"), | ||
dbc.RadioButton(label=html.H6("h6"), value="h6", id="radiobutton), | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dbc.Switch(label=html.H5("h5"), value="h5", id="switch) | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
) | ||
|
||
dash_dcc.start_server(app) | ||
|
||
dash_dcc.wait_for_text_to_equal("#checklist h2", "H2 label") | ||
dash_dcc.wait_for_text_to_equal("#checklist a", "Link in checklist") | ||
|
||
dash_dcc.wait_for_text_to_equal("#radio-items h3", "on") | ||
dash_dcc.wait_for_text_to_equal("#radio-items p", "off") | ||
|
||
dash_dcc.wait_for_text_to_equal("#checkbox h4", "h4") | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dash_dcc.wait_for_text_to_equal("#radiobutton h6", "h6") | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dash_dcc.wait_for_text_to_equal(#switch h5", "h5") | ||
AnnMarieW marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These icons aren't showing up for me when I run the docs because Font Awesome stylesheet isn't actually linked.
We can add the link in
docs/templates/partials/head.html
, though I would actually have a preference for changing this example to use Bootstrap icons, since we're already linking the CSS anyway. So less for the reader of the docs to load when they visit.