From 9b24a78d8280ff17f305c42336ee1fb3495534e0 Mon Sep 17 00:00:00 2001 From: trading_peter Date: Sat, 12 Mar 2022 17:03:54 +0100 Subject: [PATCH] Initial version --- README.md | 2 +- package.json | 8 ++-- tp-element.js | 35 ----------------- tp-spinner.js | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 40 deletions(-) delete mode 100644 tp-element.js create mode 100644 tp-spinner.js diff --git a/README.md b/README.md index 1ab27b7..3f0ec6e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# tp-element +# tp-spinner diff --git a/package.json b/package.json index 4ecb195..0652d4e 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "tp-element", - "version": "0.0.1", + "name": "@tp/tp-spinner", + "version": "1.0.0", "description": "", - "main": "tp-element.js", + "main": "tp-spinner.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-spinner.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-spinner.js b/tp-spinner.js new file mode 100644 index 0000000..e0441d4 --- /dev/null +++ b/tp-spinner.js @@ -0,0 +1,104 @@ +/** +@license +Copyright (c) 2022 trading_peter +This program is available under Apache License Version 2.0 + +Spinner css code by the awesome: + +The MIT License (MIT) + +Copyright (c) 2014 Luke Haas + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +https://github.com/lukehaas/css-loaders +*/ + +import { LitElement, html, css } from 'lit'; + +/* +--tp-spinner-border-width | var | 4px | Thickness of the spinners border. +--tp-spinner-color1 | var | #81D4FA | Ring background. +--tp-spinner-color2 | var | #039BE5 | Darker ring segment. +--tp-spinner-width | var | 30px | Width of the spinner ring. +--tp-spinner-height | var | 30px | Height of the spinner ring. +*/ +class TpSpinner extends LitElement { + static get styles() { + return [ + css` + :host { + display: inline-block; + } + + .spinner { + font-size: 10px; + position: relative; + text-indent: -9999em; + border-top: var(--tp-spinner-border-width, 4px) solid var(--tp-spinner-color1, #81D4FA); + border-right: var(--tp-spinner-border-width, 4px) solid var(--tp-spinner-color1, #81D4FA); + border-bottom: var(--tp-spinner-border-width, 4px) solid var(--tp-spinner-color1, #81D4FA); + border-left: var(--tp-spinner-border-width, 4px) solid var(--tp-spinner-color2, #039BE5); + -webkit-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); + -webkit-animation: spinnerAnimation 1.1s infinite linear; + animation: spinnerAnimation 1.1s infinite linear; + overflow: hidden; + } + + .spinner, + .spinner:after { + border-radius: 50%; + width: var(--tp-spinner-width, 30px); + height: var(--tp-spinner-height, 30px); + } + + @-webkit-keyframes spinnerAnimation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } + } + + @keyframes spinnerAnimation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } + } + ` + ]; + } + + render() { + return html` +
+ `; + } +} + +window.customElements.define('tp-spinner', TpSpinner);