aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/search
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-05-20 10:16:50 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-05-20 10:16:50 +0200
commit44445734ba4a0f05564f808c2fd34a7f23c6fafb (patch)
tree3bd22add718620cbf931286f55137bcc666100be /static/widgets/search
parent95ae9f15e1db335a7f8358d811ea37e2c89dd10f (diff)
Let's do a rewrite!
Created project structure and changed `build.zig` and added licence.
Diffstat (limited to 'static/widgets/search')
-rw-r--r--static/widgets/search/index.css50
-rw-r--r--static/widgets/search/index.js68
2 files changed, 0 insertions, 118 deletions
diff --git a/static/widgets/search/index.css b/static/widgets/search/index.css
deleted file mode 100644
index 14e650d..0000000
--- a/static/widgets/search/index.css
+++ /dev/null
@@ -1,50 +0,0 @@
-:host {
- position: fixed;
- top: 0;
- left: 0;
-}
-
-#container {
- position: fixed;
- top: -200px;
- left: 5px;
- right: 5px;
- height: 100px;
- background: #fff9;
- backdrop-filter: blur(10px);
- border-radius: var(--border-radius);
- transition: top 0.2s ease;
- padding: 10px;
- display: grid;
- gap: 10px;
- box-shadow: var(--shadow);
-}
-
-#container.visible {
- top: 5px;
-}
-
-#title {
- font-size: 1.2em;
- align-content: center;
- padding-left: 5px;
- user-select: none;
-}
-
-#search-box {
- width: 100%;
- display: grid;
- grid-template-columns: auto 50px;
-}
-
-input {
- border-top-right-radius: 0px !important;
- border-bottom-right-radius: 0px !important;
-}
-
-button {
- width: 50px;
- border-top-left-radius: 0px !important;
- border-bottom-left-radius: 0px !important;
- height: 42px;
-}
diff --git a/static/widgets/search/index.js b/static/widgets/search/index.js
deleted file mode 100644
index b014cdd..0000000
--- a/static/widgets/search/index.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import icons from 'icons';
-import * as sfw from 'sfw';
-const { Div, Input, Button } = sfw.element.native;
-
-import stylesheet from './index.css';
-
-const css = await sfw.css.sheet(stylesheet);
-
-export default class Search extends sfw.element.Container {
- #container
- #search
-
- constructor() {
- super({ css });
-
- this.onsubmit = () => {}
- this.onhide = () => {}
-
- this.onclick = (e) => e.stopPropagation();
- this.hide = () => {
- this.#container.classList.remove('visible');
- document.removeEventListener('click', this.hide);
- this.onhide();
- };
-
- this.body.append(
- this.#container = Div.new({
- id: 'container',
- children: [
- Div.new({ innerText: 'Search', id: 'title' }),
- Div.new({
- id: 'search-box',
- children: [
- this.#search = Input.new({
- type: 'search',
- onsearch: () => this.submit(),
- onkeydown: (event) => {
- if (event.key === 'Enter') {
- this.submit();
- }
- }
- }),
- Button.new({
- children: [ icons.search ],
- onclick: () => this.submit(),
- }),
- ]
- })
- ]
- })
- );
- }
-
- submit() {
- this.onsubmit(this.#search.value);
- this.#search.blur();
- this.hide();
- }
-
- toggle() {
- this.#container.classList.toggle('visible');
-
- if (this.#container.classList.contains('visible')) {
- this.#search.focus()
- document.addEventListener('click', this.hide)
- }
- }
-}