Exemple #1
0
async def serve(q: Q):
    if '#' in q.args:
        hash_ = q.args['#']
        q.page['nav'] = ui.form_card(box='1 1 2 5', items=[
            ui.text(f'#={hash_}'),
            ui.button(name='show_nav', label='Back', primary=True),
        ])
    else:
        q.page['nav'] = ui.nav_card(
            box='1 1 2 5',
            value='#menu/spam',
            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', disabled=True),
                ]),
                ui.nav_group('Help', items=[
                    ui.nav_item(name='#about', label='About', icon='Info'),
                    ui.nav_item(name='#support', label='Support', icon='Help'),
                ])
            ],
        )
    await q.page.save()
def card_sidebar() -> ui.NavCard:
    """
    Card for demo.
    """
    item_list = [
        ui.nav_group('Functions',
                     items=[
                         ui.nav_item(name='assign',
                                     label='Assign next action'),
                         ui.nav_item(name='record', label='Record results'),
                         ui.nav_item(name='add_people', label='Add people')
                     ])
    ]
    card = ui.nav_card(box=box_sidebar, items=item_list)

    return card
Exemple #3
0
async def setup_page(q: Q):
    q.page['meta'] = ui.meta_card(
        box='',
        title=app_title
    )

    q.page['header'] = ui.header_card(
        box='1 1 2 1',
        title=app_title,
        subtitle=f'{len(catalog)} Interactive Examples',
    )

    q.page['examples'] = ui.nav_card(
        box='1 2 2 -1',
        items=[
            ui.nav_group(
                label='Examples',
                items=[ui.nav_item(name=f'#{e.name}', label=e.title) for e in catalog.values()]
            ),
        ],
    )

    q.page['blurb'] = ui.form_card(
        box='3 1 5 3',
        items=[],
    )

    q.page['code'] = ui.frame_card(
        box='3 4 5 -1',
        title='',
        content='',
    )
    q.page['preview'] = ui.frame_card(
        box='8 1 5 -1',
        title='Preview',
        path='/demo',
    )
    await q.page.save()
Exemple #4
0
async def serve(q: Q):
    if '#' in q.args and not q.args.show_nav:
        hash_ = q.args['#']
        q.page.drop()
        q.page['redirect'] = ui.form_card(box='1 1 2 5',
                                          items=[
                                              ui.text(f'#={hash_}'),
                                              ui.button(name='show_nav',
                                                        label='Back',
                                                        primary=True),
                                          ])
    else:
        q.page['meta'] = ui.meta_card(box='', redirect='#')
        q.page['nav1'] = ui.nav_card(
            box='1 1 2 -1',
            value='#menu/spam',
            title='H2O Wave',
            subtitle='And now for something completely different!',
            image=
            'https://www.h2o.ai/wp-content/themes/h2o2018/templates/dist/images/h2o_logo.svg',
            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',
                                             disabled=True),
                             ]),
                ui.nav_group('Help',
                             items=[
                                 ui.nav_item(name='#about',
                                             label='About',
                                             icon='Info'),
                                 ui.nav_item(name='#support',
                                             label='Support',
                                             icon='Help'),
                             ])
            ],
            secondary_items=[
                ui.inline(items=[
                    ui.persona(title='John Doe',
                               subtitle='Software developer',
                               size='s',
                               image=persona),
                    ui.menu(items=[
                        ui.command(
                            name='profile', label='Profile', icon='Contact'),
                        ui.command(name='preferences',
                                   label='Preferences',
                                   icon='Settings'),
                        ui.command(
                            name='logout', label='Logout', icon='SignOut'),
                    ])
                ]),
            ],
        )
        q.page['nav2'] = ui.nav_card(
            box='3 1 2 -1',
            value='#menu/ham',
            persona=ui.persona(title='John Doe',
                               subtitle='Data Scientist',
                               caption='Online',
                               size='xl',
                               image=persona),
            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',
                                             disabled=True),
                             ]),
                ui.nav_group('Help',
                             items=[
                                 ui.nav_item(name='#about',
                                             label='About',
                                             icon='Info'),
                                 ui.nav_item(name='#support',
                                             label='Support',
                                             icon='Help'),
                             ])
            ],
            secondary_items=[
                ui.button(name='logout', label='Logout', width='100%')
            ],
            color='primary')
    await q.page.save()