Brython-components is an easy implementation of brython's webcomonent
Project description
Brython-components
Brython-components is an easy implementation of brython's webcomonent.
Installation
Use the package manager pip to install.
pip install brip
brip install brython-components
Usage
file.html
<popup-info>
<span slot="data-text">Popup info data</span>
</popup-info>
file.py
from browser import html
from brython_components import bind, customElement, defineElement, react
html.maketag("SLOT")
@defineElement("popup-info")
class PopupInfo(customElement):
def __init__(self):
super().__init__()
self.render_root <= html.STYLE('''
.wrapper {
position: relative;
}
.info {
font-size: 0.8rem;
width: 200px;
display: inline-block;
border: 1px solid black;
padding: 10px;
background: white;
border-radius: 10px;
opacity: 0;
transition: 0.6s all;
position: absolute;
top: 20px;
left: 10px;
z-index: 3;
}
.icon:hover + .info, .icon:focus + .info {
opacity: 1;
}
''')
wrapper = html.SPAN(Class="wrapper")
icon = html.SPAN(Class="icon", tabindex="0")
wrapper <= icon
info = html.SPAN(Class="info")
info <= html.SLOT(name="data-text")
wrapper <= info
self.render_root <= wrapper
@bind(".icon", "click")
def deactivate(self, event):
info = self.render_root.select_one(".info")
icon = event.target
if not info.style.opacity:
info.style["opacity"] = 1
icon.style["text-decoration"] = "line-through"
else:
info.style["opacity"] = ""
icon.style["text-decoration"] = ""
@react(".icon")
def completed(self, targets):
targets[0].text = ":) hover me"
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file brython_components-0.3.1.tar.gz
.
File metadata
- Download URL: brython_components-0.3.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c739a3d38d95ad47039536b9769fbc4a4659f103e0a987186749f6886b4b3712 |
|
MD5 | 24680adf6e2be2d5f15c7faf006eca8d |
|
BLAKE2b-256 | cca8ab1ce602c18d326980e89953799e64653b6c246bb30d831518cb27ccbf06 |
File details
Details for the file brython_components-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: brython_components-0.3.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.9 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76b339b84275abbb30ca755cc6ba6e2cc17d8f19ac8b1b358e43b0f676ae3b1b |
|
MD5 | 79ddf0e04706facc26d3e25ef089d66d |
|
BLAKE2b-256 | 22f6c8f6f9b422b450aac319753ae5dead79554f77831271e263e289beee2c95 |