Skip to content

Commit

Permalink
Revert "feat(frontend): add loader and loading states"
Browse files Browse the repository at this point in the history
This reverts commit 46a7956.
  • Loading branch information
hkdeman committed Jan 28, 2025
1 parent 46a7956 commit e19fe5a
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 123 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type IButtonProps = {

export const Button: FC<IButtonProps> = (props) => {
return <motion.button className={twMerge(classNames("rounded-lg border flex justify-center items-center text-xs px-2 py-1 cursor-pointer gap-1 bg-white hover:bg-gray-100 dark:bg-white/10 dark:hover:bg-white/15 dark:border-white/20 dark:backdrop-blur-md", props.className, {
"cursor-not-allowed opacity-75": props.disabled,
"cursor-not-allowed": props.disabled,
"h-[35px] rounded-[4px] gap-2 hover:gap-3": props.type === "lg",
}))} onClick={props.onClick} disabled={props.disabled} whileTap={{ scale: 0.8 }}>
<div className={classNames("text-xs text-gray-600 dark:text-neutral-100", props.labelClassName)}>
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/classes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export const ClassNames = {
Text: "text-neutral-600 dark:text-neutral-300",
}

export const BASE_CARD_CLASS = "bg-white h-[200px] w-[200px] rounded-3xl shadow-sm border p-4 flex flex-col justify-between dark:bg-white/10 dark:border-white/5";
export const BRAND_COLOR = "text-[#ca6f1e] dark:text-[#ca6f1e]";
export const BRAND_COLOR_BG = "bg-[#ca6f1e] dark:bg-[#ca6f1e]";
2 changes: 1 addition & 1 deletion frontend/src/components/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const Dropdown: FC<IDropdownProps> = (props) => {
return (
<div className={classNames("relative", props.className)} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
{props.loading ? <div className="flex h-full w-full items-center justify-center">
<Loading hideText={true} size="sm" />
<Loading hideText={true} containerClassName="w-4 h-4" />
</div> :
<> <div className="group/dropdown flex gap-1 justify-between items-center border border-gray-200 rounded-lg w-full p-1 h-[34px] px-2 dark:bg-white/10 dark:border-white/20">
<div className="flex gap-1 text-gray-700 text-sm truncate items-center dark:text-neutral-300">
Expand Down
44 changes: 11 additions & 33 deletions frontend/src/components/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,26 @@
import classNames from "classnames";
import { FC } from "react";
import { twMerge } from "tailwind-merge";
import { ClassNames } from "./classes";

type ILoadingProps = {
className?: string;
hideText?: boolean;
containerClassName?: string;
loadingText?: string;
size?: "lg" | "md" | "sm";
textClassName?: string;
}

export const Loading: FC<ILoadingProps> = ({ className, hideText, loadingText, size = "md" }) => {
if (size === "sm") {
return <div className="flex justify-center items-center w-fit h-fit gap-1">
<div className="h-[16px] w-[16px] relative">
<div className="scale-[0.25] absolute top-0 left-0 -translate-y-[20px] -translate-x-[20px]">
<Loading className={className} hideText={hideText} loadingText={loadingText} size="lg" />
</div>
</div>
export const Loading: FC<ILoadingProps> = ({ containerClassName, className, hideText, loadingText, textClassName }) => {
return (
<div className={twMerge("h-full w-full flex flex-col justify-center items-center gap-2", containerClassName)} role="status">
<svg aria-hidden="true" className={twMerge(classNames("w-8 h-8 text-gray-200 animate-spin fill-[#ca6f1e] ", className))} viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
{
!hideText &&
<div className={classNames(ClassNames.Text, "text-sm")}>{loadingText}</div>
<div className={classNames("text-sm text-gray-500 dark:text-neutral-300", textClassName)}>{ loadingText ?? "Loading..."}</div>
}
</div>
}
if (size === "md") {
return <div className="flex justify-center items-center w-fit h-fit gap-1">
<div className="h-[32px] w-[32px] relative">
<div className="scale-[0.5] absolute top-0 left-0 -translate-y-[12px] -translate-x-[12px]">
<Loading className={className} hideText={hideText} loadingText={loadingText} size="lg" />
</div>
</div>
{
!hideText &&
<div className={classNames(ClassNames.Text, "text-sm")}>{loadingText}</div>
}
</div>
}
return <div className={twMerge("loader w-14 aspect-square animate-boxy rounded-full", className)}></div>;
}


export const LoadingPage: FC = () => {
return <div className="flex justify-center items-center h-full w-full">
<Loading size="lg" />
</div>
)
}
21 changes: 0 additions & 21 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@
@tailwind components;
@tailwind utilities;


@layer utilities {
.loader {
--g1: conic-gradient(from 90deg at top 3px left 3px, transparent 90deg, #666666 0);
--g2: conic-gradient(from -90deg at bottom 3px right 3px, transparent 90deg, #666666 0);
background: var(--g1), var(--g1), var(--g1), var(--g1), var(--g2), var(--g2), var(--g2), var(--g2);
background-position: 0 0, 100% 0, 100% 100%, 0 100%;
background-repeat: no-repeat;
animation: boxy 1.5s infinite;
}

.dark .loader {
--g1: conic-gradient(from 90deg at top 3px left 3px, transparent 90deg, #bbb 0);
--g2: conic-gradient(from -90deg at bottom 3px right 3px, transparent 90deg, #bbb 0);
background: var(--g1), var(--g1), var(--g1), var(--g1), var(--g2), var(--g2), var(--g2), var(--g2);
background-position: 0 0, 100% 0, 100% 100%, 0 100%;
background-repeat: no-repeat;
animation: boxy 1.5s infinite;
}
}

body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export const ChatPage: FC = () => {
})
}
{ loading && <div className="flex w-full justify-end mt-4">
<Loading loadingText="Waiting for response" size="sm" />
<Loading containerClassName="flex-row w-fit ml-8" loadingText="Waiting for response" textClassName="text-sm text-neutral-800 dark:text-neutral-300" className="w-4 h-4" />
</div> }
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/graph/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphElements } from "../../components/graph/constants";
import { Graph, IGraphInstance } from "../../components/graph/graph";
import { createEdge, createNode } from "../../components/graph/utils";
import { Icons } from "../../components/icons";
import { LoadingPage } from "../../components/loading";
import { Loading } from "../../components/loading";
import { InternalPage } from "../../components/page";
import { InternalRoutes } from "../../config/routes";
import { GetGraphDocument, GetGraphQuery, GetGraphQueryVariables } from "../../generated/graphql";
Expand Down Expand Up @@ -62,7 +62,7 @@ export const GraphPage: FC = () => {

if (loading) {
return <InternalPage routes={[InternalRoutes.Graph]}>
<LoadingPage />
<Loading />
</InternalPage>
}

Expand Down
18 changes: 9 additions & 9 deletions frontend/src/pages/raw-execute/raw-execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { v4 } from "uuid";
import { AnimatedButton } from "../../components/button";
import { CodeEditor } from "../../components/editor";
import { Icons } from "../../components/icons";
import { Loading, LoadingPage } from "../../components/loading";
import { Loading } from "../../components/loading";
import { InternalPage } from "../../components/page";
import { Table } from "../../components/table";
import { InternalRoutes } from "../../config/routes";
Expand Down Expand Up @@ -50,7 +50,11 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
return <div className="flex flex-col grow group/cell">
<div className="relative">
<div className="flex grow h-[150px] border border-gray-200 rounded-md overflow-hidden dark:bg-white/10 dark:border-white/5">
<CodeEditor language="sql" value={code} setValue={setCode} onRun={handleRawExecute} />
{
loading
? <Loading hideText={true} />
: <CodeEditor language="sql" value={code} setValue={setCode} onRun={handleRawExecute} />
}
</div>
<div className={classNames("absolute -bottom-3 z-20 flex justify-between px-3 pr-8 w-full opacity-0 transition-all duration-500 group-hover/cell:opacity-100", {
"opacity-100": showTools,
Expand All @@ -62,7 +66,7 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
<AnimatedButton className="bg-red-100/80 hover:bg-red-200 dark:hover:bg-red-900" iconClassName="stroke-red-800" labelClassName="text-red-800" icon={Icons.Delete} label="Delete" onClick={handleDelete} />
}
</div>
<AnimatedButton className="bg-green-200 hover:bg-green-400 dark:hover:bg-green-900" iconClassName="stroke-green-800" labelClassName="text-green-800" icon={Icons.CheckCircle} label="Submit query" onClick={handleRawExecute} disabled={loading} />
<AnimatedButton className="bg-green-200 hover:bg-green-400 dark:hover:bg-green-900" iconClassName="stroke-green-800" labelClassName="text-green-800" icon={Icons.CheckCircle} label="Submit query" onClick={handleRawExecute} />
</div>
</div>
{
Expand All @@ -72,16 +76,12 @@ const RawExecuteCell: FC<IRawExecuteCellProps> = ({ cellId, onAdd, onDelete, sho
</div>
}
{
loading
? <div className="flex justify-center items-center h-[250px]">
<Loading />
</div>
: rows != null && submittedCode.length > 0 &&
rows != null && submittedCode.length > 0 &&
(isCodeAQuery
?
<div className="flex flex-col w-full h-[250px] mt-4">
<Table columns={rows.RawExecute.Columns.map(c => c.Name)} columnTags={rows.RawExecute.Columns.map(c => c.Type)}
rows={rows.RawExecute.Rows} totalPages={1} currentPage={1} disableEdit={true} />
rows={rows.RawExecute.Rows} totalPages={1} currentPage={1} disableEdit={true} />
</div>
: <div className="bg-white/10 text-neutral-800 dark:text-neutral-300 rounded-lg p-2 flex gap-2 self-start items-center my-4">
Action Executed
Expand Down
23 changes: 7 additions & 16 deletions frontend/src/pages/storage-unit/explore-storage-unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AnimatedButton } from "../../components/button";
import { Dropdown } from "../../components/dropdown";
import { Icons } from "../../components/icons";
import { Input, InputWithlabel } from "../../components/input";
import { Loading, LoadingPage } from "../../components/loading";
import { Loading } from "../../components/loading";
import { InternalPage } from "../../components/page";
import { Table } from "../../components/table";
import { graphqlClient } from "../../config/graphql-client";
Expand Down Expand Up @@ -36,7 +36,6 @@ export const ExploreStorageUnit: FC = () => {
const [showAdd, setShowAdd] = useState(false);
const [newRowForm, setNewRowForm] = useState<RecordInput[]>([]);
const [checkedRows, setCheckedRows] = useState<Set<number>>(new Set());
const [deleting, setDeleting] = useState(false);

const [getStorageUnitRows, { loading }] = useGetStorageUnitRowsLazyQuery({
onCompleted(data) {
Expand All @@ -45,7 +44,7 @@ export const ExploreStorageUnit: FC = () => {
},
fetchPolicy: "no-cache",
});
const [addRow, { loading: adding }] = useAddRowMutation();
const [addRow,] = useAddRowMutation();

const unitName = useMemo(() => {
return unit?.Name;
Expand Down Expand Up @@ -118,9 +117,7 @@ export const ExploreStorageUnit: FC = () => {
if (current == null || rows == null || checkedRows.size === 0) {
return;
}
let unableToDeleteAll = false;
const deletedIndexes = [];
setDeleting(true);
for (const index of [...checkedRows].sort()) {
const row = rows.Rows[index];
if (row == null) {
Expand All @@ -140,7 +137,7 @@ export const ExploreStorageUnit: FC = () => {
storageUnit: unitName,
type: current.Type as DatabaseType,
values,
},
}
});
if (data?.DeleteRow.Status) {
return res();
Expand All @@ -157,8 +154,6 @@ export const ExploreStorageUnit: FC = () => {
} else {
notify(`Unable to delete the row: ${e}`, "error");
}
setDeleting(false);
unableToDeleteAll=true;
break;
}
}
Expand All @@ -173,10 +168,7 @@ export const ExploreStorageUnit: FC = () => {
Rows: newRows,
});
setCheckedRows(newCheckedRows);
if (!unableToDeleteAll) {
notify("Row deleted successfully!", "success");
}
setDeleting(false);
notify("Row deleted successfully!", "success");
}, [checkedRows, current, rows, schema, unitName]);

const totalCount = useMemo(() => {
Expand Down Expand Up @@ -411,7 +403,7 @@ export const ExploreStorageUnit: FC = () => {

if (loading) {
return <InternalPage routes={routes}>
<LoadingPage />
<Loading />
</InternalPage>
}

Expand Down Expand Up @@ -442,9 +434,8 @@ export const ExploreStorageUnit: FC = () => {
},
}} animate={showAdd ? "open" : "close"}>
<div className="flex w-full justify-end gap-2">
{adding || deleting && <Loading />}
{checkedRows.size > 0 && <AnimatedButton type="lg" icon={Icons.Delete} label={checkedRows.size > 1 ? "Delete rows" : "Delete row"} iconClassName="stroke-red-500 dark:stroke-red-500" labelClassName="text-red-500 dark:text-red-500" onClick={handleRowDelete} disabled={deleting} /> }
<AnimatedButton type="lg" icon={Icons.Add} label={showAdd ? "Cancel" : "Add Row"} onClick={handleToggleShowAdd} disabled={adding} />
{checkedRows.size > 0 && <AnimatedButton type="lg" icon={Icons.Delete} label={checkedRows.size > 1 ? "Delete rows" : "Delete row"} iconClassName="stroke-red-500 dark:stroke-red-500" labelClassName="text-red-500 dark:text-red-500" onClick={handleRowDelete} /> }
<AnimatedButton type="lg" icon={Icons.Add} label={showAdd ? "Cancel" : "Add Row"} onClick={handleToggleShowAdd} />
</div>
<div className={classNames("flex flex-col gap-2 overflow-y-auto h-full p-8 mt-2", {
"flex border border-white/5 rounded-lg": showAdd,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/storage-unit/storage-unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createDropdownItem, Dropdown } from "../../components/dropdown";
import { IGraphCardProps } from "../../components/graph/graph";
import { Icons } from "../../components/icons";
import { Input, InputWithlabel, Label } from "../../components/input";
import { Loading, LoadingPage } from "../../components/loading";
import { Loading } from "../../components/loading";
import { InternalPage } from "../../components/page";
import { SearchInput } from "../../components/search";
import { DATABASES_THAT_DONT_SUPPORT_SCRATCH_PAD } from "../../components/sidebar/sidebar";
Expand Down Expand Up @@ -223,7 +223,7 @@ export const StorageUnitPage: FC = () => {

if (loading) {
return <InternalPage routes={routes}>
<LoadingPage />
<Loading />
</InternalPage>
}

Expand Down
35 changes: 2 additions & 33 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,7 @@ module.exports = {
],
darkMode: 'selector',
theme: {
extend: {
fontFamily: {
title: `"Megrim", -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;`,
},
colors: {
brand: "#BF853E",
},
animation: {
fade: 'fadeOut 300ms ease-in-out',
boxy: 'boxy 1.5s infinite',
},
keyframes: () => ({
fadeOut: {
'0%': {
opacity: 0,
},
'100%': {
opacity: 100,
},
},
boxy: {
'0%': { backgroundSize: '35px 15px,15px 15px,15px 35px,35px 35px' },
'25%': { backgroundSize: '35px 35px,15px 35px,15px 15px,35px 15px' },
'50%': { backgroundSize: '15px 35px,35px 35px,35px 15px,15px 15px' },
'75%': { backgroundSize: '15px 15px,35px 15px,35px 35px,15px 35px' },
'100%': { backgroundSize: '35px 15px,15px 15px,15px 35px,35px 35px' },
},
}),
},
extend: {},
},
plugins: [],
}

}

0 comments on commit e19fe5a

Please sign in to comment.