Ejemplo n.º 1
0
def test_module_from_url():
    url = "https://code.jquery.com/jquery-3.5.0.js"
    jquery = idom.Module(url)
    assert jquery.url == url
    with pytest.raises(ValueError, match="Module is not installed locally"):
        jquery.name
    with pytest.raises(ValueError, match="Module is not installed locally"):
        jquery.delete()
Ejemplo n.º 2
0
def test_module_deletion():
    # also test install
    jquery = idom.Module("jquery", install="[email protected]")
    assert idom.client.web_module_exists(jquery.name)
    with idom.client.web_module_path(jquery.name).open() as f:
        assert "jQuery JavaScript Library v3.5.0" in f.read()
    jquery.delete()
    assert not idom.client.web_module_exists(jquery.name)
Ejemplo n.º 3
0
def test_module_from_url():
    url = "https://code.jquery.com/jquery-3.5.0.js"
    jquery = idom.Module(url)
    assert jquery.url == url
Ejemplo n.º 4
0
def test_reference_pre_installed_module(victory):
    assert victory.url == idom.Module("victory").url
Ejemplo n.º 5
0
import idom

victory = idom.Module("victory")

VictoryBar = victory.Import("VictoryBar")

display(VictoryBar, {"style": {"parent": {"width": "500px"}}})
Ejemplo n.º 6
0
def test_module_cannot_have_source_and_install():
    with pytest.raises(ValueError, match=r"Both .* were given."):
        idom.Module("something",
                    install="something",
                    source=HERE / "something.js")
Ejemplo n.º 7
0
from pathlib import Path

import idom

path_to_source_file = Path(__file__).parent / "super_simple_chart.js"
ssc = idom.Module("super-simple-chart", source_file=path_to_source_file)

idom.run(
    idom.component(lambda: ssc.SuperSimpleChart({
        "data": [
            {
                "x": 1,
                "y": 2
            },
            {
                "x": 2,
                "y": 4
            },
            {
                "x": 3,
                "y": 7
            },
            {
                "x": 4,
                "y": 3
            },
            {
                "x": 5,
                "y": 5
            },
            {
Ejemplo n.º 8
0
import json
from pathlib import Path

import idom


here = Path(__file__).parent
custom_chart_path = here / "custom_chart.js"
ClickableChart = idom.Module("chart", source=custom_chart_path).Import("ClickableChart")


data = [
    {"x": 1, "y": 2},
    {"x": 2, "y": 4},
    {"x": 3, "y": 7},
    {"x": 4, "y": 3},
    {"x": 5, "y": 5},
]


@idom.element
async def EventLog(self, event=None):
    return idom.html.div(
        {"class": "highlight"}, idom.html.pre(json.dumps(event, indent=2))
    )


@idom.element
async def ShowChartClicks(self):

    log = EventLog({})
import idom

semantic_ui = idom.Module("semantic-ui-react")
Button = semantic_ui.Import("Button")

semantic_ui_style = idom.html.link({
    "rel":
    "stylesheet",
    "href":
    "//cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css",
})


def pre_seperated(*args):
    return idom.html.pre({"style": {
        "white-space": "pre-wrap"
    }}, "\n".join(map(str, args)))


@idom.element
async def PrimarySecondaryButtons(self, message=None, event=None, info=None):
    async def on_click_primary(event, info):
        self.update("Primary Clicked:", event, info)

    async def on_click_secondary(event, info):
        self.update("Secondary Clicked:", event, info)

    return idom.html.div([
        semantic_ui_style,
        Button({
            "primary": True,