Skip to content

Commit

Permalink
enh: sparkle-ization of app design (#1215)
Browse files Browse the repository at this point in the history
* enh: sparkle-ization of app design

* fuck

* fix build

* nit
  • Loading branch information
spolu authored Sep 1, 2023
1 parent 327c874 commit 32714f3
Show file tree
Hide file tree
Showing 37 changed files with 1,462 additions and 1,267 deletions.
85 changes: 0 additions & 85 deletions front/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,90 +1,5 @@
import { classNames } from "@app/lib/utils";

export function Button({
type = "button",
onClick = null,
disabled = false,
children,
}: React.PropsWithChildren<{
type?: "button" | "submit" | "reset" | undefined;
onClick?: any;
disabled?: boolean;
}>) {
return (
<button
type={type ? type : "button"}
className={classNames(
"inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium leading-4",
disabled ? "text-gray-300" : "text-gray-700 hover:bg-gray-50",
"shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2"
)}
onClick={onClick}
disabled={disabled}
>
{children}
</button>
);
}

export function ActionButton({
type = "button",
onClick = null,
onMouseDown = null,
disabled = false,
children,
}: React.PropsWithChildren<{
type?: "button" | "submit" | "reset" | undefined;
onClick?: any;
onMouseDown?: any; // useful when you don't want to end selection
disabled?: boolean;
}>) {
return (
<button
type={type ? type : "button"}
className={classNames(
"inline-flex items-center rounded-md border px-3 py-1 text-sm font-medium leading-6",
disabled
? "border-gray-200 bg-white text-gray-300"
: "border-gray-700 bg-gray-700 text-white hover:bg-gray-800",
"shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2"
)}
onClick={onClick}
onMouseDown={onMouseDown}
disabled={disabled}
>
{children}
</button>
);
}

export function HighlightButton({
type,
onClick,
disabled,
children,
}: React.PropsWithChildren<{
type?: "button" | "submit" | "reset" | undefined;
onClick?: any;
disabled?: boolean;
}>) {
return (
<button
type={type ? type : "button"}
className={classNames(
"inline-flex items-center rounded-md border px-3 py-1 text-sm font-medium leading-6",
disabled
? "border-gray-200 bg-white text-gray-300"
: "border-action-600 bg-action-600 text-white hover:bg-action-500",
"shadow-sm focus:outline-none focus:ring-2 focus:ring-action-500 focus:ring-offset-2"
)}
onClick={onClick}
disabled={disabled}
>
{children}
</button>
);
}

export function GoogleSignInButton({
onClick = null,
children,
Expand Down
17 changes: 8 additions & 9 deletions front/components/GoogleDriveFoldersPickerModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button } from "@dust-tt/sparkle";
import { Dialog, Transition } from "@headlessui/react";
import { Fragment, useEffect, useRef, useState } from "react";
import TreeView, { INode } from "react-accessible-treeview";
Expand All @@ -7,8 +8,6 @@ import { IoMdArrowDropdown, IoMdArrowDropright } from "react-icons/io";
import { GoogleDriveSelectedFolderType } from "@app/lib/connectors_api";
import { WorkspaceType } from "@app/types/user";

import { ActionButton, Button } from "./Button";

export default function GoogleDriveFoldersPickerModal(props: {
owner: WorkspaceType;
connectorId: string;
Expand Down Expand Up @@ -153,22 +152,22 @@ export default function GoogleDriveFoldersPickerModal(props: {
onClick={() => {
props.setOpen(false);
}}
>
Cancel
</Button>
label="Cancel"
type="secondary"
/>
</div>
<div className="ml-3">
<ActionButton
<Button
type="primary"
onClick={async () => {
if (selectedFoldersToSave) {
await onSave(selectedFoldersToSave);
}
props.setOpen(false);
}}
disabled={!selectedFoldersToSave}
>
Save
</ActionButton>
label="Save"
/>
</div>
</div>
</Dialog.Panel>
Expand Down
2 changes: 1 addition & 1 deletion front/components/app/DatasetPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChevronDownIcon } from "@dust-tt/sparkle";
import { Menu } from "@headlessui/react";
import { ChevronDownIcon } from "@heroicons/react/20/solid";
import Link from "next/link";

import { useDatasets } from "@app/lib/swr";
Expand Down
34 changes: 16 additions & 18 deletions front/components/app/DatasetView.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import "@uiw/react-textarea-code-editor/dist.css";

import {
ArrowDownOnSquareIcon,
ArrowUpOnSquareIcon,
Button,
PlusCircleIcon,
PlusIcon,
XCircleIcon,
} from "@heroicons/react/20/solid";
import {
ArrowDownOnSquareIcon,
ArrowUpOnSquareStackIcon,
} from "@heroicons/react/24/outline";
} from "@dust-tt/sparkle";
import dynamic from "next/dynamic";
import { useEffect, useRef, useState } from "react";
import TextareaAutosize from "react-textarea-autosize";

import { Button } from "@app/components/Button";
import { checkDatasetData } from "@app/lib/datasets";
import { getDatasetTypes, getValueType } from "@app/lib/datasets";
import { MODELS_STRING_MAX_LENGTH } from "@app/lib/utils";
Expand Down Expand Up @@ -614,17 +612,18 @@ export default function DatasetView({
<div className="mt-6 flex flex-row">
{!readOnly ? (
<Button
type="secondary"
onClick={() => {
handleNewEntry(datasetData.length - 1);
}}
>
<PlusIcon className="-ml-1 mr-1 h-5 w-5" />
New Entry
</Button>
icon={PlusIcon}
label="New Entry"
/>
) : null}
<div className="flex-1"></div>
<div className="ml-2 flex-initial">
<Button
type="tertiary"
onClick={() => {
const dataStr =
"data:text/jsonl;charset=utf-8," +
Expand All @@ -643,10 +642,9 @@ export default function DatasetView({
downloadAnchorNode.click();
downloadAnchorNode.remove();
}}
>
<ArrowDownOnSquareIcon className="-ml-1 mr-1 h-5 w-5" />
Download
</Button>
icon={ArrowDownOnSquareIcon}
label="Download"
/>
</div>
<div className="ml-2 flex-initial">
<input
Expand All @@ -662,15 +660,15 @@ export default function DatasetView({
></input>
{!readOnly ? (
<Button
type="tertiary"
onClick={() => {
if (fileInputRef.current) {
fileInputRef.current.click();
}
}}
>
<ArrowUpOnSquareStackIcon className="-ml-1 mr-1 h-5 w-5" />
JSONL
</Button>
icon={ArrowUpOnSquareIcon}
label="JSONL"
/>
) : null}
</div>
</div>
Expand Down
61 changes: 36 additions & 25 deletions front/components/app/Deploy.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import "@uiw/react-textarea-code-editor/dist.css";

import {
Button,
ClipboardIcon,
CubeIcon,
DocumentTextIcon,
} from "@dust-tt/sparkle";
import { Dialog, Transition } from "@headlessui/react";
import { CubeIcon, DocumentDuplicateIcon } from "@heroicons/react/20/solid";
import { ArrowRightCircleIcon } from "@heroicons/react/24/outline";
import dynamic from "next/dynamic";
import Link from "next/link";
import { Fragment, useState } from "react";

import { ActionButton, Button, HighlightButton } from "@app/components/Button";
import { useKeys } from "@app/lib/swr";
import { classNames } from "@app/lib/utils";
import { AppType, SpecificationType } from "@app/types/app";
Expand Down Expand Up @@ -82,20 +85,20 @@ export default function Deploy({

return (
<div>
<HighlightButton
disabled={disabled}
<Button
label="deploy"
type="primary"
onClick={() => {
setOpen(!open);
}}
>
<CubeIcon className="-ml-1 mr-1 h-5 w-5" />
Deploy
</HighlightButton>
disabled={disabled}
icon={CubeIcon}
/>

<Transition.Root show={open} as={Fragment}>
<Dialog
as="div"
className="relative z-10"
className="relative z-30"
onClose={() => setOpen(false)}
>
<Transition.Child
Expand Down Expand Up @@ -180,34 +183,42 @@ export default function Deploy({
</div>
<div className="flex-1"></div>
<div className="mt-1">
<ActionButton onClick={handleCopyClick}>
<DocumentDuplicateIcon className="-ml-1 mr-1 mt-0.5 h-5 w-5" />
{copyButtonText}
</ActionButton>
<Button
type="primary"
onClick={handleCopyClick}
label={copyButtonText}
icon={ClipboardIcon}
/>
</div>
</div>
<p className="mt-4 text-sm text-gray-500">
For a detailed documentation of the Run model and Run
creation parameters, refer to the API reference.
</p>
<p className="mt-2">
<Link
href="https://docs.dust.tt/runs"
target="_blank"
className="mr-2"
>
<Button>
<ArrowRightCircleIcon className="-ml-1 mr-2 h-4 w-4" />
Visit API Reference
</Button>
</Link>
<Button
icon={DocumentTextIcon}
label="Visit API Reference"
type="secondary"
onClick={() => {
window.open(
"https://docs.dust.tt/runs",
"_blank",
"noopener,noreferrer"
);
}}
/>
</p>
</div>
</div>
<div className="mt-5 flex flex-row items-center space-x-2 sm:mt-6">
<div className="flex-1"></div>
<div className="flex flex-initial">
<Button onClick={() => setOpen(false)}>Close</Button>
<Button
type="secondary"
onClick={() => setOpen(false)}
label="Close"
/>
</div>
</div>
</Dialog.Panel>
Expand Down
2 changes: 1 addition & 1 deletion front/components/app/ModelPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChevronDownIcon } from "@dust-tt/sparkle";
import { Menu } from "@headlessui/react";
import { ChevronDownIcon } from "@heroicons/react/20/solid";
import Link from "next/link";
import { useEffect } from "react";
import { useState } from "react";
Expand Down
20 changes: 8 additions & 12 deletions front/components/app/NewBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button } from "@dust-tt/sparkle";
import { Menu } from "@headlessui/react";
import { PlusIcon } from "@heroicons/react/20/solid";

Expand Down Expand Up @@ -121,18 +122,13 @@ export default function NewBlock({
<PlusIcon className="h-4 w-4" />
</Menu.Button>
) : (
<Menu.Button
className={classNames(
"inline-flex items-center rounded-md border px-3 py-1 text-sm font-medium leading-6",
disabled
? "border-gray-200 bg-white text-gray-300"
: "border-gray-700 bg-gray-700 text-white hover:bg-gray-800",
"shadow-sm focus:outline-none focus:ring-0 focus:ring-2"
)}
disabled={disabled}
>
<PlusIcon className="-ml-1 mr-1 h-5 w-5" />
Block
<Menu.Button as="div" disabled={disabled}>
<Button
type="secondary"
label="Add Block"
icon={PlusIcon}
disabled={disabled}
/>
</Menu.Button>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion front/components/app/SpecRunView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function SpecRunView({
TODO(spolu): investigate */}
<TextareaAutosize className="hidden" value="foo" />

<div className="flex flex-col space-y-2">
<div className="flex flex-col gap-y-4">
{spec.map((block, idx) => {
// Match status with block
let status = null;
Expand Down
Loading

0 comments on commit 32714f3

Please sign in to comment.