diff --git a/src-web/App.tsx b/src-web/Workspace.tsx
similarity index 84%
rename from src-web/App.tsx
rename to src-web/Workspace.tsx
index 539c0842..53562d66 100644
--- a/src-web/App.tsx
+++ b/src-web/Workspace.tsx
@@ -1,5 +1,5 @@
import classnames from 'classnames';
-import { useEffect, useState } from 'react';
+import { useWindowSize } from 'react-use';
import { RequestPane } from './components/RequestPane';
import { ResponsePane } from './components/ResponsePane';
import { Sidebar } from './components/Sidebar';
@@ -12,16 +12,12 @@ type Params = {
requestId?: string;
};
-export function App({ matches }: { path: string; matches?: Params }) {
+export function Workspace({ matches }: { path: string; matches?: Params }) {
const workspaceId = matches?.workspaceId ?? '';
const { data: requests } = useRequests(workspaceId);
const request = requests?.find((r) => r.id === matches?.requestId);
-
- const [screenWidth, setScreenWidth] = useState(window.innerWidth);
- useEffect(() => {
- window.addEventListener('resize', () => setScreenWidth(window.innerWidth));
- }, []);
- const isH = screenWidth > 900;
+ const { width } = useWindowSize();
+ const isH = width > 900;
return (
diff --git a/src-web/components/AppRouter.tsx b/src-web/components/AppRouter.tsx
new file mode 100644
index 00000000..34f215c5
--- /dev/null
+++ b/src-web/components/AppRouter.tsx
@@ -0,0 +1,13 @@
+import { Router } from 'preact-router';
+import { Workspaces } from '../pages/Workspaces';
+import { Workspace } from '../Workspace';
+
+export function AppRouter() {
+ return (
+
+
+
+
+
+ );
+}
diff --git a/src-web/components/Button.tsx b/src-web/components/Button.tsx
index 6e5bbe08..a7fe0180 100644
--- a/src-web/components/Button.tsx
+++ b/src-web/components/Button.tsx
@@ -25,6 +25,7 @@ export type ButtonProps = {
children?: ComponentChildren;
disabled?: boolean;
title?: string;
+ tabIndex?: number;
};
export const Button = forwardRef(function Button(
@@ -35,7 +36,6 @@ export const Button = forwardRef(function Button(
color,
justify = 'center',
size = 'md',
- type = 'button',
...props
}: ButtonProps,
ref: ForwardedRef
,
@@ -43,7 +43,6 @@ export const Button = forwardRef(function Button(
return (
- {/**/}
{
+ console.log('UPDATED REQUEST');
queryClient.setQueryData(
requestsQueryKey(request.workspaceId),
(requests: HttpRequest[] = []) => {
@@ -45,12 +47,14 @@ await listen('updated_request', ({ payload: request }: { payload: HttpRequest })
});
await listen('deleted_request', ({ payload: request }: { payload: HttpRequest }) => {
+ console.log('DELETED REQUEST');
queryClient.setQueryData(requestsQueryKey(request.workspaceId), (requests: HttpRequest[] = []) =>
requests.filter((r) => r.id !== request.id),
);
});
await listen('updated_response', ({ payload: response }: { payload: HttpResponse }) => {
+ console.log('UPDATED RESPONSE');
queryClient.setQueryData(
responsesQueryKey(response.requestId),
(responses: HttpResponse[] = []) => {
@@ -91,11 +95,7 @@ render(
-
-
-
-
-
+
,
diff --git a/src-web/pages/Workspaces.tsx b/src-web/pages/Workspaces.tsx
index dfd70dfe..ee336d1c 100644
--- a/src-web/pages/Workspaces.tsx
+++ b/src-web/pages/Workspaces.tsx
@@ -1,10 +1,21 @@
+import { useEffect, useState } from 'react';
+import { useMount, useUnmount } from 'react-use';
import { ButtonLink } from '../components/ButtonLink';
+import { Editor } from '../components/Editor';
import { Heading } from '../components/Heading';
import { VStack } from '../components/Stacks';
import { useWorkspaces } from '../hooks/useWorkspaces';
export function Workspaces(props: { path: string }) {
const workspaces = useWorkspaces();
+ const [value, setValue] = useState('hello wolrd');
+ useUnmount(() => {
+ console.log('UNMOUNT WORKSPACES');
+ });
+ useMount(() => {
+ console.log('MOUNT WORKSPACES');
+ });
+ console.log('RENDER WORKSPACES');
return (
Workspaces
@@ -13,6 +24,7 @@ export function Workspaces(props: { path: string }) {
{w.name}
))}
+
);
}