Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command center to pink2 #1625

Open
wants to merge 3 commits into
base: feat-pink-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/commandCenter/commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { debounce } from '$lib/helpers/debounce';
import { isMac } from '$lib/helpers/platform';
import { wizard } from '$lib/stores/wizard';
import { onMount } from 'svelte';
import { type ComponentType, onMount } from 'svelte';
import { derived, writable } from 'svelte/store';
import { nanoid } from 'nanoid/non-secure';
import { trackEvent } from '$lib/actions/analytics';
Expand Down Expand Up @@ -49,7 +49,7 @@ type BaseCommand = {
disabled?: boolean;
forceEnable?: boolean;
group?: CommandGroup;
icon?: string;
icon?: ComponentType;
image?: string;
rank?: number;
nested?: boolean;
Expand Down
85 changes: 44 additions & 41 deletions src/lib/commandCenter/panels/ai.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { Remarkable } from 'remarkable';
import Template from './template.svelte';
import { Layout } from '@appwrite.io/pink-svelte';

const markdownInstance = new Remarkable();

Expand Down Expand Up @@ -227,47 +228,49 @@
</div>
{/if}

<div class="footer" slot="footer">
<div class="u-flex u-cross-center u-gap-4">
<AvatarInitials size={32} name={$user.name} />
<form
class="input-text-wrapper u-width-full-line"
style="--amount-of-buttons: 1;"
on:submit|preventDefault={(e) => {
handleSubmit(e);
}}>
<!-- svelte-ignore a11y-autofocus -->
<input
type="text"
class="input-text"
placeholder="Ask a question..."
autofocus
bind:value={$input}
disabled={$isLoading} />
<div class="options-list">
<button
class="options-list-button"
aria-label="ask AI"
type="submit"
disabled={!$input.trim() || $isLoading}>
<span class="icon-arrow-sm-right" aria-hidden="true" />
</button>
</div>
</form>
</div>

<div class="u-flex u-main-end u-cross-center u-gap-16 u-margin-block-start-16">
<div class="u-flex u-cross-center u-gap-4">
<kbd class="kbd">Enter</kbd>
<span>to search</span>
</div>
<div class="sep" />
<div class="u-flex u-cross-center u-gap-4">
<kbd class="kbd">Esc</kbd>
<span>to {$subPanels.length === 1 ? 'close' : 'go back'}</span>
</div>
</div>
</div>
<Layout.Stack slot="footer">
<Layout.Stack gap="l">
<Layout.Stack direction="row" gap="s">
<AvatarInitials size={32} name={$user.name} />
<form
class="input-text-wrapper u-width-full-line"
style="--amount-of-buttons: 1;"
on:submit|preventDefault={(e) => {
handleSubmit(e);
}}>
<!-- svelte-ignore a11y-autofocus -->
<input
type="text"
class="input-text"
placeholder="Ask a question..."
autofocus
bind:value={$input}
disabled={$isLoading} />
<div class="options-list">
<button
class="options-list-button"
aria-label="ask AI"
type="submit"
disabled={!$input.trim() || $isLoading}>
<span class="icon-arrow-sm-right" aria-hidden="true" />
</button>
</div>
</form>
</Layout.Stack>

<Layout.Stack direction="row" justifyContent="space-between" gap="xxl"
><Layout.Stack direction="row" alignItems="center" gap="xxs">
<kbd class="kbd">Enter</kbd> <span>to search</span></Layout.Stack>
<Layout.Stack
direction="row"
justifyContent="flex-end"
alignItems="center"
gap="xxs">
<kbd class="kbd">Esc</kbd>
<span>to {$subPanels.length === 1 ? 'close' : 'go back'}</span></Layout.Stack>
</Layout.Stack>
</Layout.Stack>
</Layout.Stack>
</Template>

<style lang="scss">
Expand Down
35 changes: 26 additions & 9 deletions src/lib/commandCenter/panels/root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { isMac } from '$lib/helpers/platform';
import { commands, searchers, type Command, isKeyedCommand } from '../commands';
import Template from './template.svelte';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
import { IconArrowRight } from '@appwrite.io/pink-icons-svelte';

let search = '';

Expand Down Expand Up @@ -53,21 +55,28 @@
};
</script>

