Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5489e60
small design review
TGlide Aug 14, 2023
d11fa02
more design review changes
TGlide Aug 14, 2023
03deb8d
mock migrations
TGlide Aug 14, 2023
74de2e5
change ai logo in console
TGlide Aug 16, 2023
c462905
add experimental label & fix breadcrumb clearing visual bug
TGlide Aug 16, 2023
ecadba6
AI question avatar
TGlide Aug 16, 2023
b496a54
auto-expandable ai panel
TGlide Aug 16, 2023
1f40284
table check touch area
TGlide Aug 16, 2023
64f0e78
fix floating action bar mobile
TGlide Aug 16, 2023
5d7b583
fix: selection clear
TGlide Aug 16, 2023
d37fb2d
fix queries
TGlide Aug 17, 2023
8d9e54f
toggleable debug overlay
TGlide Aug 17, 2023
668034e
remove search commands in favor of searchers
TGlide Aug 17, 2023
79774d7
remove search commands in favor of searchers
TGlide Aug 17, 2023
aca2620
remove comments
TGlide Aug 17, 2023
190395e
command center design review
TGlide Aug 17, 2023
cdb86da
add tooltip to header
TGlide Aug 17, 2023
d814703
reorder commands
TGlide Aug 17, 2023
7bb0ae4
fix ai panel input
TGlide Aug 17, 2023
2a0f8f5
more commands
TGlide Aug 17, 2023
42f6eed
hide firebase oauth
TGlide Aug 17, 2023
047ff87
Merge branch '1.4.x' into design-reviews-1.4
TGlide Aug 18, 2023
67883b3
fix missing project sdk
TGlide Aug 18, 2023
5ef22c8
fix icon
TGlide Aug 18, 2023
320605c
add feedback fn
TGlide Aug 18, 2023
ec5ad21
migration design changes
TGlide Aug 18, 2023
aa822fb
improve command selection
TGlide Aug 18, 2023
1fb8b58
fix code padding
TGlide Aug 18, 2023
2b58934
loading dots animation
TGlide Aug 18, 2023
5bdc88f
add border to avatars
TGlide Aug 18, 2023
1598022
migrations loaders
TGlide Aug 18, 2023
7069fb2
fix wizard title
TGlide Aug 18, 2023
d97c489
radio button spacing
TGlide Aug 18, 2023
84ccd9e
fix padding
TGlide Aug 18, 2023
d899623
logs MVP
TGlide Aug 21, 2023
ebcf8ee
better errors
TGlide Aug 21, 2023
fdd4b5f
fix tags
TGlide Aug 21, 2023
1517544
more design changes
TGlide Aug 21, 2023
441fcce
details tabs
TGlide Aug 21, 2023
e1e4c92
hide AI command when needed
TGlide Aug 21, 2023
58b5707
review changes
TGlide Aug 22, 2023
b44f12e
fix some check issues
TGlide Aug 22, 2023
3b483d1
extract helpers
TGlide Aug 22, 2023
2f59c4f
status icons
TGlide Aug 22, 2023
188e5f7
globalize commands
TGlide Aug 22, 2023
552470c
improve kbd nav command center
TGlide Aug 22, 2023
2fefb6b
Merge branch 1.4.x into design-reviews-1.4
TGlide Aug 22, 2023
f46cf9f
small fix
TGlide Aug 22, 2023
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
8,824 changes: 7,356 additions & 1,468 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/lib/actions/multi-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Action } from 'svelte/action';

export type MultiActionArray = Array<(node: HTMLElement) => ReturnType<Action>>;

export function multiAction(node: HTMLElement, arr: MultiActionArray) {
const destroyFns = arr.map((fn) => {
const actionReturn = fn(node);

return actionReturn
? actionReturn.destroy
: () => {
/* noop */
};
});
return {
destroy() {
destroyFns.forEach((fn) => fn());
}
};
}
20 changes: 18 additions & 2 deletions src/lib/commandCenter/commandCenter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,30 @@
import { commandCenterKeyDownHandler, disableCommands, registerCommands } from './commands';
import { RootPanel } from './panels';
import { addSubPanel, clearSubPanels, subPanels } from './subPanels';
import { addNotification } from '$lib/stores/notifications';

let debugOverlayEnabled = false;

