-
Notifications
You must be signed in to change notification settings - Fork 142
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
[QA] Add unit tests and examples for kpi_card
and kpi_card_reference
#529
Conversation
for more information, see https://pre-commit.ci
…izro into feat/create_kpi_cards
for more information, see https://pre-commit.ci
@stichbury @antonymilne - ready for another round 👍 You guys can review again while I'll create the yaml example |
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.
The docs look great! The tests need a little bit more work I think, but I trust you to do it and merge whenever you're happy with it.
Did the code for KPI card and KPI reference card change? I don't remember it having all the CardHeader
stuff in it before, but it looks like a great way to do it. There's just one thing I'd suggest refactoring. Currently it looks like this:
return dbc.Card(
[
dbc.CardHeader(
[
html.P(icon, className="material-symbols-outlined") if icon else None,
html.H2(title),
],
),
dbc.CardBody(value_format.format(value=value)),
],
className="card-kpi",
)
Let's break it up a bit like this:
header = dbc.CardHeader([html.P(icon, className="material-symbols-outlined") if icon else None, html.H2(title)])
body = dbc.CardBody(value_format.format(value=value))
return dbc.Card([header, body], className="card-kpi")
And similarly for the kpi_card_reference
. Normally I wouldn't care and would probably write it as you have done yourself, but given that these are meant to be easy to understand copy and pastable functions I think better to make them look less intimidating. Exactly the same logic as my suggestion for how to rewrite that long df
with all the text in it.
Remember that you're actually writing code for multiple different purposes here:
- "normal" code read by experienced developers
- test cases read by experienced developers but should be easy to run the tests in my head
- copy and pastable code for users who can code but don't know Dash well
- docs read by all users
Each of these has slightly different expectations/acceptable level of complexity so the code style can change between them rather than being one size fits all. e.g. stuff with lots of nesting weirdly formatted by black is fine for me as an experienced developer but not so digestible to a user reading docs.
vizro-core/changelog.d/20240607_125345_huong_li_nguyen_create_kpi_cards.md
Outdated
Show resolved
Hide resolved
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.
LGTM, loads of great and useful content. Thanks and well done 🙏
Yes, you probably didn't see my comment there then haha I've changed it here: #493 (comment) after our discussion on not having so many different classNames in the functions.
Yeah, that makes sense - will pay more attention to that now! 👍 |
Oooh yes I didn't see the |
Description
kpi_card
andkpi_card_reference
figure.md
fromcard-button.md
figure.md
Screenshot
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":