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

Feature/plotly theming #6

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
36bec62
Feat(plotly_theme): added theme and configuration options for plotly …
GedionT Oct 14, 2024
53b5f1e
Feat(plotly_components): added plotly chart components
GedionT Oct 14, 2024
a57d6d1
Feat(st_undp): apply plotly theme and export components
GedionT Oct 14, 2024
3ced4a9
Feat(integration): added an integration page for charts
GedionT Oct 14, 2024
5e8ddb6
Fix(app): added integration page to navigation
GedionT Oct 14, 2024
2c784cb
Feat(lib): added plotly dependency in poetry
GedionT Oct 14, 2024
ecb6e52
Fix(plotly-menu): underlined animation effect fixed for plotly chart …
GedionT Oct 14, 2024
13752cc
Fix(link-animation): link underline animation on hover fixed
GedionT Oct 14, 2024
6342f71
Fix(checkbox): removed custom icon for checkbox
GedionT Oct 14, 2024
fb5aeab
Refactor(formatting): code formatting applied
GedionT Oct 14, 2024
1a8a102
Chore(poetry): update lock file
GedionT Oct 14, 2024
792edcd
Refactor(about): code format and linting
GedionT Oct 14, 2024
e7dcc43
Refactor(custom-pages): linting and code formatting
GedionT Oct 14, 2024
7e6383a
Refactor(standard): removed unused module
GedionT Oct 14, 2024
f838ea9
Refactor(st_undp): linting and code formatting in main and adding enc…
GedionT Oct 14, 2024
7e11a9f
Docs(plotly): added basic docstrings
GedionT Oct 14, 2024
2685c72
Fix(style): code padding and visited link fix
GedionT Oct 15, 2024
4fa77e1
Refactor(lint): removed line break character
GedionT Oct 15, 2024
dec57ae
Fix(lint): removed line break character for readability
GedionT Oct 15, 2024
7c86dd9
Feat(standard): added expander to text tab
GedionT Oct 15, 2024
d219e18
Docs(readme): added plotly feature to readme
GedionT Oct 15, 2024
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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ python -m st_undp configure
```

This will edit the theme section in the file if it exists or create it if it doesn't.
Then, call `apply_style` function inside your application entry point, typically `app.py`:
Then, call `apply_style` function inside your application entry point, typically `app.py`:

```python
import st_undp
Expand All @@ -63,6 +63,7 @@ This package is currently in the early stages of development. Main features incl
- `ProximaNova` fonts
- CSS styles for most Streamlit input components
- Several custom components from the UNDP Design System, such as Author, Footer, Header, Stats Card
- Custom UNDP themed for Plotly and ready-made Plotly charts.
- No additional dependencies on top of what is required by `streamlit`

## Contributing
Expand All @@ -81,16 +82,16 @@ routine operations.

## License

This project is licensed under the BSD 3-Clause License. However, entities or individuals not affiliated with UNDP
are strictly prohibited from using this package or any of its components to create, share, publish, or distribute works
This project is licensed under the BSD 3-Clause License. However, entities or individuals not affiliated with UNDP
are strictly prohibited from using this package or any of its components to create, share, publish, or distribute works
that resemble, claim affiliation with, or imply endorsement by UNDP.

UNDP’s name, emblem and its abbreviation are the exclusive property of UNDP and are protected under international law.
Their unauthorized use is prohibited, and they may not be reproduced or used in any manner without UNDP’s prior written permission.
UNDP’s name, emblem and its abbreviation are the exclusive property of UNDP and are protected under international law.
Their unauthorized use is prohibited, and they may not be reproduced or used in any manner without UNDP’s prior written permission.

## Contact

