Skip to content

Commit 233cdea

Browse files
authored
Merge pull request #28 from webxdc/resizable_windws
Resizable windows
2 parents 793f081 + f3b6de5 commit 233cdea

11 files changed

+237
-147
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This allows you to simulate multiple users using the same application.
1717

1818
You can install the tool globally. This works with any webxdc project:
1919

20-
```shell
20+
```
2121
npm install -g webxdc-dev
2222
```
2323

@@ -41,7 +41,10 @@ to see full information. You can also filter messages. There is also a "chat"
4141
tab which you can use to see `info` contained in updates as well as any
4242
`summary` text contained in an update.
4343

44-
You can collapse and expand the sidebar with the arrow.
44+
The sidebar can be closed with `Close Messages` button within the sidebar and
45+
expanded by clicking on `Open Messages` within the devices tab.
46+
The sidebars width can also be adjusted by moving the separating line between
47+
devices and sidebar.
4548

4649
Each instance header also contains additional information: the port number on
4750
which the instance was opened, the amount of updates this instance sent and

frontend/App.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Component } from "solid-js";
22
import { JSX, createSignal, createEffect } from "solid-js";
3-
import { Box, Tabs, TabList, Tab, TabPanel } from "@hope-ui/solid";
3+
import { Box, Tabs, TabList, Tab, TabPanel, Flex } from "@hope-ui/solid";
44
import { Route, Routes, useNavigate, useLocation } from "solid-app-router";
55

66
import Main from "./Main";
@@ -48,21 +48,21 @@ const App: Component = () => {
4848
};
4949

5050
return (
51-
<Tabs index={tabIndex()} onChange={handleTabsChange}>
52-
<TabList>
53-
<Tab>Main</Tab>
54-
<Tab>Info</Tab>
55-
</TabList>
56-
<TabPanel>
57-
<Panel>
51+
<Tabs h="$screenH" index={tabIndex()} onChange={handleTabsChange}>
52+
<Flex direction={"column"} h="$full" maxH="100vh">
53+
<TabList>
54+
<Tab>Main</Tab>
55+
<Tab>Info</Tab>
56+
</TabList>
57+
<TabPanel flexGrow="1" display="flex" justifyContent="center" maxHeight="calc(100vh - 40px)">
5858
<AppRoutes />
59-
</Panel>
60-
</TabPanel>
61-
<TabPanel>
62-
<Panel>
63-
<AppRoutes />
64-
</Panel>
65-
</TabPanel>
59+
</TabPanel>
60+
<TabPanel>
61+
<Panel>
62+
<AppRoutes />
63+
</Panel>
64+
</TabPanel>
65+
</Flex>
6666
</Tabs>
6767
);
6868
};

frontend/Chat.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Chat: Component<{
3535
<Show when={summary()}>
3636
{(summary) => <Badge>Summary: {summary}</Badge>}
3737
</Show>
38-
<Box width="53vw" maxHeight="36vh" overflow="scroll">
38+
<Box>
3939
<Table id="chat" dense css={{ "table-layout": "fixed" }}>
4040
<Thead>
4141
<Th width="10%" minWidth="7em">

frontend/Filter.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const Filter: Component<{
2626
}> = (props) => {
2727
return (
2828
<Select size="xs" value={props.value} onChange={props.onChange}>
29-
<SelectTrigger width="$64">
29+
<SelectTrigger>
3030
<SelectPlaceholder>{props.label}</SelectPlaceholder>
3131
<SelectValue />
3232
<SelectIcon />
3333
</SelectTrigger>
34-
<SelectContent width="$64">
34+
<SelectContent>
3535
<SelectListbox>
3636
<For each={props.entries}>
3737
{(entry) => (

frontend/Filters.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Filters: Component<{
1515
onChange: (search: Search) => void;
1616
}> = (props) => {
1717
return (
18-
<Flex justifyContent="flex-start" gap="$5">
18+
<Flex justifyContent="flex-start" gap="$5" mb="$1">
1919
<Filter
2020
label="instanceId"
2121
entries={instanceIdEntries()}

frontend/InstancesButtons.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Component } from "solid-js";
1+
import { Component, Show } from "solid-js";
22
import { Button, notificationService, Flex, Tooltip } from "@hope-ui/solid";
33

44
import type { Instance } from "../types/instance";
@@ -10,6 +10,8 @@ This wipes out any localStorage and sessionStorage on each client, and reloads t
1010

1111
const InstancesButtons: Component<{
1212
onAfterAdd?: (instanceId: string) => void;
13+
show_messages_button: boolean;
14+
onOpenMessages: () => void;
1315
}> = (props) => {
1416
const handleAddInstance = async () => {
1517
const instanceData: Instance = await (
@@ -40,10 +42,13 @@ const InstancesButtons: Component<{
4042

4143
return (
4244
<Flex direction="row" justifyContent="flex-start" gap="$3">
43-
<Button onClick={handleAddInstance}>Add Instance</Button>
45+
<Button colorScheme="neutral" size="xs" onClick={handleAddInstance}>Add Instance</Button>
4446
<Tooltip label={CLEAR_INFO}>
45-
<Button onClick={handleClear}>Reset</Button>
47+
<Button colorScheme="neutral" size="xs" onClick={handleClear}>Reset</Button>
4648
</Tooltip>
49+
<Show when={props.show_messages_button} >
50+
<Button colorScheme="neutral" size="xs" onClick={props.onOpenMessages}>Open Messages</Button>
51+
</Show>
4752
</Flex>
4853
);
4954
};

frontend/Main.tsx

+61-70
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { Component, For, createSignal, Show, Setter, JSX } from "solid-js";
1+
import { Component, For, createSignal, Setter, Show } from "solid-js";
22
import {
33
Flex,
44
Box,
5-
Tooltip,
6-
IconButton,
75
createDisclosure,
6+
Heading,
7+
Button,
88
} from "@hope-ui/solid";
9-
import { IoCaretBackOutline, IoCaretForwardOutline } from "solid-icons/io";
109

1110
import { instances } from "./store";
1211
import InstancesButtons from "./InstancesButtons";
1312
import { scrollToInstance } from "./Instance";
1413
import Sidebar, { Search } from "./Sidebar";
1514
import Instance from "./Instance";
1615
import type { Instance as InstanceData } from "../types/instance";
16+
import SplitView from "./SplitView";
1717

1818
const Main: Component = () => {
1919
const [search, setSearch] = createSignal<Search>({
@@ -24,78 +24,69 @@ const Main: Component = () => {
2424
onOpen();
2525
return setSearch(value);
2626
};
27-
2827
const { isOpen, onOpen, onClose } = createDisclosure({ defaultIsOpen: true });
2928

3029
return (
3130
<>
32-
<Flex justifyContent="space-between">
33-
<Flex flexDirection="column">
34-
<Box m="$8" ml="$1">
35-
<Flex flexWrap="wrap" gap="$5" overflow="scroll" maxHeight="77vh">
36-
<For each={instances()}>
37-
{(instance: InstanceData) => (
38-
<Instance instance={instance} setSearch={setSearchAndOpen} />
39-
)}
40-
</For>
31+
{
32+
<Show when={isOpen()} fallback={
33+
<Flex>
34+
<Flex flexDirection="column">
35+
<Flex mb="$1" justifyContent="space-between">
36+
<Heading level="1">Devices</Heading>
37+
<InstancesButtons
38+
onAfterAdd={(instanceId) => {
39+
scrollToInstance(instanceId);
40+
}}
41+
show_messages_button={true}
42+
onOpenMessages={onOpen}
43+
/>
44+
</Flex>
45+
<Box overflow="auto" >
46+
<Flex flexWrap="wrap" gap="$5" justifyContent="center">
47+
<For each={instances()}>
48+
{(instance: InstanceData) => (
49+
<Instance instance={instance} setSearch={setSearchAndOpen} />
50+
)}
51+
</For>
52+
</Flex>
53+
</Box>
54+
</Flex>
55+
</Flex>
56+
}>
57+
<SplitView>
58+
<Flex flexDirection="column">
59+
<Flex mb="$1" justifyContent="space-between">
60+
<Heading level="1">Devices</Heading>
61+
<InstancesButtons
62+
onAfterAdd={(instanceId) => {
63+
scrollToInstance(instanceId);
64+
}}
65+
show_messages_button={false}
66+
onOpenMessages={() => {}}
67+
/>
68+
</Flex>
69+
<Box overflow="auto" >
70+
<Flex flexWrap="wrap" gap="$5" justifyContent="center">
71+
<For each={instances()}>
72+
{(instance: InstanceData) => (
73+
<Instance instance={instance} setSearch={setSearchAndOpen} />
74+
)}
75+
</For>
76+
</Flex>
77+
</Box>
4178
</Flex>
42-
</Box>
43-
<InstancesButtons
44-
onAfterAdd={(instanceId) => {
45-
scrollToInstance(instanceId);
46-
}}
47-
/>
48-
</Flex>
49-
<Box height="100wh">
50-
<Show
51-
when={isOpen()}
52-
fallback={
53-
<SidebarButton
54-
label="Open messages"
55-
onClick={onOpen}
56-
top="2rem"
57-
right="-2rem"
58-
icon={<IoCaretBackOutline size={22} color="#000000" />}
59-
/>
60-
}
61-
>
62-
<SidebarButton
63-
label="Close messages"
64-
onClick={onClose}
65-
top="2rem"
66-
right="2rem"
67-
icon={<IoCaretForwardOutline size={22} color="#000000" />}
68-
/>
69-
<Sidebar search={search} setSearch={setSearchAndOpen} />
70-
</Show>
71-
</Box>
72-
</Flex>
79+
<Flex direction="column">
80+
<Flex justifyContent="space-between" marginBottom="$1">
81+
<Heading display="inline-block" level="1" mb="1">Messages</Heading>
82+
<Button colorScheme="neutral" size="xs" onClick={onClose}> Close Messages </Button>
83+
</Flex>
84+
<Sidebar search={search} setSearch={setSearchAndOpen} />
85+
</Flex>
86+
</SplitView>
87+
</Show>
88+
}
7389
</>
7490
);
7591
};
76-
77-
const SidebarButton: Component<{
78-
label: string;
79-
onClick: () => void;
80-
icon: JSX.Element;
81-
top: string;
82-
right: string;
83-
}> = (props) => {
84-
return (
85-
<Tooltip label={props.label}>
86-
<IconButton
87-
variant="ghost"
88-
size="sm"
89-
position="relative"
90-
top={props.top}
91-
right={props.right}
92-
onClick={props.onClick}
93-
aria-label={props.label}
94-
backgroundColor="white"
95-
icon={props.icon}
96-
/>
97-
</Tooltip>
98-
);
99-
};
100-
10192
export default Main;

frontend/Messages.tsx

+27-31
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,33 @@ const Messages: Component<{
2424
});
2525

2626
return (
27-
<Box width="53vw" maxHeight="36vh" overflow="scroll">
28-
<Table id="messages" dense css={{ "table-layout": "fixed" }}>
29-
<Thead>
30-
<Th width="10%" minWidth="7em">
31-
Id
32-
</Th>
33-
<Th width="10%">Type</Th>
34-
<Th width="20%">Descr</Th>
35-
<Th minWidth="60%">Payload</Th>
36-
</Thead>
37-
<Tbody>
38-
<For
39-
each={getMessages({
40-
instanceId: props.search().instanceId,
41-
type: props.search().type,
42-
})}
43-
>
44-
{(message, index) => (
45-
<MessageRow
46-
isSelected={messageIndex() === index()}
47-
message={message}
48-
onSelect={(message) => {
49-
setMessageIndex(index());
50-
props.onSelectMessage(message);
51-
}}
52-
/>
53-
)}
54-
</For>
55-
</Tbody>
56-
</Table>
57-
</Box>
27+
<Table id="messages" dense css={{ "table-layout": "fixed" }}>
28+
<Thead>
29+
<Th maxW="70px"> Id </Th>
30+
<Th maxW="70px">Type</Th>
31+
<Th maxW="70px">Descr</Th>
32+
<Th>Payload</Th>
33+
</Thead>
34+
<Tbody>
35+
<For
36+
each={getMessages({
37+
instanceId: props.search().instanceId,
38+
type: props.search().type,
39+
})}
40+
>
41+
{(message, index) => (
42+
<MessageRow
43+
isSelected={messageIndex() === index()}
44+
message={message}
45+
onSelect={(message) => {
46+
setMessageIndex(index());
47+
props.onSelectMessage(message);
48+
}}
49+
/>
50+
)}
51+
</For>
52+
</Tbody>
53+
</Table>
5854
);
5955
};
6056

0 commit comments

Comments
 (0)