aboutsummaryrefslogtreecommitdiffstats
path: root/web/spinner.js
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-09-05 12:16:27 +0300
committerTulir Asokan <tulir@maunium.net>2020-09-05 12:16:27 +0300
commit28c7d2f1a2113d3ea609373a345d23d35361d605 (patch)
tree98c4f649d4a90a4dc5db6485e484510d4e15e870 /web/spinner.js
parent27fd49f6e581c8bdc6c05e3ef83bf68fdd472f6f (diff)
Split up spinner and widget API into files
Diffstat (limited to 'web/spinner.js')
-rw-r--r--web/spinner.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/spinner.js b/web/spinner.js
new file mode 100644
index 0000000..6462cde
--- /dev/null
+++ b/web/spinner.js
@@ -0,0 +1,31 @@
+// Copyright (c) 2020 Tulir Asokan
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import { html } from "https://unpkg.com/htm/preact/index.mjs?module"
+
+export const Spinner = ({ size = 40, noCenter = false, noMargin = false, green = false }) => {
+ let margin = 0
+ if (!isNaN(+size)) {
+ size = +size
+ margin = noMargin ? 0 : `${Math.round(size / 6)}px`
+ size = `${size}px`
+ }
+ const noInnerMargin = !noCenter || !margin
+ const comp = html`
+ <div style="width: ${size}; height: ${size}; margin: ${noInnerMargin ? 0 : margin} 0;"
+ class="sk-chase ${green && "green"}">
+ <div class="sk-chase-dot" />
+ <div class="sk-chase-dot" />
+ <div class="sk-chase-dot" />
+ <div class="sk-chase-dot" />
+ <div class="sk-chase-dot" />
+ <div class="sk-chase-dot" />
+ </div>
+ `
+ if (!noCenter) {
+ return html`<div style="margin: ${margin} 0;" class="sk-center-wrapper">${comp}</div>`
+ }
+ return comp
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage