Created
September 6, 2022 16:13
-
-
Save mturoci/e9e93b5442b1f7f2842744a854bc4c79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from h2o_wave import main, app, Q, ui | |
@app('/') | |
async def serve(q: Q): | |
# Check if a link is clicked or active in URL. | |
if q.args['#'] is not None: | |
# Set it to local state. | |
q.client.current_nav = f'#{q.args["#"]}' | |
# Create a navigation card. | |
q.page['nav'] = ui.nav_card( | |
box='1 1 2 -1', | |
# Use saved value or go for a default. | |
value=q.client.current_nav or '#menu/spam', | |
title='H2O Wave', | |
items=[ | |
ui.nav_group('Menu', items=[ | |
ui.nav_item(name='#menu/spam', label='Spam'), | |
ui.nav_item(name='#menu/ham', label='Ham'), | |
ui.nav_item(name='#menu/eggs', label='Eggs'), | |
ui.nav_item(name='#menu/toast', label='Toast'), | |
]) | |
] | |
) | |
await q.page.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment