Skip to content

Commit

Permalink
Minor UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
spaaaacccee committed Feb 28, 2024
1 parent 8dc97c1 commit ead0e6a
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function BreakpointListEditor({
handleBreakpointsChange(updatedBreakpoints)
}
addItemLabel="Breakpoint"
placeholder="No breakpoints."
placeholder="Get started by adding a breakpoint."
/>
</Box>
</Scroll>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/generic/ListEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export default function Editor<T>(props: Props<T>) {
</Typography>
</Box>
</Collapse>
<Box p={2} pt={2}>
<Stack p={2} pt={2} gap={2} direction="row">
<Button
disableElevation
variant="outlined"
Expand All @@ -429,7 +429,7 @@ export default function Editor<T>(props: Props<T>) {
<Box sx={{ color: "text.primary" }}>{addItemLabel}</Box>
</Button>
{extras}
</Box>
</Stack>
</List>
</DragDropContext>
);
Expand Down
7 changes: 5 additions & 2 deletions client/src/components/generic/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ export function SnackbarProvider({ children }: { children?: ReactNode }) {
},
]);
appendLog(() => ({
content: filter([message, secondary]).join(", "),
timestamp: `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
action: "append",
log: {
content: filter([message, secondary]).join(", "),
timestamp: `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
},
}));
if (options.error) {
console.error(`${message}, ${secondary}`);
Expand Down
27 changes: 23 additions & 4 deletions client/src/components/inspector/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,45 @@
import { WidgetsOutlined } from "@mui/icons-material";
import { Typography as Type } from "@mui/material";
import { Flex, FlexProps } from "components/generic/Flex";
import { cloneElement, ReactElement, ReactNode } from "react";
import { ReactElement, ReactNode } from "react";

export function Placeholder({
label,
icon = <WidgetsOutlined />,
secondary,
...rest
}: { label?: ReactNode; icon?: ReactElement } & FlexProps) {
}: {
label?: ReactNode;
icon?: ReactElement;
secondary?: ReactNode;
} & FlexProps) {
return (
<Flex
justifyContent="center"
alignItems="center"
color="text.secondary"
bgcolor="background.paper"
sx={{
gap: 2,
background: (t) => `repeating-linear-gradient(
45deg,
${t.palette.background.default},
${t.palette.background.paper} 1px,
${t.palette.background.paper} 7px,
${t.palette.background.default} 8px
)`,
}}
textAlign="center"
vertical
pt={6}
{...rest}
>
{cloneElement(icon, { sx: { mb: 2 }, fontSize: "large" })}
{icon}
<Type>{label}</Type>
{!!secondary && (
<Type variant="caption" sx={{ px: 8, maxWidth: 480 }}>
{secondary}
</Type>
)}
</Flex>
);
}
6 changes: 5 additions & 1 deletion client/src/components/inspector/TraceRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ function TraceRendererCircularProgress() {
);
}

const VIEWPORT_PAGE_DESCRIPTION =
"When you create a layer, you'll see it visualised here.";

