Initial version.

This commit is contained in:
trading_peter 2022-04-29 20:32:47 +02:00
parent 6a3bd8da51
commit 1cf76404b8
4 changed files with 43 additions and 40 deletions

View File

@ -1 +1 @@
# tp-element
# tp-radio-group

View File

@ -1,14 +1,14 @@
{
"name": "@tp/tp-element",
"version": "0.0.1",
"name": "@tp/tp-radio-group",
"version": "1.0.0",
"description": "",
"main": "tp-element.js",
"main": "tp-radio-group.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitea.codeblob.work/tp-elements/tp-element.git"
"url": "https://gitea.codeblob.work/tp-elements/tp-radio-group.git"
},
"author": "trading_peter",
"license": "Apache-2.0",

View File

@ -1,35 +0,0 @@
/**
@license
Copyright (c) 2022 trading_peter
This program is available under Apache License Version 2.0
*/
import { LitElement, html, css } from 'lit';
class TpElement extends LitElement {
static get styles() {
return [
css`
:host {
display: block;
}
`
];
}
render() {
const { } = this;
return html`
`;
}
static get properties() {
return { };
}
}
window.customElements.define('tp-element', TpElement);

38
tp-radio-group.js Normal file
View File

@ -0,0 +1,38 @@
/**
@license
Copyright (c) 2022 trading_peter
This program is available under Apache License Version 2.0
*/
import { LitElement, html, css } from 'lit';
class TpRadioGroup extends LitElement {
static get styles() {
return [
css`
:host {
display: block;
}
`
];
}
render() {
return html`
<slot @checked=${this.updateValue}></slot>
`;
}
updateValue(e) {
const target = e.target;
const radios = this.querySelectorAll('tp-radio');
radios.forEach(radio => {
if (radio !== target) {
radio.checked = false;
}
});
}
}
window.customElements.define('tp-radio-group', TpRadioGroup);