<Template options={results} bind:search searchPlaceholder="Search for commands or content...">
<div slot="option" class="u-flex u-main-space-between content" let:option={command}>
<div class="u-flex u-gap-8 u-cross-center">
<Template options={results} bind:search searchPlaceholder="Search...">
<Layout.Stack
slot="option"
direction="row"
justifyContent="space-between"
alignItems="center"
let:option={command}>
<Layout.Stack direction="row" alignItems="center" gap="s">
{#if command.image}
<img
src={`${base}/icons/${$app.themeInUse}/color/${command.image}.svg`}
alt={command.label} />
{:else if command.icon}
<Icon icon={command.icon} size="s" />
{:else}
<i class="icon-{command.icon ?? 'arrow-sm-right'}" />
<Icon icon={IconArrowRight} size="s" />
{/if}
<span>
{command.label}
</span>
</div>
<div class="u-flex u-gap-4 u-cross-center">
</Layout.Stack>
<Layout.Stack direction="row" justifyContent="flex-end" alignItems="center" gap="s">
{#if hasCtrl(command)}
<kbd class="kbd"> {isMac() ? '⌘' : 'Ctrl'} </kbd>
{/if}
Expand All @@ -85,11 +94,19 @@
{key.toUpperCase()}
</kbd>
{#if hasNext}
<span class="u-margin-inline-4" style:opacity={0.5}>then</span>
<span class="then">then</span>
{/if}
{/each}
{/if}
</div>
</div>
</Layout.Stack>
</Layout.Stack>
<svelte:fragment slot="no-options">No commands found</svelte:fragment>
</Template>

<style>
.then {
color: var(--color-fgcolor-neutral-tertiary, #97979b);
font-size: var(--font-size-s, 14px);
font-weight: 400;
}
</style>
96 changes: 39 additions & 57 deletions src/lib/commandCenter/panels/template.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { getCommandCenterCtx } from '../commandCenter.svelte';

import { clearSubPanels, popSubPanel, subPanels } from '../subPanels';
import { IconArrowRight } from '@appwrite.io/pink-icons-svelte';
import { Icon, Layout } from '@appwrite.io/pink-svelte';

/* eslint no-undef: "off" */
type Option = $$Generic<Omit<Command, 'group'> & { group?: string }>;
Expand Down Expand Up @@ -294,7 +296,11 @@
on:focus={getOptionFocusHandler(item)}>
<slot name="option" option={castOption(item)}>
<div class="u-flex u-gap-8 u-cross-center">
<i class="icon-{item.icon ?? 'arrow-sm-right'}" />
{#if item.icon}
<Icon icon={item.icon} size="s" />
{:else}
<Icon icon={IconArrowRight} size="s" />
{/if}
<span>
{item.label}
</span>
Expand All @@ -316,15 +322,17 @@

<div class="footer">
<slot name="footer">
<div class=" u-flex u-flex u-cross-center u-main-space-between">
<div class="u-flex u-cross-center u-gap-4">
<kbd class="kbd">Enter</kbd> <span>to select</span>
</div>
<div class="u-flex u-cross-center u-gap-4">
<Layout.Stack direction="row" justifyContent="space-between"
><Layout.Stack direction="row" alignItems="center" gap="xxs">
<kbd class="kbd">Enter</kbd> <span>to select</span></Layout.Stack>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the Keyboard component on Pink, we can use that one too 👍

<Layout.Stack
direction="row"
justifyContent="flex-end"
alignItems="center"
gap="xxs">
<kbd class="kbd">Esc</kbd>
<span>to {$subPanels.length > 1 ? 'go back' : 'close'}</span>
</div>
</div>
<span>to {$subPanels.length > 1 ? 'go back' : 'close'}</span></Layout.Stack>
</Layout.Stack>
</slot>
</div>
</div>
Expand Down Expand Up @@ -363,45 +371,16 @@
animation: scale-up 150ms cubic-bezier(0.5, 1, 0.89, 1);
}

// Theme
:global(.theme-light) .card {
--cmd-center-bg: hsl(var(--color-neutral-0));
--cmd-center-border: hsl(var(--color-neutral-10));
--cmd-center-shadow: 0px 16px 32px 0px rgba(55, 59, 77, 0.04);

--kbd-bg: hsl(var(--color-neutral-15));
--kbd-color: hsl(var(--color-neutral-60));

--crumb-bg: hsl(var(--color-neutral-10));
--crumb-color: hsl(var(--color-neutral-100));

--result-bg: hsl(var(--color-neutral-10));
--footer-bg: linear-gradient(180deg, #fff 0%, #e8e9f0 100%);

--icon-color: hsl(var(--color-neutral-50));
--label-color: hsl(var(--color-neutral-60));
}

:global(.theme-dark) .card {
--cmd-center-bg: hsl(var(--color-neutral-90));
--cmd-center-border: hsl(var(--color-neutral-80));
--cmd-center-shadow: 0px 16px 32px 0px #14141f;

--kbd-bg: hsl(var(--color-neutral-80));
--kbd-color: hsl(var(--color-neutral-15));

--crumb-bg: hsl(var(--color-neutral-150));
--crumb-color: hsl(var(--color-neutral-30));

--result-bg: hsl(var(--color-neutral-85));
--footer-bg: linear-gradient(
180deg,
hsl(var(--color-neutral-100)) 0%,
hsl(var(--color-neutral-85)) 100%
);

--icon-color: hsl(var(--color-neutral-70));
--label-color: hsl(var(--color-neutral-15));
.card {
--cmd-center-bg: var(--color-bgcolor-neutral-primary, #fff);
--footer-bg: var(--color-bgcolor-neutral-primary, #fff);
--cmd-center-border: var(--color-border-neutral, #ededf0);
--result-bg: var(--color-overlay-neutral-hover, rgba(25, 25, 28, 0.03));
--kbd-bg: var(--color-overlay-on-neutral, rgba(0, 0, 0, 0.06));
--kbd-color: var(--color-fgcolor-neutral-secondary, #56565c);
--icon-color: var(--color-fgcolor-neutral-tertiary, #97979b);
--label-color: var(--color-fgColor-neutral-secondary, #56565c);
--crumb-color: var(--color-fgColor-neutral-secondary, #56565c);
}

// Elements
Expand All @@ -420,11 +399,14 @@
max-height: min(calc(100vh - var(--top) - 4rem), var(--max-height, 32rem));
overflow: hidden;
padding: 0;
box-shadow:
0 56px 32px 0 rgba(0, 0, 0, 0.02),
0 6px 14px 0 rgba(0, 0, 0, 0.04),
0 24px 25px 0 rgba(0, 0, 0, 0.03);

border-radius: 0.5rem;
border: 1px solid var(--cmd-center-border);
background: var(--cmd-center-bg);
box-shadow: var(--cmd-center-shadow);
backdrop-filter: blur(6px);

&.fullheight {
Expand All @@ -434,7 +416,7 @@
:global(.kbd) {
color: var(--kbd-color);
background-color: var(--kbd-bg);
padding-inline: 0.25rem;
padding-inline: var(--space-2, 4px);
}
}

Expand All @@ -444,7 +426,7 @@
align-items: center;
width: 100%;

border-bottom: 1px solid hsl(var(--color-border));
border-bottom: 1px solid var(--color-border-neutral, #ededf0);
font-size: 16px;
padding: 1rem;

Expand All @@ -465,7 +447,6 @@
gap: 0.25rem;

border-radius: 0.25rem;
background: var(--crumb-bg);
color: var(--crumb-color);
text-align: center;
font-family: Inter;
Expand Down Expand Up @@ -493,13 +474,14 @@
padding: 1rem;

.group {
color: hsl(var(--color-neutral-70));
color: var(--color-fgcolor-neutral-secondary, #56565c);
margin-inline-start: 0.25rem;
margin-block-end: 0.25rem;
position: relative;
z-index: 10;

font-size: 10px !important;
font-size: var(--font-size-xs, 12px);
font-weight: 500;

&:not(:first-child) {
margin-block-start: 1rem;
Expand Down Expand Up @@ -560,7 +542,7 @@
content: '';
position: absolute;
left: -8px;
border-left: 1px solid hsl(var(--color-border));
border-left: 1px solid var(--color-border-neutral, #ededf0);
height: 100%;
}
}
Expand All @@ -570,8 +552,8 @@

.footer {
background: var(--footer-bg);
border-top: 1px solid hsl(var(--color-border));
border-top: 1px solid var(--color-border-neutral, #ededf0);

padding: 0.5rem 1rem;
padding: 0.75rem 1rem;
}
</style>
5 changes: 3 additions & 2 deletions src/lib/commandCenter/searchers/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Models } from '@appwrite.io/console';
import { page } from '$app/stores';
import { showCreateDeployment } from '$routes/(console)/project-[project]/functions/function-[function]/store';
import { base } from '$app/paths';
import { IconLightningBolt, IconPlus } from '@appwrite.io/pink-icons-svelte';

const getFunctionCommand = (fn: Models.Function, projectId: string) => {
return {
Expand All @@ -15,7 +16,7 @@ const getFunctionCommand = (fn: Models.Function, projectId: string) => {
goto(`${base}/project-${projectId}/functions/function-${fn.$id}`);
},
group: 'functions',
icon: 'lightning-bolt'
icon: IconLightningBolt
} as const;
};

Expand All @@ -41,7 +42,7 @@ export const functionsSearcher = (async (query: string) => {
showCreateDeployment.set(true);
},
group: 'functions',
icon: 'plus'
icon: IconPlus
},
{
label: 'Go to deployments',
Expand Down
Loading
Loading