|
@@ -47,6 +47,11 @@ def logo_square() -> FileResponse:
|
|
return FileResponse(svg.PATH / 'logo_square.png', media_type='image/png')
|
|
return FileResponse(svg.PATH / 'logo_square.png', media_type='image/png')
|
|
|
|
|
|
|
|
|
|
|
|
+@app.post('/dark_mode')
|
|
|
|
+async def dark_mode(request: Request) -> None:
|
|
|
|
+ app.storage.browser['dark_mode'] = (await request.json()).get('value')
|
|
|
|
+
|
|
|
|
+
|
|
@app.middleware('http')
|
|
@app.middleware('http')
|
|
async def redirect_reference_to_documentation(request: Request,
|
|
async def redirect_reference_to_documentation(request: Request,
|
|
call_next: Callable[[Request], Awaitable[Response]]) -> Response:
|
|
call_next: Callable[[Request], Awaitable[Response]]) -> Response:
|
|
@@ -74,6 +79,13 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
'Examples': '/#examples',
|
|
'Examples': '/#examples',
|
|
'Why?': '/#why',
|
|
'Why?': '/#why',
|
|
}
|
|
}
|
|
|
|
+ dark_mode = ui.dark_mode(value=app.storage.browser.get('dark_mode'), on_change=lambda e: ui.run_javascript(f'''
|
|
|
|
+ fetch('/dark_mode', {{
|
|
|
|
+ method: 'POST',
|
|
|
|
+ headers: {{'Content-Type': 'application/json'}},
|
|
|
|
+ body: JSON.stringify({{value: {e.value}}}),
|
|
|
|
+ }});
|
|
|
|
+ ''', respond=False))
|
|
with ui.header() \
|
|
with ui.header() \
|
|
.classes('items-center duration-200 p-0 px-4 no-wrap') \
|
|
.classes('items-center duration-200 p-0 px-4 no-wrap') \
|
|
.style('box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1)'):
|
|
.style('box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1)'):
|
|
@@ -82,19 +94,32 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
with ui.link(target=index_page).classes('row gap-4 items-center no-wrap mr-auto'):
|
|
with ui.link(target=index_page).classes('row gap-4 items-center no-wrap mr-auto'):
|
|
svg.face().classes('w-8 stroke-white stroke-2 max-[550px]:hidden')
|
|
svg.face().classes('w-8 stroke-white stroke-2 max-[550px]:hidden')
|
|
svg.word().classes('w-24')
|
|
svg.word().classes('w-24')
|
|
- with ui.row().classes('max-lg:hidden'):
|
|
|
|
|
|
+
|
|
|
|
+ with ui.row().classes('max-[1050px]:hidden'):
|
|
for title, target in menu_items.items():
|
|
for title, target in menu_items.items():
|
|
ui.link(title, target).classes(replace='text-lg text-white')
|
|
ui.link(title, target).classes(replace='text-lg text-white')
|
|
|
|
+
|
|
search = Search()
|
|
search = Search()
|
|
search.create_button()
|
|
search.create_button()
|
|
- with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[445px]:hidden').tooltip('Discord'):
|
|
|
|
|
|
+
|
|
|
|
+ with ui.element().classes('max-[360px]:hidden'):
|
|
|
|
+ ui.button(icon='dark_mode', on_click=lambda: dark_mode.set_value(None)) \
|
|
|
|
+ .props('flat fab-mini color=white').bind_visibility_from(dark_mode, 'value', value=True)
|
|
|
|
+ ui.button(icon='light_mode', on_click=lambda: dark_mode.set_value(True)) \
|
|
|
|
+ .props('flat fab-mini color=white').bind_visibility_from(dark_mode, 'value', value=False)
|
|
|
|
+ ui.button(icon='brightness_auto', on_click=lambda: dark_mode.set_value(False)) \
|
|
|
|
+ .props('flat fab-mini color=white').bind_visibility_from(dark_mode, 'value', lambda mode: mode is None)
|
|
|
|
+
|
|
|
|
+ with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[455px]:hidden').tooltip('Discord'):
|
|
svg.discord().classes('fill-white scale-125 m-1')
|
|
svg.discord().classes('fill-white scale-125 m-1')
|
|
- with ui.link(target='https://www.reddit.com/r/nicegui/').classes('max-[395px]:hidden').tooltip('Reddit'):
|
|
|
|
|
|
+ with ui.link(target='https://www.reddit.com/r/nicegui/').classes('max-[405px]:hidden').tooltip('Reddit'):
|
|
svg.reddit().classes('fill-white scale-125 m-1')
|
|
svg.reddit().classes('fill-white scale-125 m-1')
|
|
- with ui.link(target='https://github.com/zauberzeug/nicegui/').tooltip('GitHub'):
|
|
|
|
|
|
+ with ui.link(target='https://github.com/zauberzeug/nicegui/').classes('max-[305px]:hidden').tooltip('GitHub'):
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
|
|
+
|
|
add_star().classes('max-[490px]:hidden')
|
|
add_star().classes('max-[490px]:hidden')
|
|
- with ui.row().classes('lg:hidden'):
|
|
|
|
|
|
+
|
|
|
|
+ with ui.row().classes('min-[1051px]:hidden'):
|
|
with ui.button(icon='more_vert').props('flat color=white round'):
|
|
with ui.button(icon='more_vert').props('flat color=white round'):
|
|
with ui.menu().classes('bg-primary text-white text-lg'):
|
|
with ui.menu().classes('bg-primary text-white text-lg'):
|
|
for title, target in menu_items.items():
|
|
for title, target in menu_items.items():
|
|
@@ -108,7 +133,7 @@ async def index_page(client: Client) -> None:
|
|
add_header()
|
|
add_header()
|
|
|
|
|
|
with ui.row().classes('w-full h-screen items-center gap-8 pr-4 no-wrap into-section'):
|
|
with ui.row().classes('w-full h-screen items-center gap-8 pr-4 no-wrap into-section'):
|
|
- svg.face(half=True).classes('stroke-black w-[200px] md:w-[230px] lg:w-[300px]')
|
|
|
|
|
|
+ svg.face(half=True).classes('stroke-black dark:stroke-white w-[200px] md:w-[230px] lg:w-[300px]')
|
|
with ui.column().classes('gap-4 md:gap-8 pt-32'):
|
|
with ui.column().classes('gap-4 md:gap-8 pt-32'):
|
|
title('Meet the *NiceGUI*.')
|
|
title('Meet the *NiceGUI*.')
|
|
subtitle('And let any browser be the frontend of your Python code.') \
|
|
subtitle('And let any browser be the frontend of your Python code.') \
|
|
@@ -244,8 +269,8 @@ async def index_page(client: Client) -> None:
|
|
.classes('text-white text-2xl md:text-3xl font-medium')
|
|
.classes('text-white text-2xl md:text-3xl font-medium')
|
|
ui.html('Fun-Fact: This whole website is also coded with NiceGUI.') \
|
|
ui.html('Fun-Fact: This whole website is also coded with NiceGUI.') \
|
|
.classes('text-white text-lg md:text-xl')
|
|
.classes('text-white text-lg md:text-xl')
|
|
- ui.link('Documentation', '/documentation') \
|
|
|
|
- .classes('rounded-full mx-auto px-12 py-2 text-white bg-white font-medium text-lg md:text-xl')
|
|
|
|
|
|
+ ui.link('Documentation', '/documentation').style('color: black !important') \
|
|
|
|
+ .classes('rounded-full mx-auto px-12 py-2 bg-white font-medium text-lg md:text-xl')
|
|
|
|
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1600px] mx-auto'):
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1600px] mx-auto'):
|
|
link_target('examples', '-50px')
|
|
link_target('examples', '-50px')
|
|
@@ -286,7 +311,7 @@ async def index_page(client: Client) -> None:
|
|
example_link('Lightbox', 'A thumbnail gallery where each image can be clicked to enlarge')
|
|
example_link('Lightbox', 'A thumbnail gallery where each image can be clicked to enlarge')
|
|
example_link('ROS2', 'Using NiceGUI as web interface for a ROS2 robot')
|
|
example_link('ROS2', 'Using NiceGUI as web interface for a ROS2 robot')
|
|
|
|
|
|
- with ui.row().classes('bg-primary w-full min-h-screen mt-16'):
|
|
|
|
|
|
+ with ui.row().classes('dark-box min-h-screen mt-16'):
|
|
link_target('why')
|
|
link_target('why')
|
|
with ui.column().classes('''
|
|
with ui.column().classes('''
|
|
max-w-[1600px] m-auto
|
|
max-w-[1600px] m-auto
|