aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/editable
diff options
context:
space:
mode:
Diffstat (limited to 'static/widgets/editable')
-rw-r--r--static/widgets/editable/index.css36
-rw-r--r--static/widgets/editable/index.js77
2 files changed, 0 insertions, 113 deletions
diff --git a/static/widgets/editable/index.css b/static/widgets/editable/index.css
deleted file mode 100644
index b474370..0000000
--- a/static/widgets/editable/index.css
+++ /dev/null
@@ -1,36 +0,0 @@
-
-#container {
- width: 100%;
- background: var(--card-background);
- box-shadow: var(--shadow);
- border-radius: var(--border-radius);
- display: grid;
- grid-template-columns: min-content auto min-content;
-}
-
-#container label {
- user-select: none;
- font-weight: bold;
- background: var(--primary);
- color: var(--fg-primary);
- align-content: center;
- padding: 10px;
- border-top-left-radius: var(--border-radius);
- border-bottom-left-radius: var(--border-radius);
-}
-
-#container input {
- background: var(--card-background);
- user-select: none;
- font-size: 1em;
-}
-
-#container input:read-only {
- caret-color: transparent;
-}
-
-#edit {
- width: 35px;
- padding: 10px;
- cursor: pointer;
-}
diff --git a/static/widgets/editable/index.js b/static/widgets/editable/index.js
deleted file mode 100644
index b7e24de..0000000
--- a/static/widgets/editable/index.js
+++ /dev/null
@@ -1,77 +0,0 @@
-import icons from 'icons';
-import * as sfw from 'sfw';
-const { Div, Label, Input } = sfw.element.native;
-
-import stylesheet from './index.css';
-
-const css = await sfw.css.sheet(stylesheet);
-
-export default class Editable extends sfw.element.Container {
- #label
- #input
- #edit
-
- constructor() {
- super({ css });
-
- this.onupdate = () => {};
-
- this.body.append(
- Div.new({
- id: 'container',
- children: [
- this.#label = Label.new({ htmlFor: 'input' }),
- this.#input = Input.new({
- readOnly: true,
- onkeydown: (e) => {
- if (e.key === 'Enter') {
- this.#input.readOnly = true;
- this.#update()
- this.onupdate();
- }
- },
- }),
- this.#edit = Div.new({
- id: 'edit',
- children: [ icons.edit ],
- onclick: () => {
- this.#input.readOnly = !this.#input.readOnly;
- this.#update();
-
- if (this.#input.readOnly) {
- this.onupdate();
- }
- }
- }),
- ],
- })
- );
- }
-
- #update() {
- this.#edit.innerHTML = '';
- this.#edit.append(
- this.#input.readOnly ? icons.edit : icons.check
- );
-
- if (!this.#input.readOnly) {
- this.#input.select();
- }
- }
-
- set title(value) {
- this.#label.innerText = value;
- }
-
- set value(value) {
- this.#input.value = value;
- }
-
- get value() {
- return this.#input.value;
- }
-
- set type(type) {
- this.#input.type = type;
- }
-}