-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlayout.py
88 lines (81 loc) · 2.7 KB
/
layout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64
from dash import dcc, html
def run_standalone_app(
app, app_title, repo_url, layout, callbacks, header_colors, filename
):
"""Run app as standalone app"""
app.layout = app_page_layout(
repo_url,
page_layout=layout(),
app_title=app_title,
standalone=True,
**header_colors()
)
# Register all callbacks
callbacks(app)
def app_page_layout(
repo_url,
page_layout,
app_title,
light_logo=True,
standalone=False,
bg_color="#006784",
font_color="#F3F6FA",
):
return html.Div(
id="main_page",
children=[
dcc.Location(id="url", refresh=False),
html.Div(
id="app-page-header",
children=[
html.A(
id="dashbio-logo",
children=[
html.Img(
src="data:image/png;base64,{}".format(
base64.b64encode(
open(
"./assets/plotly-dash-bio-logo.png", "rb"
).read()
).decode()
)
)
],
href="https://plotly.com/dash/",
),
html.H2(app_title),
html.A(
id="gh-link",
children=["View on GitHub"],
href=repo_url,
style={
"color": "white" if light_logo else "black",
"border": "solid 1px white"
if light_logo
else "solid 1px black",
},
),
html.Img(
src="data:image/png;base64,{}".format(
base64.b64encode(
open(
"./assets/GitHub-Mark-{}64px.png".format(
"Light-" if light_logo else ""
),
"rb",
).read()
).decode()
)
),
],
style={
"background": bg_color,
"color": font_color,
},
),
html.Div(id="app-page-content", children=page_layout),
],
)