mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2025-10-29 17:40:28 +00:00
update globalSearch layout & styling - including darkmode
This commit is contained in:
@@ -40,16 +40,18 @@
|
|||||||
class="dialog"
|
class="dialog"
|
||||||
>
|
>
|
||||||
<div tabindex="-1" id="dialog-title" class="title">
|
<div tabindex="-1" id="dialog-title" class="title">
|
||||||
<header>
|
{#if title.length || description.length}
|
||||||
<button on:click={close} aria-disabled="false" aria-label="Close" type="button" tabindex="0"
|
<header>
|
||||||
><svg viewBox="0 0 24 24" aria-hidden="true" tabindex="-1" height="100%" width="100%"
|
<button on:click={close} aria-disabled="false" aria-label="Close" type="button" tabindex="0"
|
||||||
><path
|
><svg viewBox="0 0 24 24" aria-hidden="true" tabindex="-1" height="100%" width="100%"
|
||||||
d="M6.909 5.636a.9.9 0 1 0-1.273 1.273l5.091 5.09-5.091 5.092a.9.9 0 0 0 1.273 1.273L12 13.273l5.091 5.09a.9.9 0 1 0 1.273-1.272L13.273 12l5.09-5.091a.9.9 0 1 0-1.272-1.273L12 10.727z"
|
><path
|
||||||
></path></svg
|
d="M6.909 5.636a.9.9 0 1 0-1.273 1.273l5.091 5.09-5.091 5.092a.9.9 0 0 0 1.273 1.273L12 13.273l5.091 5.09a.9.9 0 1 0 1.273-1.272L13.273 12l5.09-5.091a.9.9 0 1 0-1.272-1.273L12 10.727z"
|
||||||
>
|
></path></svg
|
||||||
</button>
|
>
|
||||||
<h5>{title}</h5>
|
</button>
|
||||||
</header>
|
<h5>{title}</h5>
|
||||||
|
</header>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
{#if description}
|
{#if description}
|
||||||
@@ -113,8 +115,11 @@
|
|||||||
|
|
||||||
.title {
|
.title {
|
||||||
--padding: 1rem;
|
--padding: 1rem;
|
||||||
|
--background-color: #ffffff;
|
||||||
|
--text-color: black;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #ffffff;
|
background-color: var(--background-color);
|
||||||
|
color: var(--text-color);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -35,6 +35,14 @@
|
|||||||
}, 50);
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function openElement(link: string) {
|
||||||
|
if (String(link)?.startsWith('/')) {
|
||||||
|
goto(link);
|
||||||
|
} else {
|
||||||
|
window.open(link, '_blank');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function registerShortcutKey() {
|
function registerShortcutKey() {
|
||||||
document.addEventListener('keydown', function (event) {
|
document.addEventListener('keydown', function (event) {
|
||||||
// listen for open/close command + k
|
// listen for open/close command + k
|
||||||
@@ -81,11 +89,7 @@
|
|||||||
const { link } = filteredchildren[focusIndex];
|
const { link } = filteredchildren[focusIndex];
|
||||||
toggleSearchDialog();
|
toggleSearchDialog();
|
||||||
|
|
||||||
if (String(link)?.startsWith('/')) {
|
openElement(link);
|
||||||
goto(link);
|
|
||||||
} else {
|
|
||||||
window.open(link, '_blank');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -96,16 +100,22 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if open}
|
{#if open}
|
||||||
<Dialog on:close={() => (open = false)} title="Search on page" description="">
|
<Dialog on:close={() => (open = false)} title="" description="">
|
||||||
<div class={className}>
|
<div class={className}>
|
||||||
<Input label="" bind:value={filterString} placeholder="attribute" />
|
<Input label="" bind:value={filterString} placeholder="Search anything..." />
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{#each filteredchildren as element, index (element)}
|
{#each filteredchildren as element, index (element)}
|
||||||
<li class={index === focusIndex ? 'focus' : ''}>
|
<li
|
||||||
<h3>{element?.name}</h3>
|
class={index === focusIndex ? 'focus' : ''}
|
||||||
|
on:click={() => openElement(element?.link) ?? '/'}
|
||||||
|
>
|
||||||
|
<div class="header">
|
||||||
|
<h3>{element?.name}</h3>
|
||||||
|
<span class="sub">{element?.link}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="group">
|
||||||
{#each Object.entries(element) as [key, value] (key)}
|
{#each Object.entries(element) as [key, value] (key)}
|
||||||
<span><b>{key}:</b> {value}</span>
|
<span><b>{key}:</b> {value}</span>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -113,11 +123,31 @@
|
|||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<div class="hint">
|
||||||
|
Press <span class="kbd">Esc</span> to close · <span class="kbd">⌘</span> +
|
||||||
|
<span class="kbd">K</span> to toggle
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
:global(.dialog .title) {
|
||||||
|
--padding: 1.2rem;
|
||||||
|
--background-color: rgba(255, 255, 255, 0.92);
|
||||||
|
--text-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(body.dark .dialog .title) {
|
||||||
|
--background-color: rgba(25, 25, 34, 0.92);
|
||||||
|
--text-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dialog .title .input) {
|
||||||
|
--padding-w: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.search-container {
|
.search-container {
|
||||||
width: 700px;
|
width: 700px;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -132,6 +162,8 @@
|
|||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
margin-top: 0.3rem;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
@@ -140,19 +172,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
|
--blur: 18px;
|
||||||
border: var(--border);
|
border: var(--border);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
padding: 1rem;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
transition: background 0.15s;
|
||||||
|
padding: 0.875rem 1rem;
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
gap: 0.375rem;
|
||||||
|
|
||||||
&.focus,
|
&.focus,
|
||||||
&:hover {
|
&:hover {
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: calc(100% - 2px);
|
width: calc(100% - 4px);
|
||||||
height: calc(100% - 2px);
|
height: calc(100% - 2px);
|
||||||
border: 2px solid var(--theme);
|
border: 2px solid var(--theme);
|
||||||
top: -1px;
|
top: -1px;
|
||||||
@@ -161,18 +202,59 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
.header {
|
||||||
margin: 0;
|
display: flex;
|
||||||
text-align: center;
|
justify-content: space-between;
|
||||||
font-size: 2rem;
|
align-items: baseline;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub {
|
||||||
|
color: #999;
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div {
|
.group {
|
||||||
margin-top: 0.5rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
column-gap: 1rem;
|
gap: 0.625rem 1.125rem;
|
||||||
row-gap: 0.1rem;
|
margin-top: 0.25rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--muted);
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
b {
|
||||||
|
color: var(--key);
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Small footer hint */
|
||||||
|
.hint {
|
||||||
|
margin-top: 10px;
|
||||||
|
text-align: right;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
.kbd {
|
||||||
|
background-color: rgba(0, 0, 0, 0.16);
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import CubeSide from '$lib/icons/cube-side.svelte';
|
import CubeSide from '$lib/icons/cube-side.svelte';
|
||||||
import HardDrive from '$lib/icons/hard-disk.svelte';
|
import HardDrive from '$lib/icons/hard-disk.svelte';
|
||||||
import Network from '$lib/icons/Network.svelte';
|
import Network from '$lib/icons/network.svelte';
|
||||||
import CPU from '$lib/icons/cpu.svelte';
|
import CPU from '$lib/icons/cpu.svelte';
|
||||||
import Fingerprint from '$lib/icons/fingerprint.svelte';
|
import Fingerprint from '$lib/icons/fingerprint.svelte';
|
||||||
import ExtractUp from '$lib/icons/extract-up.svelte';
|
import ExtractUp from '$lib/icons/extract-up.svelte';
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ button.affirmative:hover span {
|
|||||||
/* dark mode button overrides */
|
/* dark mode button overrides */
|
||||||
body.dark button span {
|
body.dark button span {
|
||||||
background-color: var(--theme);
|
background-color: var(--theme);
|
||||||
|
color: var(--bg);
|
||||||
}
|
}
|
||||||
body.dark button.affirmative span {
|
body.dark button.affirmative span {
|
||||||
color: var(--bg);
|
color: var(--bg);
|
||||||
|
|||||||
Reference in New Issue
Block a user