浏览代码

add header to reference page

Falko Schindler 2 年之前
父节点
当前提交
522f67987d
共有 1 个文件被更改,包括 12 次插入7 次删除
  1. 12 7
      main.py

+ 12 - 7
main.py

@@ -38,27 +38,31 @@ def add_head_html() -> None:
     ''')
 
 
-@ui.page('/')
-async def index_page(client: Client):
-    add_head_html()
-    client.content.classes(remove='q-pa-md gap-4')
-
+def add_header() -> None:
     with ui.header() \
             .classes('items-center') \
             .style(f'background-color: {ACCENT_COLOR}; height: {HEADER_HEIGHT}') \
             .props('elevated'):
         ui.html((STATIC / 'happy_face.svg').read_text()).classes('w-8 stroke-white')
-        ui.html((STATIC / 'nicegui_word.svg').read_text()).classes('w-24')
+        with ui.link(target=index_page):
+            ui.html((STATIC / 'nicegui_word.svg').read_text()).classes('w-24')
         with ui.row().classes('items-center ml-auto'):
             ui.link('Features').classes('text-lg').style('color: white!important')
             ui.link('Installation').classes('text-lg').style('color: white!important')
             ui.link('Documentation').classes('text-lg').style('color: white!important')
-            ui.link('API Reference').classes('text-lg').style('color: white!important')
+            ui.link('API Reference', reference_page).classes('text-lg').style('color: white!important')
             ui.link('Docker').classes('text-lg').style('color: white!important')
             ui.link('Deployment').classes('text-lg').style('color: white!important')
             with ui.link(target='https://github.com/zauberzeug/nicegui/'):
                 ui.html((STATIC / 'github.svg').read_text()).classes('fill-white scale-125 m-1')
 
+
+@ui.page('/')
+async def index_page(client: Client):
+    client.content.classes(remove='q-pa-md gap-4')
+    add_head_html()
+    add_header()
+
     with ui.row() \
             .classes('w-full q-pa-md items-center gap-12 no-wrap') \
             .style(f'height: calc(100vh - {HEADER_HEIGHT}); transform: translateX(-250px)'):
@@ -93,6 +97,7 @@ async def index_page(client: Client):
 @ui.page('/reference')
 def reference_page():
     add_head_html()
+    add_header()
     reference.create_full()