-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
154 lines (135 loc) · 4 KB
/
app.py
File metadata and controls
154 lines (135 loc) · 4 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from dash import Dash, html, dcc, Output,Input, callback, page_container, ALL, ctx
import dash_mantine_components as dmc
app = Dash(
__name__,
use_pages=True,
suppress_callback_exceptions=True,
external_scripts=[
'https://cdn.jsdelivr.net/npm/apexcharts',
# These are served locally
# 'https://code.highcharts.com/highcharts.js',
# 'http://code.highcharts.com/highcharts-more.js',
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js',
'https://d3js.org/d3.v6.min.js',
'https://d3js.org/d3.v4.js',
'https://d3js.org/d3-geo-projection.v2.min.js',
{
'src': 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js',
'integrity': 'sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="',
'crossorigin': ''
},
],
external_stylesheets = [
{
'href': 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css',
'rel': 'stylesheet',
'integrity': 'sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=',
'crossorigin': ''
},
],
)
server = app.server
_pages = {
'apexcharts':'https://apexcharts.com/',
'highcharts':'https://www.highcharts.com/demo' ,
'leaflet':'https://leafletjs.com/',
'd3js':'https://d3js.org/'
}
focusLinkStyle = {
'width':'70px',
'height':'70px',
'margin':'-20px',
'backgroundColor':'rgb(255, 255, 255)',
'borderRadius':'50%',
'padding':'15px',
'boxShadow': '0 0 50px #ccc'
}
def page_link (pageHref):
if pageHref == 'd3js':
href = "/"
style = focusLinkStyle
else:
href = pageHref
style = {}
return dcc.Link(
href= href,
children =[
dmc.ActionIcon(
id={"type": "pages-links", "index": pageHref},
n_clicks = 0,
style = style,
children = [
dmc.Image(src=f"/assets/svg/{pageHref}.svg", width='100%')
]
)
]
)
def goToSite(link, logo):
return html.A(
href=link,
target="_blank",
children = [
dmc.Button(
"Visite Library",
variant="subtle",
leftIcon=dmc.Image(src=f"/assets/svg/{logo}.svg", width=25),
)
]
)
app.layout = html.Div(
id = 'dash-app-layout',
children = [
html.A(
href='https://github.com/leberber/dashJsLibraries/tree/main',
target="_blank",
className = "githubLogo",
children = [
dmc.ActionIcon(
variant="subtle",
children = [
dmc.Image(src=f"/assets/svg/github.svg", width=25),
],
)
]
),
html.Div(
id = 'goToSiteButton',
children = [
goToSite('https://d3js.org/', 'd3js')
]
),
html.Div(
id = 'dash-page-navigation-bar',
children = [
page_link(p) for p in _pages
]
),
html.Div(
id = 'dash-page-container',
children = [
page_container
]
)
]
)
@callback(
Output('goToSiteButton', 'children'),
Output({'type': 'pages-links', 'index': ALL}, 'style'),
Output({'type': 'pages-links', 'index': ALL}, 'n_clicks'),
Input({'type': 'pages-links', 'index': ALL}, 'n_clicks'),
prevent_initial_call = True
)
def styleCurrentPage(id):
idx= ctx.triggered_id.index
pageIndex = id.index(1)
styles = [{'backgroundColor':'transparent'}] * len(id)
styles[pageIndex] = focusLinkStyle
return [
goToSite(_pages[idx], idx),
styles,
[0] * len(id)
]
if __name__ == '__main__':
app.run_server(
port=8070, debug = True
)