How to use the idom.html.p 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 Input(message=None):
        message, set_message = idom.hooks.use_state(message)
        message_var.set(message)

        async def on_change(event):
            if event["value"] == "this is a test":
                set_message(event["value"])

        if message is None:
            return idom.html.input({"id": "input", "onChange": on_change})
        else:
            return idom.html.p({"id": "complete"}, ["Complete"])
github rmorshea / idom / tests / test_core / test_events.py View on Github external
async def Button(self):
        async def on_click(event):
            clicked.set(True)
            self.update()

        if not clicked.get():
            return idom.html.button({"onClick": on_click, "id": "click"}, ["Click Me!"])
        else:
            return idom.html.p({"id": "complete"}, ["Complete"])
github rmorshea / idom / tests / test_core / test_element.py View on Github external
async def Hello(self):
        return idom.html.p({"id": "hello"}, ["Hello World"])
github rmorshea / idom / tests / test_core / test_element.py View on Github external
async def CounterOnClick(self, count=0):
        count_thread.set(current_thread())

        @idom.event
        async def increment(event):
            self.update(count + 1)

        return idom.html.div(
            idom.html.button(
                {"onClick": increment, "id": "button"}, "click to increment"
            ),
            idom.html.p({"id": f"count-{count}"}, f"count: {count}"),
        )
github rmorshea / idom / tests / test_core / test_element.py View on Github external
async def Counter(self):

        count = count_queue.get()

        @self.animate
        async def increment(stop):
            if count < 5:
                self.update()
            else:
                stop()

        return idom.html.p({"id": f"counter-{count}"}, [f"Count: {count}"])
github rmorshea / idom / docs / source / widgets / todo.py View on Github external
async def Todo():
    items, set_items = idom.hooks.use_state([])

    async def add_new_task(event):
        if event["key"] == "Enter":
            set_items(items + [event["value"]])

    tasks = []

    for index, text in enumerate(items):

        async def remove_task(event, index=index):
            set_items(items[:index] + items[index + 1 :])

        task_text = idom.html.td(idom.html.p(text))
        delete_button = idom.html.td({"onClick": remove_task}, idom.html.button(["x"]))
        tasks.append(idom.html.tr(task_text, delete_button))

    task_input = idom.html.input({"onKeyDown": add_new_task})
    task_table = idom.html.table(tasks)

    return idom.html.div(task_input, task_table)