-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from CommandDash/web-marketplace
feat(Marketplace): Marketplace is on landing page, Users can create github agents using create agent button
- Loading branch information
Showing
14 changed files
with
389 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export function clickOutside(element: HTMLElement, callbackFunction: () => void) { | ||
function onClick(event: MouseEvent) { | ||
if (!element.contains(event.target as Node)) { | ||
callbackFunction(); | ||
} | ||
} | ||
|
||
document.body.addEventListener("click", onClick); | ||
|
||
return { | ||
update(newCallbackFunction: () => void) { | ||
callbackFunction = newCallbackFunction; | ||
}, | ||
destroy() { | ||
document.body.removeEventListener("click", onClick); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<script lang="ts"> | ||
import { base } from "$app/paths"; | ||
import { clickOutside } from "$lib/actions/clickOutside"; | ||
import { goto } from "$app/navigation"; | ||
import { toastStore } from "$lib/stores/ToastStores"; | ||
import { ToastType } from "$lib/types/Toast"; | ||
import IconClose from "~icons/carbon/close"; | ||
import CarbonSearch from "~icons/carbon/search"; | ||
import CarbonGithub from "~icons/carbon/logo-github"; | ||
export let showModal: boolean; | ||
export let onClose: () => void; | ||
let dialog: HTMLDialogElement; | ||
let value: string = ""; | ||
const validateGithubURL = (url: string): boolean => { | ||
const githubUrlPattern = | ||
/^(https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/?)$/; | ||
return githubUrlPattern.test(url); | ||
}; | ||
const addGithubURL = (url: string) => { | ||
value = url; | ||
}; | ||
const onCreateAgent = () => { | ||
if (validateGithubURL(value)) { | ||
goto(`${base}/agent?github=${value}`); | ||
} else { | ||
toastStore.set({ | ||
message: "Please enter valid Github URL", | ||
type: ToastType.ERROR, | ||
}); | ||
} | ||
}; | ||
</script> | ||
|
||
{#if showModal} | ||
<div | ||
class="fixed inset-0 z-20 flex items-center justify-center bg-transparent backdrop-blur-sm" | ||
> | ||
<dialog | ||
bind:this={dialog} | ||
class="flex flex-col content-center items-center gap-x-10 gap-y-3 overflow-hidden rounded-xl border bg-gray-50/50 px-4 py-6 text-center shadow hover:bg-gray-50 hover:shadow-inner sm:h-64 sm:pb-4 xl:pt-8 dark:border-gray-800/70 dark:bg-gray-950 dark:hover:bg-gray-950 max-sm:w-[85dvw] max-sm:px-6 md:w-96 md:grid-cols-3 md:grid-rows-[auto,1fr] md:p-8" | ||
on:close={() => dialog.close()} | ||
open={showModal} | ||
> | ||
<div class="absolute right-0 top-0 mr-2 mt-2"> | ||
<button | ||
class="flex items-center px-2.5 py-1 text-sm text-white" | ||
on:click={onClose} | ||
> | ||
<IconClose class="mr-1.5 text-xl" /> | ||
</button> | ||
</div> | ||
<h1 class="text-xl font-bold text-white">Create Agent with Github</h1> | ||
<div | ||
class="relative flex h-[50px] min-w-full items-center rounded-md border px-2 has-[:focus]:border-gray-400 sm:w-64 dark:border-gray-600" | ||
> | ||
<CarbonGithub | ||
height="1.5em" | ||
width="1.5em" | ||
class="pointer-events-none absolute left-2 text-xs text-gray-400" | ||
/> | ||
<input | ||
class="h-[50px] w-full bg-transparent pl-7 focus:outline-none text-white" | ||
placeholder="Github Repo URL" | ||
type="url" | ||
{value} | ||
on:input={(e) => addGithubURL(e.currentTarget.value)} | ||
/> | ||
</div> | ||
<button | ||
on:click={onCreateAgent} | ||
class="mt-4 w-full rounded-full bg-gray-300 px-4 py-3 font-semibold text-black" | ||
> | ||
Submit | ||
</button> | ||
</dialog> | ||
</div> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,64 @@ | ||
<script lang="ts"> | ||
import { isDesktop } from "$lib/utils/isDesktop"; | ||
import { onMount, createEventDispatcher } from "svelte"; | ||
import { isDesktop } from "$lib/utils/isDesktop"; | ||
import { createEventDispatcher, onMount } from "svelte"; | ||
export let value: string = ""; | ||
export let placeholder: string = ""; | ||
export let minRows = 1; | ||
export let maxRows: null | number = null; | ||
export let disabled: boolean = false; | ||
export let value = ""; | ||
export let minRows = 1; | ||
export let maxRows: null | number = null; | ||
export let placeholder = ""; | ||
export let disabled = false; | ||
let textareaElement: HTMLTextAreaElement; | ||
let textareaElement: HTMLTextAreaElement; | ||
const dispatch = createEventDispatcher<{ submit: void }>(); | ||
const dispatch = createEventDispatcher<{ submit: void }>(); | ||
$: minHeight = `${1 + minRows * 1.5}em`; | ||
$: maxHeight = maxRows ? `${1 + maxRows * 1.5}em` : `auto`; | ||
$: minHeight = `${1 + minRows * 1.5}em`; | ||
$: maxHeight = maxRows ? `${1 + maxRows * 1.5}em` : `auto`; | ||
function handleKeydown(event: KeyboardEvent) { | ||
//submit on enter | ||
if (event.key === "Enter" && !event.shiftKey) { | ||
event.preventDefault(); | ||
function handleKeydown(event: KeyboardEvent) { | ||
if (event.key === "Enter" && !event.shiftKey) { | ||
event.preventDefault(); | ||
textareaElement.blur(); | ||
if (isDesktop(window)) { | ||
textareaElement.focus(); | ||
} | ||
dispatch("submit"); | ||
} | ||
} | ||
textareaElement.blur(); | ||
if (isDesktop(window)) { | ||
textareaElement.focus(); | ||
} | ||
dispatch("submit"); | ||
} | ||
} | ||
onMount(() => { | ||
if (isDesktop(window)) { | ||
textareaElement.focus(); | ||
} | ||
}); | ||
onMount(() => { | ||
if (isDesktop(window)) { | ||
textareaElement.focus(); | ||
} | ||
}); | ||
</script> | ||
|
||
<div class="relative min-w-0 flex-1" on:paste> | ||
<pre | ||
class="scrollbar-custom invisible overflow-x-hidden overflow-y-scroll whitespace-pre-wrap break-words p-3" | ||
aria-hidden="true" | ||
style="min-height: {minHeight}; max-height: {maxHeight}"></pre> | ||
<textarea | ||
enterkeyhint="send" | ||
tabindex="0" | ||
rows="1" | ||
bind:value | ||
bind:this={textareaElement} | ||
class="scrollbar-custom absolute top-0 m-0 h-full w-full resize-none scroll-p-3 overflow-x-hidden overflow-y-scroll border-0 bg-transparent p-3 outline-none focus:ring-0 focus-visible:ring-0" | ||
{placeholder} | ||
{disabled} | ||
on:keydown={handleKeydown} | ||
/> | ||
<pre | ||
class="scrollbar-custom invisible overflow-x-hidden overflow-y-scroll whitespace-pre-wrap break-words p-3" | ||
aria-hidden="true" | ||
style="min-height: {minHeight}; max-height: {maxHeight}">{(value || " ") + "\n"}</pre> | ||
|
||
<textarea | ||
enterkeyhint="send" | ||
tabindex="0" | ||
rows="1" | ||
class="scrollbar-custom absolute top-0 m-0 h-full w-full resize-none scroll-p-3 overflow-x-hidden overflow-y-scroll border-0 bg-transparent p-3 outline-none focus:ring-0 focus-visible:ring-0" | ||
class:text-gray-400={disabled} | ||
bind:value | ||
bind:this={textareaElement} | ||
{disabled} | ||
on:keydown={handleKeydown} | ||
on:beforeinput | ||
{placeholder} | ||
/> | ||
</div> | ||
|
||
<style> | ||
pre, | ||
textarea { | ||
font-family: inherit; | ||
box-sizing: border-box; | ||
line-height: 1.5; | ||
} | ||
pre, | ||
textarea { | ||
font-family: inherit; | ||
box-sizing: border-box; | ||
line-height: 1.5; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
export type Message = { | ||
role: "user" | "model"; | ||
text: string, | ||
references?: any[], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.