-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
151 lines (139 loc) · 4.5 KB
/
app.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
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
import dash_bootstrap_components as dbc
import dash
from dash import Dash, dcc, html, Input, Output, State
app = Dash(
__name__,
use_pages=True,
title="Michelin Guide",
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.FONT_AWESOME],
)
server = app.server
# navbar -------------------------------------------------
navbar = dbc.Navbar(
dbc.Container(
[
html.A(
# logo -------------------------------------------------
dbc.Row(
[
dbc.Col(
html.Img(
src="assets/logos/logo.svg",
height="35px",
),
),
# title -------------------------------------------------
dbc.Col(
dbc.NavbarBrand(
"Michelin World Guide",
className="navbar-title",
)
),
],
),
href="#",
style={"textDecoration": "none"},
),
# icons + language button -------------------------------------------------
dbc.NavbarToggler(id="navbar-toggler"),
dbc.Collapse(
dbc.Nav(
[
dbc.NavItem(
dbc.NavLink(
html.I(className="fab fa-github navbar-icon"),
href="https://github.com/mayaradaher/challenge-Michelin",
target="_blank",
)
),
dbc.NavItem(
dbc.NavLink(
html.I(className="fab fa-linkedin navbar-icon"),
href="https://linkedin.com/in/mayaradaher",
target="_blank",
)
),
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(
"English", href="/en", id="LinkOne"
),
dbc.DropdownMenuItem("Português", href="/br"),
],
nav=True,
in_navbar=True,
label="Select language",
className="nav-item",
),
],
className="ms-auto",
navbar=True,
),
id="navbar-collapse",
is_open=False,
navbar=True,
),
],
fluid=True,
className="navbar",
),
# navbar style -------------------------------------------------
color="#bd2333",
dark=True,
style={"height": "80px", "width": "100%"},
)
content = html.Div(
className="page-content",
)
footer = dbc.Container(
dbc.Row(
dbc.Col(
html.Hr(
className="footer",
),
),
),
fluid=True,
)
@app.callback(
Output("navbar-collapse", "is_open"),
[Input("navbar-toggler", "n_clicks"), Input("LinkOne", "n_clicks")],
[State("navbar-collapse", "is_open")],
)
def toggle_navbar_collapse(n, nBis, is_open):
if n or nBis:
return not is_open
return is_open
# defining font-awesome and fonts -------------------------------------------------
app.index_string = """
<!DOCTYPE html>
<html>
<head>
{%metas%}
{%css%}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="icon" href="/assets/logos/favicon.svg" type="image/x-icon">
</head>
<body>
{%app_entry%}
{%config%}
{%scripts%}
{%renderer%}
</body>
</html>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
</style>
"""
# layout -------------------------------------------------
app.layout = html.Div(
[
dcc.Location(id="url", pathname="/en"),
navbar,
content,
dash.page_container,
footer,
]
)
if __name__ == "__main__":
app.run_server(debug=False)