$: $registerCommands([
{
callback: toggleCommandCenter,
keys: ['k'],
ctrl: true,
forceEnable: true
},
{
label: 'Toggle debug overlay',
callback: () => {
debugOverlayEnabled = !debugOverlayEnabled;
addNotification({
title: 'Debug overlay',
message: debugOverlayEnabled ? 'Enabled' : 'Disabled',
type: 'info'
});
},
keys: ['d', 'o'],
group: 'misc',
disabled: !dev
}
]);

Expand Down Expand Up @@ -100,7 +117,7 @@
</div>
{/if}

{#if dev}
{#if dev && debugOverlayEnabled}
<div class="debug-keys" use:portal>
{#each keys as key, i (i)}
<kbd class="kbd" transition:fade|local={{ duration: 150 }}>
Expand All @@ -126,7 +143,6 @@
left: 50%;
transform: translateX(-50%);
padding: 0.5rem;
// background-color: hsl(var(--color-neutral-500) / 0.5);
z-index: 9999;

display: flex;
Expand Down
24 changes: 14 additions & 10 deletions src/lib/commandCenter/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type KeyedCommand = BaseCommand & {
alt?: boolean;
};

function isKeyedCommand(command: Command): command is KeyedCommand {
return 'keys' in command;
export function isKeyedCommand(command: Command): command is KeyedCommand {
return 'keys' in command && Array.isArray((command as KeyedCommand).keys);
}

export type Command = KeyedCommand | BaseCommand;
Expand All @@ -83,7 +83,7 @@ function isInputEvent(event: KeyboardEvent) {
function getCommandRank(command: KeyedCommand) {
const { keys, ctrl: meta, shift, alt } = command;
const modifiers = [meta, shift, alt].filter(Boolean).length;
return keys.length + modifiers * 10;
return (keys?.length || 0) + modifiers * 10;
}

function hasDisputing(command: KeyedCommand, allCommands: Command[]) {
Expand All @@ -95,7 +95,7 @@ function hasDisputing(command: KeyedCommand, allCommands: Command[]) {
return false;
}
const keysString = command.keys.join('+');
const otherKeysString = otherCommand.keys.join('+');
const otherKeysString = otherCommand?.keys?.join('+');

const cmdRank = getCommandRank(command);
const otherCmdRank = getCommandRank(otherCommand);
Expand Down Expand Up @@ -195,8 +195,10 @@ export const commandCenterKeyDownHandler = derived(
const isShiftPressed = shift ? event.shiftKey : !event.shiftKey;
const isAltPressed = alt ? event.altKey : !event.altKey;

const commandKeyCodes = keys.map((key) => key.toUpperCase().charCodeAt(0));
const allKeysPressed = recentKeyCodes.join('').includes(commandKeyCodes.join(''));
const commandKeyCodes = keys?.map((key) => key.toUpperCase().charCodeAt(0));
const allKeysPressed = commandKeyCodes
? recentKeyCodes.join('').includes(commandKeyCodes.join(''))
: false;

if (allKeysPressed && isMetaPressed && isShiftPressed && isAltPressed) {
event.preventDefault();
Expand Down Expand Up @@ -288,10 +290,12 @@ export const commandGroupRanks = derived(groupRanksMap, ($groupRankTransformatio
const initialRanks = {
...Object.fromEntries(groups.map((group) => [group, 0])),
ungrouped: 9999,
databases: 3,
users: 2,
teams: 1,
navigation: -10,
databases: 50,
users: 40,
teams: 30,
projects: 20,
organizations: 10,
navigation: 0,
help: -20,
misc: -30
} as CommandGroupRanks;
Expand Down
107 changes: 71 additions & 36 deletions src/lib/commandCenter/panels/ai.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script lang="ts">
import Template from './template.svelte';

import { AvatarInitials, Code } from '$lib/components';
import { AvatarInitials, Code, LoadingDots, SvgIcon } from '$lib/components';
import { user } from '$lib/stores/user';
import { useCompletion } from 'ai/svelte';
import { subPanels } from '../subPanels';

import { isLanguage, type Language } from '$lib/components/code.svelte';
import CoolerAppwrite from '$lib/images/appwrite-cooler.svg';
import { VARS } from '$lib/system';

const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
Expand Down Expand Up @@ -62,7 +61,9 @@

answer.push({
type: 'code',
value: nextCodeMatch[2],
value: nextCodeMatch[2].startsWith('\n')
? nextCodeMatch[2].slice(1)
: nextCodeMatch[2],
language: isLanguage(language) ? language : 'js'
});

Expand All @@ -82,6 +83,11 @@
}

$: answer = parseCompletion($completion);

function getInitials(name: string) {
const [first, last] = name.split(' ');
return `${first?.[0] ?? ''}${last?.[0] ?? ''}`;
}
</script>

<Template
Expand All @@ -98,9 +104,14 @@
};
})}
clearOnCallback={false}
fullheight
--command-panel-max-height="40rem">
<div slot="search" />
on:keydown={(e) => {
e.detail.cancel();
}}
--min-height="40rem"
--max-height="52.5rem">
<div slot="search">
<span class="experimental border-gradient">EXPERIMENTAL</span>
</div>

<div slot="option" let:option class="u-flex u-cross-center u-gap-8">
<i class="icon-question-mark-circle" />
Expand All @@ -109,20 +120,28 @@

{#if $isLoading || answer}
<div class="content">
<div class="u-flex u-gap-8">
<div class="u-flex u-gap-8 u-cross-center">
<div class="avatar is-size-x-small">{getInitials($user.name)}</div>
<p class="u-opacity-75">{$input}</p>
</div>
<div class="u-flex u-gap-8 u-margin-block-start-24">
<div class="logo">
<img src={CoolerAppwrite} alt="Appwrite logo" />
<SvgIcon name="sparkles" type="color" />
</div>
<div class="answer">
{#if $isLoading && !$completion}
<p>...</p>
<LoadingDots />
{:else}
{#each answer as part}
{#if part.type === 'text'}
<p>{part.value}</p>
<p>{part.value.trimStart()}</p>
{:else if part.type === 'code'}
{#key part.value}
<Code language={part.language} code={part.value} />
<div
class="u-margin-block-start-8"
style="margin-block-end: 1rem;">
<Code language={part.language} code={part.value} noMargin />
</div>
{/key}
{/if}
{/each}
Expand Down Expand Up @@ -174,8 +193,16 @@
</Template>

<style lang="scss">
:global(.theme-dark) .content {
--logo-bg: #282a3b;
}

:global(.theme-light) .content {
--logo-bg: #f2f2f8;
}

.content {
overflow-y: auto;
overflow: auto;
padding: 1rem;

.logo {
Expand All @@ -187,7 +214,7 @@
flex-shrink: 0;

border-radius: 0.25rem;
background: #282a3b;
background: var(--logo-bg);
}

.answer {
Expand All @@ -197,29 +224,6 @@
white-space: pre-wrap;
}
}

h2 {
color: hsl(var(--color-neutral-70));
}

.examples {
display: flex;
flex-direction: column;

li {
padding: 0.59375rem 0.5rem;

button {
&:hover {
opacity: 0.75;
}

i {
color: hsl(var(--color-neutral-70));
}
}
}
}
}

.footer {
Expand All @@ -229,4 +233,35 @@
background-color: hsl(var(--color-neutral-150));
}
}

.experimental {
display: flex;
padding: 0.09375rem 0.25rem;
align-items: center;

color: var(--light-neutrals-30, #e8e9f0);
text-align: center;
font-family: Inter;
font-size: 0.625rem;
font-style: normal;
font-weight: 500;
line-height: 150%; /* 0.9375rem */
letter-spacing: 0.075rem;
text-transform: uppercase;

background: rgba(240, 46, 101, 0.24);
--border-gradient: linear-gradient(
to bottom,
rgba(240, 46, 101, 0.48) 0%,
rgba(240, 46, 101, 0) 150%
)
border-box;
--border-size: 0.03rem;
--border-radius: 0.25rem;
border-radius: var(--border-radius);
}

:global(.theme-light) .experimental {
color: rgba(240, 46, 101, 1);
}
</style>
4 changes: 2 additions & 2 deletions src/lib/commandCenter/panels/root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script lang="ts">
import { debounce } from '$lib/helpers/debounce';
import { isMac } from '$lib/helpers/platform';
import { commands, searchers, type Command } from '../commands';
import { commands, searchers, type Command, isKeyedCommand } from '../commands';
import Template from './template.svelte';

let search = '';
Expand Down Expand Up @@ -69,7 +69,7 @@
{#if hasAlt(command)}
<kbd class="kbd"> {isMac() ? '⌥' : 'Alt'} </kbd>
{/if}
{#if 'keys' in command}
{#if isKeyedCommand(command)}
{#each command.keys as key, i}
{@const hasNext = command.keys.length - 1 !== i}

Expand Down
Loading