File size: 714 Bytes
2b4d75c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Flex
# Use a flex card to tile multiple child cards along one dimension, with optional wrapping.
# #flex
# ---
import random

from faker import Faker

from h2o_wave import site, ui, pack, data

fake = Faker()

page = site['/demo']

c = page.add('example', ui.flex_card(
    box='1 1 1 1',
    direction='horizontal',
    justify='between',
    wrap='between',
    item_view='template',
    item_props=pack(dict(
        content='<div style="width:15px; height:15px; border-radius: 50%; background-color:{{#if loss}}red{{else}}green{{/if}}" title="{{code}}"/>'  # noqa: E501
    )),
    data=data('code loss', -10),
))
c.data = [[fake.cryptocurrency_code(), random.randint(0, 1)] for _ in range(10)]

page.save()