This project is part of [Data Futures Exchange (DFx)](https://data.undp.org) at UNDP.
If you are facing any issues or would like to make some suggestions, feel free to
[open an issue](https://github.com/undp-data/st-undp/issues/new/choose).
If you are facing any issues or would like to make some suggestions, feel free to
[open an issue](https://github.com/undp-data/st-undp/issues/new/choose).
For enquiries about DFx, visit [Contact Us](https://data.undp.org/contact-us).
3 changes: 3 additions & 0 deletions app.py
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more like "extras", not so much "integrations".

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
title="custom components",
url_path="/custom",
),
st.Page(
page="pages/integrations.py", title="integrations", url_path="/integrations"
),
st.Page(
page="pages/about.py",
title="about",
Expand Down
2 changes: 1 addition & 1 deletion pages/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
st_undp.featured_card(
src="app/static/github.jpg",
title="UNDP Data GitHub",
summary="Leverage open source projects for data visualisation, geospatial analytics and artificial intelligence",
summary="Leverage open source projects for data visualisation, geo-spatial analytics and artificial intelligence",
href="https://github.com/undp-data",
tag="resource",
)
Expand Down
80 changes: 40 additions & 40 deletions pages/custom.py
Copy link
Contributor

Choose a reason for hiding this comment

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

If name similarity is an issue, modify the names, e.g., code -> code_str, code_text or even body (as per st.code signature), so st.code(body) but don't use uppercase for variables you redefine.

Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
]
)
with tab1:
code = """
CODE = """
st_undp.author(
src="app/static/aristotle.jpg",
name="Aristotle",
title="Ancient Greek philosopher and polymath",
href="https://en.wikipedia.org/wiki/Aristotle",
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab2:
code = """
CODE = """
st_undp.author_card(
src="app/static/aristotle.jpg",
name="Aristotle",
Expand All @@ -42,25 +42,25 @@
href="https://en.wikipedia.org/wiki/Aristotle",
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab3:
code = """
CODE = """
st_undp.author_summary(
src="app/static/aristotle.jpg",
name="Aristotle",
title="Ancient Greek philosopher and polymath",
summary="As the founder of the Peripatetic school of philosophy in the Lyceum in Athens, he began the wider Aristotelian tradition that followed, which set the groundwork for the development of modern science."
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab4:
code = """
CODE = """
st_undp.breadcrumb(
{
"Home": "/",
Expand All @@ -69,15 +69,15 @@
}
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab5:
st.subheader("Content Card")
body = "Use st.columns to arrange multiple cards in a row."
st.info(body, icon=":material/lightbulb:")
code = """
BODY = "Use st.columns to arrange multiple cards in a row."
st.info(BODY, icon=":material/lightbulb:")
CODE = """
st_undp.content_card(
src="app/static/aristotle.jpg",
caption="Nicomachean Ethics is closely related to Eudemian Ethics",
Expand All @@ -91,12 +91,12 @@
for _ in range(rows):
for col in st.columns(cols):
with col:
eval(code)
eval(CODE)
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab6:
code = """
CODE = """
st_undp.download_card(
src="app/static/aristotle.jpg",
title="Corpus Aristotelicum",
Expand All @@ -107,12 +107,12 @@
""".strip()
for col, variant in zip(st.columns(3), ("publication", "card", "default")):
with col:
eval(code.format(variant))
eval(CODE.format(variant))
with st.expander("Show Code"):
st.code(code.format(variant))
st.code(CODE.format(variant))

with tab7:
code = """
CODE = """
st_undp.featured_card(
src="app/static/aristotle.jpg",
title="Nicomachean Ethics",
Expand All @@ -121,13 +121,13 @@
width=6,
)
""".strip()
eval(code)
eval(CODE)
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab8:
body = "Make sure to call the footer function at the bottom of your script outside of any tab, column etc."
st.info(body, icon=":material/lightbulb:")
BODY = "Make sure to call the footer function at the bottom of your script outside of any tab, column etc."
st.info(BODY, icon=":material/lightbulb:")
footer = st.radio(
label="Footer",
options=("None", "UNDP (Default)", "UNDP DFx", "Custom"),
Expand All @@ -136,9 +136,9 @@

footer = footer.lower()
if "default" in footer:
code = """st_undp.footer()"""
CODE = """st_undp.footer()"""
elif "dfx" in footer:
code = """st_undp.footer("dfx")"""
CODE = """st_undp.footer("dfx")"""
elif "custom" in footer:
columns = {
"focus areas": {
Expand All @@ -153,12 +153,12 @@
},
}
st.json(columns)
code = """st_undp.footer(columns)"""
CODE = """st_undp.footer(columns)"""
else:
code = "None"
CODE = "None"
with st.expander("Show Code"):
st.code(code)
eval(code)
st.code(CODE)
eval(CODE)

with tab9:
logo = st.radio("Logo", ("UNDP", "PNUD"), key="logo", horizontal=True)
Expand All @@ -175,39 +175,39 @@
st.code(code)

with tab10:
code = """
CODE = """
st_undp.image_card(
src="app/static/aristotle.jpg",
summary="Nicomachean Ethics is Aristotle's best-known works on ethics: the science of the good for human life, that which is the goal or end at which all our actions aim",
href="https://en.wikipedia.org/wiki/Nicomachean_Ethics",
width=3,
)
""".strip()
eval(code)
eval(CODE)
with st.expander("Show Code"):
st.code(code)
st.code(CODE)

with tab11:
col1, col2 = st.columns(2)
with col1:
code = """
CODE = """
st_undp.stats_card(
value=3.14,
title="Pi",
text="Pi is a mathematical constant that is the ratio of a circle's circumference to its diameter",
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)
with col2:
code = """
CODE = """
st_undp.stats_card(
value=2.71,
title="Euler's constant",
text="Euler's constant is is a mathematical constant, defined as the limiting difference between the harmonic series and the natural logarithm",
)
"""
eval(code.strip())
eval(CODE.strip())
with st.expander("Show Code"):
st.code(code)
st.code(CODE)
Loading