Skip to content

Commit 10bf6e3

Browse files
kmid5280quinn-doughertyjlubkenckoerberBrianThomasRoss
authored
422 Added line-breaks to sidebar
* define and add linebreaks to sidebar * add linebreak templates * define line break, add styles, change header margins * add top padding to sidebar to compensate for changed header margin * exempt linebreak from get ordered input keys method Co-authored-by: Quinn <[email protected]> Co-authored-by: Jason <[email protected]> Co-authored-by: ckoerber <[email protected]> Co-authored-by: Brian Ross <[email protected]>
1 parent fa3a772 commit 10bf6e3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/chime_dash/app/pages/sidebar.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
create_number_input,
1919
create_date_input,
2020
create_header,
21+
create_line_break,
2122
)
2223
from chime_dash.app.services.callbacks import SidebarCallbacks
2324

@@ -37,6 +38,7 @@
3738
},
3839
current_hospitalized={"type": "number", "min": 0, "step": 1},
3940
###
41+
line_break_1={"type": "linebreak"},
4042
spread_parameters={"type": "header", "size": "h4"},
4143
date_first_hospitalized={
4244
"type": "date",
@@ -52,6 +54,7 @@
5254
"percent": True,
5355
},
5456
###
57+
line_break_2={"type": "linebreak"},
5558
severity_parameters={"type": "header", "size": "h4"},
5659
hospitalized_rate={
5760
"type": "number",
@@ -79,6 +82,7 @@
7982
icu_los={"type": "number", "min": 0, "step": 1},
8083
ventilated_los={"type": "number", "min": 0, "step": 1},
8184
###
85+
line_break_3={"type": "linebreak"},
8286
display_parameters={"type": "header", "size": "h4"},
8387
n_days={"type": "number", "min": 30, "step": 1},
8488
current_date={
@@ -107,7 +111,7 @@ class Sidebar(Page):
107111
input_type_map = ReadOnlyDict(OrderedDict(
108112
(key, value["type"])
109113
for key, value in _SIDEBAR_ELEMENTS.items()
110-
if value["type"] not in ("header",)
114+
if value["type"] not in ("header", "linebreak")
111115
))
112116
input_value_map = ReadOnlyDict(OrderedDict(
113117
(key, {"number": "value", "date": "date"}.get(value, "value"))
@@ -129,6 +133,8 @@ def get_html(self) -> List[ComponentMeta]:
129133
element = create_date_input(idx, data, self.content, self.defaults)
130134
elif data["type"] == "header":
131135
element = create_header(idx, self.content)
136+
elif data["type"] == "linebreak":
137+
element = create_line_break(idx)
132138
else:
133139
raise ValueError(
134140
"Failed to parse input '{idx}' with data '{data}'".format(
@@ -151,6 +157,7 @@ def get_html(self) -> List[ComponentMeta]:
151157
"top": "56px",
152158
"width": "320px",
153159
"zIndex": 1,
160+
"padding-top": "1rem",
154161
},
155162
)
156163

src/chime_dash/app/utils/templates.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from numpy import mod
1212
from pandas import DataFrame
1313

14-
from dash_html_components import Table, Thead, Tbody, Tr, Td, Th, H4
14+
from dash_html_components import Table, Thead, Tbody, Tr, Td, Th, H4, Hr
1515
from dash_core_components import DatePickerSingle
1616
from dash_bootstrap_components import FormGroup, Label, Input, Checklist
1717

@@ -27,7 +27,13 @@
2727
HEADER_STYLE = {
2828
"fontSize": "1rem",
2929
"fontWeight": "bold",
30-
"margin": "2rem 0 1rem",
30+
"margin-bottom": "1rem",
31+
}
32+
33+
LINE_STYLE = {
34+
"width": "30%",
35+
"text-align": "center",
36+
"color": "#cccccc"
3137
}
3238

3339

@@ -154,6 +160,8 @@ def create_header(idx: str, content: Dict[str, str]):
154160

155161
return H4(id=idx, children=content[idx], style=HEADER_STYLE)
156162

163+
def create_line_break(idx: str):
164+
return Hr(id=idx, style=LINE_STYLE)
157165

158166
def create_date_input(
159167
idx: str, data: Dict[str, Any], content: Dict[str, str], defaults: Parameters

0 commit comments

Comments
 (0)