From c030d1fbe4b3f392905b569628463e6ad6c27cfc Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Fri, 10 Apr 2026 21:00:52 -0400 Subject: [PATCH] feat: de-uglify the ACL editor --- app/components/tabs.tsx | 6 +- app/routes/acls/components/cm.client.tsx | 161 +++++++++-------------- app/routes/acls/components/fallback.tsx | 40 ++---- app/routes/acls/components/theme.ts | 63 +++++++++ app/routes/acls/overview.tsx | 4 +- app/tailwind.css | 70 ++++++++-- package.json | 5 +- pnpm-lock.yaml | 151 ++------------------- 8 files changed, 213 insertions(+), 287 deletions(-) create mode 100644 app/routes/acls/components/theme.ts diff --git a/app/components/tabs.tsx b/app/components/tabs.tsx index 3b9f270..c68e757 100644 --- a/app/components/tabs.tsx +++ b/app/components/tabs.tsx @@ -29,7 +29,7 @@ function TabList({ children, className }: { children: ReactNode; className?: str return ( @@ -76,7 +76,7 @@ function Panel({ value={value} {...props} className={cn( - "w-full overflow-clip rounded-b-lg rounded-r-lg", + "w-full overflow-clip rounded-b-md rounded-r-md", "border border-mist-200 dark:border-mist-800", className, )} diff --git a/app/routes/acls/components/cm.client.tsx b/app/routes/acls/components/cm.client.tsx index cf54c8c..ce49b68 100644 --- a/app/routes/acls/components/cm.client.tsx +++ b/app/routes/acls/components/cm.client.tsx @@ -1,112 +1,73 @@ -import * as shopify from '@shopify/lang-jsonc'; -import { xcodeDark, xcodeLight } from '@uiw/codemirror-theme-xcode'; -import CodeMirror from '@uiw/react-codemirror'; -import { BookCopy, CircleX } from 'lucide-react'; -import { useEffect, useState } from 'react'; -import Merge from 'react-codemirror-merge'; -import { ErrorBoundary } from 'react-error-boundary'; -import { ClientOnly } from 'remix-utils/client-only'; -import Fallback from './fallback'; +import * as shopify from "@shopify/lang-jsonc"; +import CodeMirror from "@uiw/react-codemirror"; +import { BookCopy, CircleX } from "lucide-react"; +import Merge from "react-codemirror-merge"; +import { ErrorBoundary } from "react-error-boundary"; + +import { headplaneTheme } from "./theme"; interface EditorProps { - isDisabled?: boolean; - value: string; - onChange: (value: string) => void; + isDisabled?: boolean; + value: string; + onChange: (value: string) => void; } -// TODO: Remove ClientOnly export function Editor(props: EditorProps) { - const [light, setLight] = useState(false); - useEffect(() => { - const theme = window.matchMedia('(prefers-color-scheme: light)'); - setLight(theme.matches); - theme.addEventListener('change', (theme) => { - setLight(theme.matches); - }); - }); - - return ( -
- - -

Failed to load the editor.

-
- } - > - }> - {() => ( - props.onChange(value)} - readOnly={props.isDisabled} - style={{ height: '100%' }} - theme={light ? xcodeLight : xcodeDark} - value={props.value} - /> - )} - - - - ); + return ( +
+ + +

Failed to load the editor.

+
+ } + > + props.onChange(value)} + readOnly={props.isDisabled} + theme={headplaneTheme} + value={props.value} + /> + + + ); } interface DifferProps { - left: string; - right: string; + left: string; + right: string; } export function Differ(props: DifferProps) { - const [light, setLight] = useState(false); - useEffect(() => { - const theme = window.matchMedia('(prefers-color-scheme: light)'); - setLight(theme.matches); - theme.addEventListener('change', (theme) => { - setLight(theme.matches); - }); - }); - - return ( -
- {props.left === props.right ? ( -
- -

No changes

-
- ) : ( -
- - -

- Failed to load the editor. -

-
- } - > - }> - {() => ( - - - - - )} - - -
- )} - - ); + return ( +
+ {props.left === props.right ? ( +
+ +

No changes

+
+ ) : ( +
+ + +

Failed to load the editor.

+
+ } + > + + + + + +
+ )} + + ); } diff --git a/app/routes/acls/components/fallback.tsx b/app/routes/acls/components/fallback.tsx index 6f8ef86..bcc5861 100644 --- a/app/routes/acls/components/fallback.tsx +++ b/app/routes/acls/components/fallback.tsx @@ -1,36 +1,18 @@ +import { Loader2 } from "lucide-react"; + import cn from "~/utils/cn"; -interface Props { - readonly acl: string; -} - -export default function Fallback({ acl }: Props) { +export default function Fallback() { return ( -
-
-
+
+
+
+ +

Loading editor…

+
-