How to use the idom.html.div function in idom

To help you get started, we’ve selected a few idom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rmorshea / idom / tests / test_core / test_hooks.py View on Github external
async def ComponentWithMemo():
        location, set_location = idom.hooks.use_state("left")
        memoized_func = idom.hooks.use_lru_cache(function_to_memoize, maxsize=2)
        last_memoized_location = memoized_func(location)

        async def on_left_button_click(event):
            set_location("left")

        async def on_center_button_click(event):
            set_location("center")

        async def on_right_button_click(event):
            set_location("right")

        return idom.html.div(
            idom.html.button(
                {"onClick": on_left_button_click, "id": "left-button"}, "left button"
            ),
            idom.html.button(
                {"onClick": on_center_button_click, "id": "center-button"},
                "center button",
            ),
            idom.html.button(
                {"onClick": on_right_button_click, "id": "right-button"}, "right button"
            ),
            f"Last triggered on click: {last_memoized_location}",
        )
github rmorshea / idom / tests / test_server / test_sanic / test_shared_state_client.py View on Github external
async def Counter(self, count):
        finalize(self, was_garbage_collected.set)
        return idom.html.div({"id": f"count-is-{count}"}, count)
github rmorshea / idom / tests / test_core / test_vdom.py View on Github external
def MyComponentWithChildrenAndAttributes(children, x):
        return idom.html.div({"x": x * 2}, children + ["world"])
github rmorshea / idom / tests / test_core / test_vdom.py View on Github external
def MyComponentWithChildren(children):
        return idom.html.div(children + ["world"])
github rmorshea / idom / tests / test_core / test_hooks.py View on Github external
async def ComponentWithMemo():
        location, set_location = idom.hooks.use_state("left")
        count = idom.hooks.use_memo(function_to_memoize, location)

        async def on_left_button_click(event):
            set_location("left")

        async def on_right_button_click(event):
            set_location("right")

        return idom.html.div(
            idom.html.button(
                {"onClick": on_left_button_click, "id": "left-button"}, "left button"
            ),
            idom.html.button(
                {"onClick": on_right_button_click, "id": "right-button"}, "right button"
            ),
            f"Memo trigger count: {count}",
        )
github rmorshea / idom / docs / source / widgets / custom_chart.py View on Github external
async def EventLog(self, event=None):
    return idom.html.div(
        {"class": "highlight"}, idom.html.pre(json.dumps(event, indent=2))
    )
github rmorshea / idom / docs / source / widgets / matplotlib_animation.py View on Github external
style = idom.html.style(
        [
            """
            .linked-inputs {margin-bottom: 20px}
            .linked-inputs input {width: 48%;float: left}
            .linked-inputs input + input {margin-left: 4%}
            """
        ]
    )

    async def restart(event):
        self.update()

    restart_button = idom.html.button({"onClick": restart}, "Run It Again ♻️")

    return idom.html.div(
        {"style": {"width": "60%"}},
        [restart_button, style, plot, mu_inputs, sigma_inputs],
    )
github rmorshea / idom / docs / source / widgets / snake.py View on Github external
def Grid(grid_size, block_size):
    return idom.html.div(
        {
            "style": {
                "height": f"{block_size * grid_size}px",
                "width": f"{block_size * grid_size}px",
            },
            "tabIndex": -1,
        },
        [
            idom.html.div(
                {"style": {"height": block_size}},
                [Block("white", block_size) for i in range(grid_size)],
            )
            for i in range(grid_size)
        ],
        event_handlers=idom.Events(),
    )
github rmorshea / idom / idom / core / _hooks.py View on Github external
async def render(self) -> "VdomDict":
        return idom.html.div(*self._children)