Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
63 lines (51 loc) · 1.55 KB
/
Copy pathapp.py
File metadata and controls
63 lines (51 loc) · 1.55 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
"""
Application entry point.
"""
from pathlib import Path
from shiny import App, reactive, ui
from undp_brand_yml.plotting import set_plotly_theme
from undp_design_system import footer, header, render_footer, render_header
from src import modules, include_markdown
set_plotly_theme()
theme = ui.Theme.from_brand(__file__)
app_ui = ui.page_fluid(
header("header"),
ui.navset_hidden(
ui.nav_panel(None, modules.example.get_ui("page1"), value="page1"),
ui.nav_panel(
None,
ui.div(include_markdown("www/about.md"), class_="p-5 vh-100"),
value="page2",
),
id="pages",
),
footer("footer"),
theme=theme,
)
def server(input, output, session):
@reactive.effect
@reactive.event(input.page_switch)
def switch_page():
"""
Reactive function to switch pages from the header.
"""
ui.update_navset("pages", selected=input.page_switch())
@render_header()
def header():
"""
Function to render the header. You can use it to customise the header based on app inputs if necessary.
"""
return theme.brand.meta.header | {
"navs": [
{"text": "Example", "value": "page1"},
{"text": "About", "value": "page2"},
],
}
@render_footer
def footer():
"""
Function to render the footer.
"""
return theme.brand.meta.footer
modules.example.get_server("page1")
app = App(app_ui, server, static_assets=Path(__file__).parent / "www")