|
@@ -23,6 +23,7 @@ from nicegui import ui
|
|
from website import documentation, example_card, svg
|
|
from website import documentation, example_card, svg
|
|
from website.demo import bash_window, browser_window, python_window
|
|
from website.demo import bash_window, browser_window, python_window
|
|
from website.documentation_tools import create_anchor_name, element_demo, generate_class_doc
|
|
from website.documentation_tools import create_anchor_name, element_demo, generate_class_doc
|
|
|
|
+from website.search import Search
|
|
from website.star import add_star
|
|
from website.star import add_star
|
|
from website.style import example_link, features, heading, link_target, section_heading, side_menu, subtitle, title
|
|
from website.style import example_link, features, heading, link_target, section_heading, side_menu, subtitle, title
|
|
|
|
|
|
@@ -33,6 +34,7 @@ app.add_middleware(SessionMiddleware, secret_key=os.environ.get('NICEGUI_SECRET_
|
|
|
|
|
|
app.add_static_files('/favicon', str(Path(__file__).parent / 'website' / 'favicon'))
|
|
app.add_static_files('/favicon', str(Path(__file__).parent / 'website' / 'favicon'))
|
|
app.add_static_files('/fonts', str(Path(__file__).parent / 'website' / 'fonts'))
|
|
app.add_static_files('/fonts', str(Path(__file__).parent / 'website' / 'fonts'))
|
|
|
|
+app.add_static_files('/static', str(Path(__file__).parent / 'website' / 'static'))
|
|
|
|
|
|
|
|
|
|
@app.get('/logo.png')
|
|
@app.get('/logo.png')
|
|
@@ -76,9 +78,9 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
.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)'):
|
|
if menu:
|
|
if menu:
|
|
- ui.button(on_click=menu.toggle).props('flat color=white icon=menu round').classes('lg:hidden')
|
|
|
|
|
|
+ ui.button(on_click=menu.toggle, icon='menu').props('flat color=white round').classes('lg:hidden')
|
|
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')
|
|
|
|
|
|
+ svg.face().classes('w-8 stroke-white stroke-2 max-[550px]:hidden')
|
|
svg.word().classes('w-24')
|
|
svg.word().classes('w-24')
|
|
with ui.button(on_click=lambda: menu.open()).props('flat color=white icon=menu').classes('lg:hidden'):
|
|
with ui.button(on_click=lambda: menu.open()).props('flat color=white icon=menu').classes('lg:hidden'):
|
|
with ui.menu().classes('bg-primary text-white text-lg') as menu:
|
|
with ui.menu().classes('bg-primary text-white text-lg') as menu:
|
|
@@ -87,18 +89,20 @@ def add_header(menu: Optional[ui.left_drawer] = None) -> None:
|
|
with ui.row().classes('max-lg:hidden'):
|
|
with ui.row().classes('max-lg: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')
|
|
- with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[435px]:hidden').tooltip('Discord'):
|
|
|
|
|
|
+ search = Search()
|
|
|
|
+ search.create_button()
|
|
|
|
+ with ui.link(target='https://discord.gg/TEpFeAaF4f').classes('max-[445px]: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-[385px]:hidden').tooltip('Reddit'):
|
|
|
|
|
|
+ with ui.link(target='https://www.reddit.com/r/nicegui/').classes('max-[395px]: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/').tooltip('GitHub'):
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
svg.github().classes('fill-white scale-125 m-1')
|
|
- add_star().classes('max-[480px]:hidden')
|
|
|
|
|
|
+ add_star().classes('max-[490px]:hidden')
|
|
with ui.row().classes('lg:hidden'):
|
|
with ui.row().classes('lg:hidden'):
|
|
- with ui.button().props('flat color=white icon=more_vert round'):
|
|
|
|
|
|
+ with ui.button(icon='more_vert').props('flat color=white round'):
|
|
with ui.menu().classes('bg-primary text-white text-lg').props(remove='no-parent-event'):
|
|
with ui.menu().classes('bg-primary text-white text-lg').props(remove='no-parent-event'):
|
|
for title, target in menu_items.items():
|
|
for title, target in menu_items.items():
|
|
- ui.menu_item(title, on_click=lambda _, target=target: ui.open(target))
|
|
|
|
|
|
+ ui.menu_item(title, on_click=lambda target=target: ui.open(target))
|
|
|
|
|
|
|
|
|
|
@ui.page('/')
|
|
@ui.page('/')
|
|
@@ -209,7 +213,7 @@ async def index_page(client: Client) -> None:
|
|
features('insights', 'Visualization', [
|
|
features('insights', 'Visualization', [
|
|
'charts, diagrams and tables',
|
|
'charts, diagrams and tables',
|
|
'3D scenes',
|
|
'3D scenes',
|
|
- 'progress bars',
|
|
|
|
|
|
+ 'straight-forward data binding',
|
|
'built-in timer for data refresh',
|
|
'built-in timer for data refresh',
|
|
])
|
|
])
|
|
features('brush', 'Styling', [
|
|
features('brush', 'Styling', [
|
|
@@ -221,7 +225,7 @@ async def index_page(client: Client) -> None:
|
|
features('source', 'Coding', [
|
|
features('source', 'Coding', [
|
|
'routing for multiple pages',
|
|
'routing for multiple pages',
|
|
'auto-reload on code change',
|
|
'auto-reload on code change',
|
|
- 'straight-forward data binding',
|
|
|
|
|
|
+ 'persistent user sessions',
|
|
'Jupyter notebook compatibility',
|
|
'Jupyter notebook compatibility',
|
|
])
|
|
])
|
|
features('anchor', 'Foundation', [
|
|
features('anchor', 'Foundation', [
|
|
@@ -283,6 +287,7 @@ async def index_page(client: Client) -> None:
|
|
example_link('Chat with AI', 'a simple chat app with AI')
|
|
example_link('Chat with AI', 'a simple chat app with AI')
|
|
example_link('SQLite Database', 'CRUD operations on a SQLite database')
|
|
example_link('SQLite Database', 'CRUD operations on a SQLite database')
|
|
example_link('Pandas DataFrame', 'displays an editable [pandas](https://pandas.pydata.org) DataFrame')
|
|
example_link('Pandas DataFrame', 'displays an editable [pandas](https://pandas.pydata.org) DataFrame')
|
|
|
|
+ example_link('Lightbox', 'A thumbnail gallery where each image can be clicked to enlarge')
|
|
|
|
|
|
with ui.row().classes('bg-primary w-full min-h-screen mt-16'):
|
|
with ui.row().classes('bg-primary w-full min-h-screen mt-16'):
|
|
link_target('why')
|
|
link_target('why')
|
|
@@ -330,17 +335,13 @@ def documentation_page() -> None:
|
|
ui.add_head_html('<style>html {scroll-behavior: auto;}</style>')
|
|
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'):
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1250px] mx-auto'):
|
|
section_heading('Reference, Demos and more', '*NiceGUI* Documentation')
|
|
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')
|
|
|
|
documentation.create_full()
|
|
documentation.create_full()
|
|
|
|
|
|
|
|
|
|
@ui.page('/documentation/{name}')
|
|
@ui.page('/documentation/{name}')
|
|
async def documentation_page_more(name: str, client: Client) -> None:
|
|
async def documentation_page_more(name: str, client: Client) -> None:
|
|
- if not hasattr(ui, name):
|
|
|
|
- name = name.replace('_', '') # NOTE: "AG Grid" leads to anchor name "ag_grid", but class is `ui.aggrid`
|
|
|
|
|
|
+ if name == 'ag_grid':
|
|
|
|
+ name = 'aggrid' # NOTE: "AG Grid" leads to anchor name "ag_grid", but class is `ui.aggrid`
|
|
module = importlib.import_module(f'website.more_documentation.{name}_documentation')
|
|
module = importlib.import_module(f'website.more_documentation.{name}_documentation')
|
|
more = getattr(module, 'more', None)
|
|
more = getattr(module, 'more', None)
|
|
if hasattr(ui, name):
|
|
if hasattr(ui, name):
|
|
@@ -355,7 +356,7 @@ async def documentation_page_more(name: str, client: Client) -> None:
|
|
with side_menu() as menu:
|
|
with side_menu() as menu:
|
|
ui.markdown(f'[← back](/documentation#{create_anchor_name(back_link_target)})').classes('bold-links')
|
|
ui.markdown(f'[← back](/documentation#{create_anchor_name(back_link_target)})').classes('bold-links')
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1250px] mx-auto'):
|
|
with ui.column().classes('w-full p-8 lg:p-16 max-w-[1250px] mx-auto'):
|
|
- section_heading('Documentation', f'ui.*{name}*')
|
|
|
|
|
|
+ section_heading('Documentation', f'ui.*{name}*' if hasattr(ui, name) else f'*{name.replace("_", " ").title()}*')
|
|
with menu:
|
|
with menu:
|
|
ui.markdown('**Demos**' if more else '**Demo**').classes('mt-4')
|
|
ui.markdown('**Demos**' if more else '**Demo**').classes('mt-4')
|
|
element_demo(api)(getattr(module, 'main_demo'))
|
|
element_demo(api)(getattr(module, 'main_demo'))
|