Skip to content

Commit

Permalink
fix: Form visibility #484
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed May 18, 2021
1 parent eb2ea68 commit cde989d
Show file tree
Hide file tree
Showing 72 changed files with 766 additions and 977 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@
"-oidc-redirect-url",
"http://localhost:10101/_auth/callback",
]
},
{
"type": "node",
"request": "launch",
"name": "Debug Wavegen",
"skipFiles": [
"<node_internals>/**"
],
"cwd": "${workspaceFolder}/tools/wavegen",
"args": [
"../../ui/src",
"../../py/h2o_wave",
"../../r/R"
],
"preLaunchTask": "tsc: build - tools/wavegen/tsconfig.json",
"program": "build/wavegen.js",
"outFiles": [
"build/**/*.js"
]
}
]
}
2 changes: 1 addition & 1 deletion githooks/pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function runRelatedTests(command, stagedFiles) {
const
files = execSync('git diff --cached --name-only --diff-filter=d').toString().split('\n').filter(Boolean).reduce((groups, f) => {
if (f.match(/^ui.+(ts|tsx)/)) groups.uiTs.push(f)
else if (f.match(/^tools\/wavegen.+(ts|tsx)/)) groups.uiTs.push(f)
else if (f.match(/^tools\/wavegen.+(ts|tsx)/)) groups.wavegenTs.push(f)
else if (f.endsWith('.py')) groups.py.push(f)
else if (f.endsWith('.go')) groups.go.push(f)
else if (f.endsWith('.md')) groups.md.push(f)
Expand Down
41 changes: 41 additions & 0 deletions py/examples/form_visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Form / Visible
# Use "visible" property to control whether form element should be shown / hidden.
# ---
from h2o_wave import main, app, Q, ui, pack, data


@app('/demo')
async def serve(q: Q):
if not q.client.initialized:
q.page['example'] = ui.form_card(box='1 1 4 10', items=[
ui.text_xl(content='First text'),
ui.text_l(content='Second text'),
ui.text_m(content='Third text'),
ui.text_s(content='Fourth text'),
ui.inline([
ui.button(name='left1', label='Left1'),
ui.button(name='left2', label='Left2'),
ui.button(name='left3', label='Left3'),
]),
ui.buttons(justify='end', items=[
ui.button(name='right1', label='Right1'),
ui.button(name='right2', label='Right2'),
ui.button(name='right3', label='Right3'),
]),
ui.buttons(items=[ui.button(name='show', label='Show'), ui.button(name='hide', label='Hide')])
])
q.client.initialized = True
items = q.page['example'].items
items_to_hide = [
items[0].text_xl,
items[2].text_m,
items[4].inline.items[0].button,
items[5].buttons.items[2].button
]
if q.args.hide:
for i in items_to_hide:
i.visible = False
if q.args.show:
for i in items_to_hide:
i.visible = True
await q.page.save()
1 change: 1 addition & 0 deletions py/examples/tour.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ layout.py
layout_size.py
layout_responsive.py
form.py
form_visibility.py
text.py
text_sizes.py
label.py
Expand Down

0 comments on commit cde989d

Please sign in to comment.