Skip to content

Commit

Permalink
[UI v2] feat: Adds Server Settings component
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Jan 30, 2025
1 parent e19fbfe commit 105081d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 9 additions & 3 deletions ui-v2/src/components/settings/server-settings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { JsonInput } from "@/components/ui/json-input";

type ServerSettingsProps = {
settings: Record<string, unknown>;
};
Expand All @@ -6,9 +8,13 @@ export const ServerSettings = ({ settings }: ServerSettingsProps) => {
return (
<div className="flex flex-col gap-1">
<label htmlFor="server-settings">Server Settings</label>
<div id="server-settings" className="p-2 bg-slate-100 rounded-sm">
TODO: {JSON.stringify(settings)}
</div>
<JsonInput
id="server-settings"
className="p-2 rounded-sm"
value={JSON.stringify(settings, null, 2)}
disabled
hideLineNumbers
/>
</div>
);
};
12 changes: 11 additions & 1 deletion ui-v2/src/components/ui/json-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ type JsonInputProps = React.ComponentProps<"div"> & {
onBlur?: () => void;
disabled?: boolean;
className?: string;
hideLineNumbers?: boolean;
};

export const JsonInput = React.forwardRef<HTMLDivElement, JsonInputProps>(
(
{ className, value, onChange, onBlur, disabled, ...props },
{
className,
value,
onChange,
onBlur,
disabled,
hideLineNumbers = false,
...props
},
forwardedRef,
) => {
const editor = useRef<HTMLDivElement | null>(null);
Expand All @@ -29,6 +38,7 @@ export const JsonInput = React.forwardRef<HTMLDivElement, JsonInputProps>(
let basicSetup: BasicSetupOptions | undefined;
if (disabled) {
basicSetup = {
lineNumbers: !hideLineNumbers,
highlightActiveLine: false,
foldGutter: false,
highlightActiveLineGutter: false,
Expand Down

0 comments on commit 105081d

Please sign in to comment.