diff --git a/README.md b/README.md index 1ab27b7..4cf74c6 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# tp-element +# tp-icon diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..098c9be --- /dev/null +++ b/package-lock.json @@ -0,0 +1,61 @@ +{ + "name": "tp-icon", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@lit/reactive-element": { + "version": "1.3.0", + "resolved": "https://verdaccio.codeblob.work/@lit%2freactive-element/-/reactive-element-1.3.0.tgz", + "integrity": "sha512-0TKSIuJHXNLM0k98fi0AdMIdUoHIYlDHTP+0Vruc2SOs4T6vU1FinXgSvYd8mSrkt+8R+qdRAXvjpqrMXMyBgw==" + }, + "@tp/helpers": { + "version": "1.0.0", + "resolved": "https://verdaccio.codeblob.work/@tp%2fhelpers/-/helpers-1.0.0.tgz", + "integrity": "sha512-0RcwkVBsZoa2jaOGwf0QNBHIC1vA/8G1rsvWC1j20tyyzZBOqGGOwvgnLN1TEP3C8zT4+oUMlQbu6DmkpW9T3A==" + }, + "@tp/tp-tooltip": { + "version": "1.0.0", + "resolved": "https://verdaccio.codeblob.work/@tp%2ftp-tooltip/-/tp-tooltip-1.0.0.tgz", + "integrity": "sha512-UtrIK5KWcEiC+HnHOVbgg90j4RjHn3e9ehOBYPZsm6zO+tT7pQJJYFOtJqBW+DDV7jVfH3AvGKCxtzNiJXYvDw==", + "requires": { + "@tp/helpers": "^1.0.0", + "lit": "^2.2.0" + }, + "dependencies": { + "lit": { + "version": "2.2.0", + "resolved": "https://verdaccio.codeblob.work/lit/-/lit-2.2.0.tgz", + "integrity": "sha512-FDyxUuczo6cJJY/2Bkgfh1872U4ikUvmK1Cb6+lYC1CW+QOo8CaWXCpvPKFzYsz0ojUxoruBLVrECc7VI2f1dQ==", + "requires": { + "@lit/reactive-element": "^1.3.0", + "lit-element": "^3.2.0", + "lit-html": "^2.2.0" + } + } + } + }, + "@types/trusted-types": { + "version": "2.0.2", + "resolved": "https://verdaccio.codeblob.work/@types%2ftrusted-types/-/trusted-types-2.0.2.tgz", + "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==" + }, + "lit-element": { + "version": "3.2.0", + "resolved": "https://verdaccio.codeblob.work/lit-element/-/lit-element-3.2.0.tgz", + "integrity": "sha512-HbE7yt2SnUtg5DCrWt028oaU4D5F4k/1cntAFHTkzY8ZIa8N0Wmu92PxSxucsQSOXlODFrICkQ5x/tEshKi13g==", + "requires": { + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.2.0" + } + }, + "lit-html": { + "version": "2.2.0", + "resolved": "https://verdaccio.codeblob.work/lit-html/-/lit-html-2.2.0.tgz", + "integrity": "sha512-dJnevgV8VkCuOXLWrjQopDE8nSy8CzipZ/ATfYQv7z7Dct4abblcKecf50gkIScuwCTzKvRLgvTgV0zzagW4gA==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + } + } +} diff --git a/package.json b/package.json index 4ecb195..4ca5971 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,19 @@ { - "name": "tp-element", - "version": "0.0.1", + "name": "tp-icon", + "version": "1.0.0", "description": "", - "main": "tp-element.js", + "main": "tp-icon.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-icon.git" }, "author": "trading_peter", "license": "Apache-2.0", "dependencies": { + "@tp/tp-tooltip": "^1.0.0", "lit": "^2.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-icon.js b/tp-icon.js new file mode 100644 index 0000000..de7f768 --- /dev/null +++ b/tp-icon.js @@ -0,0 +1,55 @@ +/** +@license +Copyright (c) 2022 trading_peter +This program is available under Apache License Version 2.0 +*/ + +import { LitElement, html, svg, css } from 'lit'; +import { Tooltip } from '@tp/tp-tooltip/tp-tooltip-mixin.js'; + +class TpIcon extends Tooltip(LitElement) { + static get styles() { + return css` + :host { + display: inline-block; + width: var(--tp-icon-width, 24px); + height: var(--tp-icon-height, 24px); + cursor: pointer; + outline: none; + } + + .wrap { + display: flex; + align-items: center; + } + `; + } + + render() { + return html` +
+ ${svg` + + ${this.icon} + + `} +
+ `; + } + + static get properties() { + return { + icon: { type: Object } + }; + } + + firstUpdated() { + this.setAttribute('tabindex', '-1'); + } + + shouldRender() { + return Boolean(this.icon); + } +} + +window.customElements.define('tp-icon', TpIcon);