mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: more command center animations
This commit is contained in:
1 parent
ea8a92481c
commit
6874ab276f
2 files changed
+65
-52
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
import { fade, scale } from 'svelte/transition';
|
||||
|
||||
export let show = false;
|
||||
export let size: 'small' | 'big' = null;
|
||||
@@ -9,7 +10,7 @@
|
||||
export let headerDivider = true;
|
||||
export let animate = true;
|
||||
|
||||
let dialog: HTMLDialogElement;
|
||||
let dialog: HTMLDivElement;
|
||||
let alert: HTMLElement;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
@@ -31,20 +32,14 @@
|
||||
}
|
||||
}
|
||||
function openModal() {
|
||||
if (dialog && !dialog.open) {
|
||||
dialog.showModal();
|
||||
document.documentElement.classList.add('u-overflow-hidden');
|
||||
}
|
||||
document.documentElement.classList.add('u-overflow-hidden');
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
if (closable) {
|
||||
if (dialog && dialog.open) {
|
||||
dispatch('close');
|
||||
dialog.close();
|
||||
show = false;
|
||||
document.documentElement.classList.remove('u-overflow-hidden');
|
||||
}
|
||||
dispatch('close');
|
||||
show = false;
|
||||
document.documentElement.classList.remove('u-overflow-hidden');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,20 +66,35 @@
|
||||
|
||||
<svelte:window on:mousedown={handleBLur} on:keydown={handleKeydown} />
|
||||
|
||||
<dialog
|
||||
class="modal"
|
||||
class:is-small={size === 'small'}
|
||||
class:is-big={size === 'big'}
|
||||
class:is-separate-header={headerDivider}
|
||||
bind:this={dialog}
|
||||
on:cancel|preventDefault>
|
||||
{#if show}
|
||||
<slot />
|
||||
{/if}
|
||||
</dialog>
|
||||
{#if show}
|
||||
<div
|
||||
class="dialog"
|
||||
class:is-small={size === 'small'}
|
||||
class:is-big={size === 'big'}
|
||||
class:is-separate-header={headerDivider}
|
||||
on:cancel|preventDefault
|
||||
bind:this={dialog}
|
||||
transition:fade={{ duration: animate ? 150 : 0 }}>
|
||||
<div class="card" transition:scale={{ duration: animate ? 150 : 0, start: 0.9 }}>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.modal {
|
||||
.dialog {
|
||||
padding: 0.5rem;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background-color: hsl(var(--color-neutral-500) / 0.5);
|
||||
z-index: 9999;
|
||||
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.card {
|
||||
min-width: 400px;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
@@ -66,36 +66,36 @@
|
||||
|
||||
<ul class="u-margin-block-start-16 u-flex u-flex-vertical u-gap-8">
|
||||
{#each results as command, i}
|
||||
<li
|
||||
class="u-flex u-main-space-between result"
|
||||
data-selected={selected === i ? true : undefined}>
|
||||
<span>
|
||||
{command.label}
|
||||
</span>
|
||||
<div class="u-flex u-gap-4 u-cross-center">
|
||||
{#if command.ctrl}
|
||||
<kbd class="kbd"> {isMac() ? '⌘' : 'ctrl'} </kbd>
|
||||
{/if}
|
||||
{#if command.shift}
|
||||
<kbd class="kbd"> {isMac() ? '⇧' : 'shift'} </kbd>
|
||||
{/if}
|
||||
{#if command.alt}
|
||||
<kbd class="kbd"> {isMac() ? '⌥' : 'alt'} </kbd>
|
||||
{/if}
|
||||
{#each command.keys as key, i}
|
||||
{@const hasNext = command.keys.length - 1 !== i}
|
||||
|
||||
<kbd class="kbd">
|
||||
{key.toUpperCase()}
|
||||
</kbd>
|
||||
{#if hasNext}
|
||||
<span class="u-margin-inline-4" style:opacity={0.5}>then</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<li class="result" data-selected={selected === i ? true : undefined}>
|
||||
{#if selected === i}
|
||||
<div class="bg" in:send={{ key: 'bg' }} out:receive={{ key: 'bg' }} />
|
||||
{/if}
|
||||
<div class="u-flex u-main-space-between content">
|
||||
<span>
|
||||
{command.label}
|
||||
</span>
|
||||
<div class="u-flex u-gap-4 u-cross-center">
|
||||
{#if command.ctrl}
|
||||
<kbd class="kbd"> {isMac() ? '⌘' : 'ctrl'} </kbd>
|
||||
{/if}
|
||||
{#if command.shift}
|
||||
<kbd class="kbd"> {isMac() ? '⇧' : 'shift'} </kbd>
|
||||
{/if}
|
||||
{#if command.alt}
|
||||
<kbd class="kbd"> {isMac() ? '⌥' : 'alt'} </kbd>
|
||||
{/if}
|
||||
{#each command.keys as key, i}
|
||||
{@const hasNext = command.keys.length - 1 !== i}
|
||||
|
||||
<kbd class="kbd">
|
||||
{key.toUpperCase()}
|
||||
</kbd>
|
||||
{#if hasNext}
|
||||
<span class="u-margin-inline-4" style:opacity={0.5}>then</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{:else}
|
||||
<li class="result">
|
||||
@@ -118,14 +118,17 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.result .content {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.result .bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-color: hsl(var(--color-neutral-200));
|
||||
border-radius: 0.75rem;
|
||||
translate: 0 -1px;
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
/* .result[data-selected] {
|
||||
|
||||
Reference in new issue
Block a user