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

[ENH] Make stacked bar plot widths responsive + basic enhancements for smaller screen usability #99

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Changes from all 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
32 changes: 28 additions & 4 deletions climate_emotions_map/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@
}


def create_mobile_warning():
"""Create an alert to be displayed on mobile devices or small screens."""
return dmc.Alert(
children=[
"Graphics on this site are not optimized for mobile devices or small screens. ",
"For the best experience, please view it full-screen on a laptop or desktop.",
],
title="Larger screen size recommended",
color="yellow",
hiddenFrom="sm",
mb="sm",
)


def create_question_dropdown():
"""
Create the dropdown for subquestions grouped by question.
Expand Down Expand Up @@ -210,7 +224,7 @@ def create_design_credit():
style={"display": "inline"},
),
" - Alyssa Dai, Michelle Wang, Nikhil Bhagwat, Arman Jahanpour, Kendra Oudyk, Rémi Gau, Sebastian Urchs - ",
"contributed to the creation of the web app which is provided as is with no guarantee, ",
"created this web app which is provided as is with no guarantee, ",
"but were not involved in the design, analysis, and reporting of the project. ",
"The project results and interpretation are entirely the responsibility of the article authors.",
],
Expand Down Expand Up @@ -284,6 +298,7 @@ def create_app_subtitle():
style={"display": "inline"},
size="sm",
fw=500,
visibleFrom="sm",
)


Expand Down Expand Up @@ -466,7 +481,9 @@ def create_bar_plots_for_question(question_id: str, subquestion_id: str):
][question_id],
config=DCC_GRAPH_CONFIG,
),
w=1200,
fluid=True,
# TODO: Reduce currently hard-coded L/R margins in Plotly fig to fill up more available width
w={"base": "100vw", "lg": 1000},
# size="xl",
)
return figure
Expand Down Expand Up @@ -495,7 +512,9 @@ def create_selected_question_bar_plot():
),
config=DCC_GRAPH_CONFIG,
),
w=1200,
fluid=True,
# TODO: Reduce currently hard-coded L/R margins in Plotly fig to fill up more available width
w={"base": "100vw", "lg": 1000},
)

return dmc.Stack(
Expand Down Expand Up @@ -602,6 +621,7 @@ def create_main():
mx="xs",
fluid=True,
children=[
create_mobile_warning(),
create_map_title(),
dmc.Grid(
[
Expand Down Expand Up @@ -632,5 +652,9 @@ def construct_layout():
return dmc.AppShell(
children=[create_header(), create_navbar(), create_main()],
header={"height": HEADER_HEIGHT},
navbar={"width": 300},
navbar={
"width": 300,
"breakpoint": "sm",
"collapsed": {"mobile": True},
},
)