|
@@ -10,6 +10,7 @@ if True:
|
|
|
|
|
|
import os
|
|
|
from pathlib import Path
|
|
|
+from typing import Optional
|
|
|
|
|
|
from fastapi import Request
|
|
|
from fastapi.responses import FileResponse, RedirectResponse
|
|
@@ -61,7 +62,7 @@ def add_head_html() -> None:
|
|
|
ui.add_head_html(f"<style>{(Path(__file__).parent / 'website' / 'static' / 'style.css').read_text()}</style>")
|
|
|
|
|
|
|
|
|
-def add_header() -> None:
|
|
|
+def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
|
menu_items = {
|
|
|
'Installation': '/#installation',
|
|
|
'Features': '/#features',
|
|
@@ -73,14 +74,12 @@ def add_header() -> None:
|
|
|
with ui.header() \
|
|
|
.classes('items-center duration-200 p-0 px-4 no-wrap') \
|
|
|
.style('box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1)'):
|
|
|
+ if menu:
|
|
|
+ ui.button(on_click=menu.toggle).props('flat color=white icon=menu round') \
|
|
|
+ .classes('max-[405px]:hidden lg:hidden')
|
|
|
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')
|
|
|
svg.word().classes('w-24')
|
|
|
- with ui.row().classes('lg:hidden'):
|
|
|
- with ui.menu().classes('bg-primary text-white text-lg') as menu:
|
|
|
- for title, target in menu_items.items():
|
|
|
- ui.menu_item(title, on_click=lambda _, target=target: ui.open(target))
|
|
|
- ui.button(on_click=menu.open).props('flat color=white icon=menu')
|
|
|
with ui.row().classes('max-lg:hidden'):
|
|
|
for title, target in menu_items.items():
|
|
|
ui.link(title, target).classes(replace='text-lg text-white')
|
|
@@ -88,7 +87,12 @@ def add_header() -> None:
|
|
|
svg.discord().classes('fill-white scale-125 m-1')
|
|
|
with ui.link(target='https://github.com/zauberzeug/nicegui/'):
|
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
|
- add_star()
|
|
|
+ add_star().classes('max-[460px]:hidden')
|
|
|
+ with ui.row().classes('lg:hidden'):
|
|
|
+ with ui.button().props('flat color=white icon=more_vert round'):
|
|
|
+ with ui.menu().classes('bg-primary text-white text-lg').props(remove='no-parent-event'):
|
|
|
+ for title, target in menu_items.items():
|
|
|
+ ui.menu_item(title, on_click=lambda _, target=target: ui.open(target))
|
|
|
|
|
|
|
|
|
@ui.page('/')
|
|
@@ -136,18 +140,25 @@ async def index_page(client: Client):
|
|
|
ui.html('<em>1.</em>').classes('text-3xl font-bold')
|
|
|
ui.markdown('Create __main.py__').classes('text-lg')
|
|
|
with python_window(classes='w-full h-52'):
|
|
|
- ui.markdown('''```python\n
|
|
|
-from nicegui import ui
|
|
|
+ ui.markdown('''
|
|
|
+ ```python\n
|
|
|
+ from nicegui import ui
|
|
|
|
|
|
-ui.label('Hello NiceGUI!')
|
|
|
+ ui.label('Hello NiceGUI!')
|
|
|
|
|
|
-ui.run()
|
|
|
-```''')
|
|
|
+ ui.run()
|
|
|
+ ```
|
|
|
+ ''')
|
|
|
with ui.column().classes('w-full max-w-md gap-2'):
|
|
|
ui.html('<em>2.</em>').classes('text-3xl font-bold')
|
|
|
ui.markdown('Install and launch').classes('text-lg')
|
|
|
with bash_window(classes='w-full h-52'):
|
|
|
- ui.markdown('```bash\npip3 install nicegui\npython3 main.py\n```')
|
|
|
+ ui.markdown('''
|
|
|
+ ```bash
|
|
|
+ pip3 install nicegui
|
|
|
+ python3 main.py
|
|
|
+ ```
|
|
|
+ ''')
|
|
|
with ui.column().classes('w-full max-w-md gap-2'):
|
|
|
ui.html('<em>3.</em>').classes('text-3xl font-bold')
|
|
|
ui.markdown('Enjoy!').classes('text-lg')
|
|
@@ -156,15 +167,18 @@ ui.run()
|
|
|
with ui.expansion('...or use Docker to run your main.py').classes('w-full gap-2 bold-links arrow-links'):
|
|
|
with ui.row().classes('mt-8 w-full justify-center items-center gap-8'):
|
|
|
ui.markdown('''
|
|
|
-With our [multi-arch Docker image](https://hub.docker.com/repository/docker/zauberzeug/nicegui)
|
|
|
-you can start the server without installing any packages.
|
|
|
+ With our [multi-arch Docker image](https://hub.docker.com/repository/docker/zauberzeug/nicegui)
|
|
|
+ you can start the server without installing any packages.
|
|
|
|
|
|
-The command searches for `main.py` in in your current directory and makes the app available at http://localhost:8888.
|
|
|
-''').classes('max-w-xl')
|
|
|
+ The command searches for `main.py` in in your current directory and makes the app available at http://localhost:8888.
|
|
|
+ ''').classes('max-w-xl')
|
|
|
with bash_window(classes='max-w-lg w-full h-52'):
|
|
|
- ui.markdown('```bash\n'
|
|
|
- 'docker run -it --rm -p 8888:8080 \\\n -v "$PWD":/app zauberzeug/nicegui\n'
|
|
|
- '```')
|
|
|
+ ui.markdown('''
|
|
|
+ ```bash
|
|
|
+ docker run -it --rm -p 8888:8080 \\
|
|
|
+ -v "$PWD":/app zauberzeug/nicegui
|
|
|
+ ```
|
|
|
+ ''')
|
|
|
|
|
|
with ui.column().classes('w-full p-8 lg:p-16 bold-links arrow-links max-w-[1600px] mx-auto'):
|
|
|
link_target('features', '-50px')
|
|
@@ -229,18 +243,16 @@ The command searches for `main.py` in in your current directory and makes the ap
|
|
|
with ui.row().classes('w-full text-lg leading-tight grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4'):
|
|
|
example_link('Slideshow', 'implements a keyboard-controlled image slideshow')
|
|
|
example_link('Authentication', 'shows how to use sessions to build a login screen')
|
|
|
- example_link(
|
|
|
- 'Modularization',
|
|
|
- 'provides an example of how to modularize your application into multiple files and reuse code')
|
|
|
- example_link(
|
|
|
- 'FastAPI',
|
|
|
- 'illustrates the integration of NiceGUI with an existing FastAPI application')
|
|
|
- example_link(
|
|
|
- 'Map',
|
|
|
- 'demonstrates wrapping the JavaScript library [leaflet](https://leafletjs.com/) to display a map at specific locations')
|
|
|
- example_link(
|
|
|
- 'AI Interface',
|
|
|
- 'utilizes the [replicate](https://replicate.com) library to perform voice-to-text transcription and generate images from prompts with Stable Diffusion')
|
|
|
+ example_link('Modularization',
|
|
|
+ 'provides an example of how to modularize your application into multiple files and reuse code')
|
|
|
+ example_link('FastAPI',
|
|
|
+ 'illustrates the integration of NiceGUI with an existing FastAPI application')
|
|
|
+ example_link('Map',
|
|
|
+ 'demonstrates wrapping the JavaScript library [leaflet](https://leafletjs.com/) '
|
|
|
+ 'to display a map at specific locations')
|
|
|
+ example_link('AI Interface',
|
|
|
+ 'utilizes the [replicate](https://replicate.com) library to perform voice-to-text '
|
|
|
+ 'transcription and generate images from prompts with Stable Diffusion')
|
|
|
example_link('3D Scene', 'creates a webGL view and loads an STL mesh illuminated with a spotlight')
|
|
|
example_link('Custom Vue Component', 'shows how to write and integrate a custom Vue component')
|
|
|
example_link('Image Mask Overlay', 'shows how to overlay an image with a mask')
|
|
@@ -300,15 +312,15 @@ The command searches for `main.py` in in your current directory and makes the ap
|
|
|
@ui.page('/documentation')
|
|
|
def documentation_page():
|
|
|
add_head_html()
|
|
|
- add_header()
|
|
|
- side_menu()
|
|
|
+ menu = side_menu()
|
|
|
+ add_header(menu)
|
|
|
ui.add_head_html('<style>html {scroll-behavior: auto;}</style>')
|
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1250px] mx-auto'):
|
|
|
section_heading('Reference, Demos and more', '*NiceGUI* Documentation')
|
|
|
- ui.markdown(
|
|
|
- 'This is the documentation for NiceGUI >= 1.0. '
|
|
|
- 'Documentation for older versions can be found at [https://0.9.nicegui.io/](https://0.9.nicegui.io/reference).'
|
|
|
- ).classes('bold-links arrow-links')
|
|
|
+ ui.markdown('''
|
|
|
+ This is the documentation for NiceGUI >= 1.0.
|
|
|
+ Documentation for older versions can be found at [https://0.9.nicegui.io/](https://0.9.nicegui.io/reference).
|
|
|
+ ''').classes('bold-links arrow-links')
|
|
|
documentation.create_full()
|
|
|
|
|
|
|