diff --git a/src/canvas/components/ErrorDisplay.tsx b/src/canvas/components/ErrorDisplay.tsx index 5600db4b..bef439da 100644 --- a/src/canvas/components/ErrorDisplay.tsx +++ b/src/canvas/components/ErrorDisplay.tsx @@ -1,6 +1,11 @@ +import { css } from "@emotion/react"; import { Box, Code, Dialog, ScrollArea, Text } from "@radix-ui/themes"; import { memo } from "react"; +const styles = { + trigger: css({ cursor: "pointer" }), +}; + interface ErrorDisplayProps { id: string; error: string; @@ -11,25 +16,29 @@ const ErrorDisplay = memo(({ id, error, message }: ErrorDisplayProps) => { return ( - - + + An error occurred in widget {id}. Click anywhere to check the details. - - + + Error in widget {id} - + {error} - - - {message} - + + +
+                
+                  {message}
+                
+              
+
diff --git a/src/canvas/components/WidgetContainer.tsx b/src/canvas/components/WidgetContainer.tsx index 8fe8bc44..0c46b478 100644 --- a/src/canvas/components/WidgetContainer.tsx +++ b/src/canvas/components/WidgetContainer.tsx @@ -1,4 +1,4 @@ -import { RefObject, memo, useCallback, useRef } from "react"; +import { RefObject, memo, useRef } from "react"; import Draggable, { DraggableData, DraggableEvent } from "react-draggable"; import { ErrorBoundary } from "react-error-boundary"; import ErrorDisplay from "./ErrorDisplay"; @@ -6,6 +6,23 @@ import { stringifyError } from "../utils"; import { LuGripVertical } from "react-icons/lu"; import { Box } from "@radix-ui/themes"; import { updateWidgetSettings, useWidgetsStore } from "../hooks"; +import { css } from "@emotion/react"; + +const styles = { + wrapper: css({ + "&:hover": { ".handle": { opacity: 1 } }, + }), + handle: css({ + cursor: "grab", + opacity: 0, + zIndex: 2, + transition: "opacity 200ms ease-in-out", + }), + container: css({ + color: "var(--gray-12)", + zIndex: 1, + }), +}; interface WidgetContainerProps { id: string; @@ -15,69 +32,59 @@ const WidgetContainer = memo(({ id }: WidgetContainerProps) => { const { Component, width, height, x, y, opacity } = useWidgetsStore( (state) => state.widgets[id], ); - const containerRef = useRef(null); + const wrapperRef = useRef(null); - const onStop = useCallback( - (_: DraggableEvent, data: DraggableData) => { - updateWidgetSettings(id, { x: x + data.x, y: y + data.y }, true); - }, - [id, x, y], - ); + const onStop = (_: DraggableEvent, data: DraggableData) => { + updateWidgetSettings(id, { x: x + data.x, y: y + data.y }, true); + }; return ( } + nodeRef={wrapperRef as RefObject} onStop={onStop} bounds="body" - handle=".draggable-handle" + handle=".handle" position={{ x: 0, y: 0 }} > - - ( - - )} + + + + - - + ( + + )} + > + + + ); diff --git a/src/canvas/index.html b/src/canvas/index.html index 90785065..eb6e88ac 100644 --- a/src/canvas/index.html +++ b/src/canvas/index.html @@ -8,7 +8,7 @@ -
+
diff --git a/src/custom.css b/src/custom.css index ea5ea476..f5e3c6b7 100644 --- a/src/custom.css +++ b/src/custom.css @@ -1,4 +1,9 @@ .radix-themes { --em-font-family: var(--default-font-family); --em-font-size-adjust: 1; + + &[data-is-root-theme="true"] { + height: 100%; + width: 100%; + } } diff --git a/src/manager/App.tsx b/src/manager/App.tsx index 5942385c..89be4e50 100644 --- a/src/manager/App.tsx +++ b/src/manager/App.tsx @@ -25,12 +25,7 @@ const App = () => { useUpdateSettingsListener(); return ( - + { return ( - + @@ -27,15 +33,7 @@ const AboutTab = memo(() => { A cross-platform desktop customization tool - + Version diff --git a/src/manager/components/IntegerInput.tsx b/src/manager/components/IntegerInput.tsx index 1c3db743..24c60b32 100644 --- a/src/manager/components/IntegerInput.tsx +++ b/src/manager/components/IntegerInput.tsx @@ -1,6 +1,15 @@ +import { css } from "@emotion/react"; import { Box, BoxProps, Reset } from "@radix-ui/themes"; import { ChangeEvent, KeyboardEvent, useCallback } from "react"; +const styles = { + root: css({ + backgroundColor: "var(--gray-5)", + borderRadius: "var(--radius-2)", + lineHeight: "1.6", + }), +}; + type IntegerInputProps = BoxProps & { value: number; onValueChange: (value: number) => void; @@ -78,16 +87,7 @@ const IntegerInput = ({ }; return ( - + ) => { return ( - + {title} - + {children} diff --git a/src/manager/components/Settings/Shortcut.tsx b/src/manager/components/Settings/Shortcut.tsx index a56f83d7..9ea7af77 100644 --- a/src/manager/components/Settings/Shortcut.tsx +++ b/src/manager/components/Settings/Shortcut.tsx @@ -20,9 +20,21 @@ import { Shortcuts } from "../../../types"; import { updateShortcut, useAppSettingsStore } from "../../hooks"; import { toast } from "sonner"; import { INVALID_KEYCODES, KEYCODES, MODIFIERS } from "./keyboard"; +import { css } from "@emotion/react"; const INITIAL_PLACEHOLDER = "Shortcut disabled"; +const styles = { + input: css({ + width: "240px", + fontSize: "var(--font-size-2)", + paddingLeft: "var(--space-1)", + "> input": { cursor: "text" }, + "--text-field-focus-color": "var(--accent-8)", + }), + inputInvalid: css({ "--text-field-focus-color": "var(--red-8)" }), +}; + interface Props { shortcutKey: keyof Shortcuts; } @@ -165,15 +177,7 @@ const ShortcutAction = ({ shortcutKey }: Props) => { onFocus={handleFocus} onBlur={handleBlur} onKeyDown={handleKeyDown} - css={{ - width: "240px", - fontSize: "var(--font-size-2)", - paddingLeft: "var(--space-1)", - "> input": { cursor: "text" }, - "--text-field-focus-color": isValid - ? "var(--accent-8)" - : "var(--red-8)", - }} + css={[styles.input, !isValid && styles.inputInvalid]} > { {config.type === WidgetConfigType.VALID ? ( - + Name diff --git a/src/manager/components/Widgets/Dependencies.tsx b/src/manager/components/Widgets/Dependencies.tsx index 9e6011d6..850fff4f 100644 --- a/src/manager/components/Widgets/Dependencies.tsx +++ b/src/manager/components/Widgets/Dependencies.tsx @@ -1,6 +1,16 @@ +import { css } from "@emotion/react"; import { Code, Inset, Link, Popover, Table, Text } from "@radix-ui/themes"; import { memo } from "react"; +const styles = { + table: css({ + "--table-cell-padding": "var(--space-1) var(--space-2)", + "--table-cell-min-height": 0, + "[data-radix-scroll-area-viewport]": { maxHeight: "150px" }, + "& tr:last-child": { "--table-row-box-shadow": "none" }, + }), +}; + interface DependenciesProps { dependencies: Record; } @@ -17,15 +27,7 @@ const Dependencies = memo(({ dependencies }: DependenciesProps) => { - + {dependenciesArray.map(([name, version]) => ( diff --git a/src/manager/components/Widgets/Settings.tsx b/src/manager/components/Widgets/Settings.tsx index ec305d63..f2ef3b1b 100644 --- a/src/manager/components/Widgets/Settings.tsx +++ b/src/manager/components/Widgets/Settings.tsx @@ -3,6 +3,16 @@ import { LiaTimesSolid } from "react-icons/lia"; import { updateWidgetSettings, useWidgetsStore } from "../../hooks"; import { memo, useCallback } from "react"; import IntegerInput from "../IntegerInput"; +import { css } from "@emotion/react"; + +const styles = { + table: css({ + "--table-cell-padding": "var(--space-1) var(--space-2)", + "--table-cell-min-height": 0, + "& tr": { "--table-row-box-shadow": "none" }, + "& th": { color: "var(--gray-11)", width: "100px" }, + }), +}; const X = ({ id }: SettingsProps) => { const x = useWidgetsStore((state) => state.widgets[id].settings.x); @@ -68,16 +78,7 @@ interface SettingsProps { const Settings = memo(({ id }: SettingsProps) => { return ( - + Position (px) diff --git a/src/manager/components/Widgets/Trigger.tsx b/src/manager/components/Widgets/Trigger.tsx index b184f994..8b7681cb 100644 --- a/src/manager/components/Widgets/Trigger.tsx +++ b/src/manager/components/Widgets/Trigger.tsx @@ -2,6 +2,28 @@ import { Box, Flex, Tabs, Text } from "@radix-ui/themes"; import { WidgetConfigType } from "../../../types"; import { useWidgetsStore } from "../../hooks"; import { memo } from "react"; +import { css } from "@emotion/react"; + +const styles = { + trigger: css({ + justifyContent: "start", + height: "35px", + // Move the active bar indicator from bottom to left + "&::before": { + top: "10%", + bottom: "10%", + left: 0, + right: "unset", + height: "unset", + width: "2px", + }, + }), + indicator: css({ + borderRadius: "var(--radius-thumb)", + backgroundColor: "var(--green-10)", + }), + indicatorInvalid: css({ backgroundColor: "var(--red-10)" }), +}; interface TriggerProps { id: string; @@ -12,34 +34,15 @@ const Trigger = memo(({ id, value }: TriggerProps) => { const config = useWidgetsStore((state) => state.widgets[id].config); return ( - + {config.content.dir} diff --git a/src/manager/components/Widgets/index.tsx b/src/manager/components/Widgets/index.tsx index 611784a0..02e5b6a1 100644 --- a/src/manager/components/Widgets/index.tsx +++ b/src/manager/components/Widgets/index.tsx @@ -7,6 +7,12 @@ import GlobalActions from "./GlobalActions"; import Config from "./Config"; import Settings from "./Settings"; import Header from "./Header"; +import { css } from "@emotion/react"; + +const styles = { + tabList: css({ width: "25%", height: "100%", boxShadow: "none" }), + tabContent: css({ boxShadow: "inset 1px 0 0 0 var(--gray-a5)" }), +}; const WidgetsTab = memo(() => { const ids = useWidgetsStore( @@ -16,7 +22,7 @@ const WidgetsTab = memo(() => { return ( - + @@ -30,15 +36,13 @@ const WidgetsTab = memo(() => { {ids.map((id, index) => ( - - + +
diff --git a/src/manager/index.html b/src/manager/index.html index cd5c98ce..60199aa2 100644 --- a/src/manager/index.html +++ b/src/manager/index.html @@ -9,7 +9,7 @@ -
+