export function TraceRenderer({
width,
height,
Expand Down Expand Up @@ -194,9 +197,10 @@ export function TraceRenderer({
) : (
<Placeholder
icon={<ViewInArOutlined />}
label="No layers to render"
label="Viewport"
width={width}
height={height}
secondary={VIEWPORT_PAGE_DESCRIPTION}
/>
)}
</TraceRendererContext.Provider>
Expand Down
13 changes: 12 additions & 1 deletion client/src/components/settings-editor/RendererEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ export function RendererEditor({ value, onValueChange }: RendererEditorProps) {
return (
<>
<Flex alignItems="center" py={1}>
<Box flex={1}>
<Box
flex={1}
sx={{
width: 0,
overflow: "hidden",
"> *": {
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
},
}}
>
<Type>
{current
? `${current.renderer.meta.name} ${current.renderer.meta.version}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function RendererListEditor() {
addItemExtras={
<FeaturePickerButton
icon={<ResetIcon />}
sx={{ ml: 2 }}
onClick={() => setSettings(() => ({ renderer: defaultRenderers }))}
>
Reset to Defaults
Expand Down
15 changes: 12 additions & 3 deletions client/src/components/settings-editor/ServerEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {
ManagedModal as Dialog,
AppBarTitle as Title,
} from "components/generic/Modal";
import { OverlineDot as Dot } from "components/generic/Overline";
import { SelectField as Select } from "components/generic/Select";
import { Space } from "components/generic/Space";
import { useConnection } from "hooks/useConnectionResolver";
import { useConnectionStatus } from "hooks/useConnectionStatus";
import { entries, omit, startCase } from "lodash";
Expand Down Expand Up @@ -54,7 +52,18 @@ export function ServerEditor({ value, onValueChange }: ServerEditorProps) {
return (
<>
<Flex alignItems="center" py={0.5}>
<Box flex={1}>
<Box
flex={1}
sx={{
width: 0,
overflow: "hidden",
"> *": {
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
},
}}
>
<Type>
{connection
? `${connection.name} ${connection.version}`
Expand Down
1 change: 0 additions & 1 deletion client/src/components/settings-editor/ServerListEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function ServerListEditor() {
addItemExtras={
<FeaturePickerButton
icon={<ResetIcon />}
sx={{ ml: 2 }}
onClick={() => setSettings(() => ({ remote: defaultRemotes }))}
>
Reset to Defaults
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/DebugPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ export function DebugPage({ template: Page }: PageContentProps) {
</Box>
</Box>
) : (
<Placeholder icon={<BugReportOutlined />} label="Debugger" />
<Placeholder
icon={<BugReportOutlined />}
label="Debugger"
secondary="Configure breakpoints and other debugging options here. First, you'll need to load a trace."
/>
)}
</Page.Content>
<Page.Extras>{controls}</Page.Extras>
Expand Down
14 changes: 12 additions & 2 deletions client/src/pages/InfoPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ListOutlined } from "@mui/icons-material";
import { CloseOutlined, ListOutlined } from "@mui/icons-material";
import { Divider, List, ListItem, ListItemText } from "@mui/material";
import { FeaturePickerButton } from "components/app-bar/FeaturePickerButton";
import { Flex } from "components/generic/Flex";
import { Scroll } from "components/generic/Scrollbars";
import { Placeholder } from "components/inspector/Placeholder";
Expand All @@ -11,10 +12,19 @@ import { PageContentProps } from "./PageMeta";
export function InfoPage({ template: Page }: PageContentProps) {
const { controls, onChange, state, dragHandle } = useViewTreeContext();

const [log] = useLog();
const [log, setLog] = useLog();
return (
<Page onChange={onChange} stack={state}>
<Page.Handle>{dragHandle}</Page.Handle>
<Page.Options>
<FeaturePickerButton
disabled={!log.length}
icon={<CloseOutlined />}
onClick={() => setLog(() => ({ action: "clear" }))}
>
Clear
</FeaturePickerButton>
</Page.Options>
<Page.Content>
<Flex vertical>
{log.length ? (
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/LayersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Scroll } from "components/generic/Scrollbars";
import { useViewTreeContext } from "components/inspector/ViewTree";
import { LayerListEditor } from "components/layer-editor/LayerListEditor";
import { PageContentProps } from "./PageMeta";

export function LayersPage({ template: Page }: PageContentProps) {
const { controls, onChange, state, dragHandle } = useViewTreeContext();

Expand Down
24 changes: 14 additions & 10 deletions client/src/pages/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ export function SettingsPage({ template: Page }: PageContentProps) {
}
function renderLabel(label: ReactNode) {
return (
<Type variant="body1" sx={{ minWidth: "max-content", mr: 4 }}>
<Type
variant="body1"
sx={{
mr: 4,
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
}}
>
{label}
</Type>
);
Expand All @@ -71,9 +79,8 @@ export function SettingsPage({ template: Page }: PageContentProps) {
<TabPanel value="general">
<Box>
{renderHeading("Playback")}
<Flex alignItems="center">
<Flex alignItems="center" justifyContent="space-between">
{renderLabel("Playback Rate")}
<Space flex={1} />
<Slider
sx={{ maxWidth: 320, mr: 2 }}
marks={[1, 2, 5, 10].map((v) => ({
Expand All @@ -94,17 +101,16 @@ export function SettingsPage({ template: Page }: PageContentProps) {
/>
</Flex>
{renderHeading("Appearance")}
<Flex alignItems="center">
<Flex alignItems="center" justifyContent="space-between">
{renderLabel("Acrylic")}
<Space flex={1} />
<Switch
defaultChecked={!!acrylic}
onChange={(_, v) =>
setSettings(() => ({ "appearance/acrylic": v }))
}
/>
</Flex>
<Flex alignItems="center">
<Flex alignItems="center" justifyContent="space-between">
{renderLabel("Dark Mode")}
<Space flex={1} />
<Switch
Expand All @@ -116,9 +122,8 @@ export function SettingsPage({ template: Page }: PageContentProps) {
}
/>
</Flex>
<Flex alignItems="center">
<Flex alignItems="center" justifyContent="space-between">
{renderLabel("Accent")}
<Space flex={1} />
<FeaturePicker
value={accentColor}
items={map(keys(accentColors), (c) => ({
Expand All @@ -134,9 +139,8 @@ export function SettingsPage({ template: Page }: PageContentProps) {
/>
</Flex>
{renderHeading("Behaviour")}
<Flex alignItems="center">
<Flex alignItems="center" justifyContent="space-between">
{renderLabel("Show Explore Panel on Start-up")}
<Space flex={1} />
<Switch
defaultChecked={!!showOnStart}
onChange={(_, v) =>
Expand Down
15 changes: 12 additions & 3 deletions client/src/pages/StepsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
DragIndicatorOutlined,
FiberManualRecordOutlined,
LayersOutlined as LayersIcon,
SegmentOutlined,
Expand Down Expand Up @@ -100,6 +99,11 @@ function useStepsPageState(
};
}

const getStepsPageDescription = (s?: string) =>
s
? `${s} contains 0 steps.`
: "When you load a trace, you'll see its steps here.";

export function StepsPage({ template: Page }: PageContentProps) {
const { spacing } = useTheme();
const paper = usePaper();
Expand Down Expand Up @@ -250,11 +254,16 @@ export function StepsPage({ template: Page }: PageContentProps) {
) : (
<Placeholder
icon={<SegmentOutlined />}
label={`${inferLayerName(layer)}`}
label="Steps"
secondary={getStepsPageDescription(inferLayerName(layer))}
/>
)
) : (
<Placeholder icon={<SegmentOutlined />} label="Steps" />
<Placeholder
icon={<SegmentOutlined />}
label="Steps"
secondary={getStepsPageDescription()}
/>
)}
</Flex>
{!!steps?.length && (
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/TreePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ export function TreePage({ template: Page }: PageContentProps) {
)}
</AutoSize>
) : (
<Placeholder icon={<AccountTreeOutlined />} label="Tree" />
<Placeholder
icon={<AccountTreeOutlined />}
label="Tree"
secondary="When you load a trace that has tree-like data, you'll see it as a decision tree here."
/>
)}
</Flex>
</Page.Content>{" "}
Expand Down
4 changes: 2 additions & 2 deletions client/src/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"short_name": "Visualiser",
"name": "Visualiser",
"version": "1.1.11-1",
"version": "1.1.11-2",
"description": "Visualise pathfinding search and more",
"version_name": "1.1.11-1; late February 2024",
"version_name": "1.1.11-2; late February 2024",
"repository": "https://github.com/path-visualiser/app",
"docs": "https://github.com/path-visualiser/app/blob/master/docs",
"homepage": "https://path-visualiser.github.io/",
Expand Down
19 changes: 14 additions & 5 deletions client/src/slices/log.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { createSlice } from "./createSlice";

import { createSlice } from "./createSlice";

type LogEntry = {
content: string;
timestamp?: string;
};

type Log = LogEntry[];

export const [useLog, LogProvider] = createSlice<Log, LogEntry>([], {
reduce: (prev, next) => [next, ...prev],
});
type LogAction = { action: "append"; log: LogEntry } | { action: "clear" };

export const [useLog, LogProvider] = createSlice<Log, LogAction>([], {
reduce: (prev, next) => {
switch (next.action) {
case "append":
return [next.log, ...prev];
case "clear":
return [];
}
},
});

0 comments on commit ead0e6a

Please sign in to comment.