mirror of
https://github.com/pyscript/pyscript.git
synced 2026-03-12 07:01:10 -04:00
precommit fixes
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from pyodide.ffi import create_proxy
|
||||
from pyscript import display, document, when, window
|
||||
from pyweb import media, pydom
|
||||
|
||||
from pyscript import display, document, when, window
|
||||
|
||||
devicesSelect = pydom["#devices"][0]
|
||||
video = pydom["video"][0]
|
||||
devices = {}
|
||||
|
||||
@@ -2,9 +2,10 @@ import random
|
||||
import time
|
||||
from datetime import datetime as dt
|
||||
|
||||
from pyscript import display, when
|
||||
from pyweb import pydom
|
||||
|
||||
from pyscript import display, when
|
||||
|
||||
|
||||
@when("click", "#just-a-button")
|
||||
def on_click():
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
print("tests starting")
|
||||
import pytest
|
||||
|
||||
from pyscript import window
|
||||
|
||||
args = window.location.search.replace("?", "").split("&")
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from pyscript import document, when
|
||||
from pyweb import pydom
|
||||
|
||||
from pyscript import document, when
|
||||
|
||||
|
||||
class TestDocument:
|
||||
def test__element(self):
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from textwrap import dedent
|
||||
|
||||
import examples
|
||||
from pyscript import when, window
|
||||
from pyweb import pydom
|
||||
from pyweb.ui import elements as el
|
||||
from pyweb.ui import shoelace
|
||||
from pyweb.ui.markdown import markdown
|
||||
|
||||
from pyscript import when, window
|
||||
|
||||
# Style dictionary for code blocks
|
||||
STYLE_CODE_BLOCK = {"text-align": "left", "background-color": "#eee", "padding": "20px"}
|
||||
|
||||
@@ -27,29 +28,37 @@ def create_component_details(component):
|
||||
|
||||
"""
|
||||
# Get the example from the examples catalog
|
||||
examples_gallery = examples.kits['shoelace']
|
||||
examples_gallery = examples.kits["shoelace"]
|
||||
example = examples_gallery[component]["instance"]
|
||||
details = example.__doc__ or f"Details missing for component {component}"
|
||||
|
||||
div = el.div([
|
||||
# Title and description (description is picked from the class docstring)
|
||||
el.h1(component),
|
||||
markdown(details),
|
||||
# Example section
|
||||
el.h2("Example:"),
|
||||
el.div([
|
||||
example,
|
||||
shoelace.Details(
|
||||
el.div(examples_gallery[component]["code"], style=STYLE_CODE_BLOCK),
|
||||
summary="View Code", style={"background-color": "gainsboro"},
|
||||
),
|
||||
],
|
||||
style={
|
||||
"border-radius": "3px",
|
||||
"background-color": "var(--sl-color-neutral-50)",
|
||||
"margin-bottom": "1.5rem"
|
||||
}
|
||||
)], style={"margin": "20px"})
|
||||
div = el.div(
|
||||
[
|
||||
# Title and description (description is picked from the class docstring)
|
||||
el.h1(component),
|
||||
markdown(details),
|
||||
# Example section
|
||||
el.h2("Example:"),
|
||||
el.div(
|
||||
[
|
||||
example,
|
||||
shoelace.Details(
|
||||
el.div(
|
||||
examples_gallery[component]["code"], style=STYLE_CODE_BLOCK
|
||||
),
|
||||
summary="View Code",
|
||||
style={"background-color": "gainsboro"},
|
||||
),
|
||||
],
|
||||
style={
|
||||
"border-radius": "3px",
|
||||
"background-color": "var(--sl-color-neutral-50)",
|
||||
"margin-bottom": "1.5rem",
|
||||
},
|
||||
),
|
||||
],
|
||||
style={"margin": "20px"},
|
||||
)
|
||||
return div
|
||||
|
||||
|
||||
@@ -68,12 +77,14 @@ def add_component_section(component, parent_div):
|
||||
el.a(component, href="#"),
|
||||
style={"display": "block", "text-align": "center", "margin": "auto"},
|
||||
)
|
||||
|
||||
# Create a handler that opens the component details when the link is clicked
|
||||
@when("click", div)
|
||||
def _change():
|
||||
new_main = create_component_details(component)
|
||||
main_area.html = ""
|
||||
main_area.append(new_main)
|
||||
|
||||
# Add the new link element to the parent div (left panel)
|
||||
parent_div.append(div)
|
||||
return div
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from pyscript import when
|
||||
from pyweb import pydom
|
||||
from pyweb.ui import elements as el
|
||||
from pyweb.ui.shoelace import (
|
||||
@@ -12,6 +11,8 @@ from pyweb.ui.shoelace import (
|
||||
Rating,
|
||||
)
|
||||
|
||||
from pyscript import when
|
||||
|
||||
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
||||
details_code = """
|
||||
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
||||
|
||||
@@ -3,6 +3,7 @@ import js
|
||||
js.document.body.append("document patch ")
|
||||
|
||||
import a
|
||||
|
||||
from pyscript import RUNNING_IN_WORKER, display, sync
|
||||
|
||||
display("Hello World", target="test", append=True)
|
||||
|
||||
Reference in New Issue
Block a user