From 1cf76404b80883ed3132e0237c8e51c9d276d4a7 Mon Sep 17 00:00:00 2001 From: trading_peter Date: Fri, 29 Apr 2022 20:32:47 +0200 Subject: [PATCH] Initial version. --- README.md | 2 +- package.json | 8 ++++---- tp-element.js | 35 ----------------------------------- tp-radio-group.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 tp-element.js create mode 100644 tp-radio-group.js diff --git a/README.md b/README.md index 1ab27b7..412f0b2 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# tp-element +# tp-radio-group diff --git a/package.json b/package.json index c39fdff..2c146d0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tp-element.js b/tp-element.js deleted file mode 100644 index 6a92a2f..0000000 --- a/tp-element.js +++ /dev/null @@ -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); diff --git a/tp-radio-group.js b/tp-radio-group.js new file mode 100644 index 0000000..ca174fd --- /dev/null +++ b/tp-radio-group.js @@ -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` + + `; + } + + 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);