Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/components/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ const useCodePersistence = (
// EditorControls component for the buttons section
const EditorControls = ({
handleValidate,
handleBeautify,
isValidating,
resetCode,
nextStepPath,
outputResult,
}: {
handleValidate: () => void;
handleBeautify: () => void;
isValidating: boolean;
resetCode: () => void;
nextStepPath: string | undefined;
Expand All @@ -126,6 +128,10 @@ const EditorControls = ({
<MyBtn onClick={resetCode} variant="error">
Reset
</MyBtn>

<MyBtn onClick={handleBeautify} variant="secondary">
Beautify
</MyBtn>
</Flex>
{!nextStepPath ? (
<CertificateButton />
Expand Down Expand Up @@ -208,6 +214,8 @@ export default function CodeEditor({
dispatchOutput({ type: "RESET" });
};

const handleBeautify = () => tryFormattingCode(editorRef, setCodeString);

const handleEditorMount = (editor: any, monaco: Monaco) => {
setMonaco(monaco);

Expand Down Expand Up @@ -237,6 +245,7 @@ export default function CodeEditor({
</div>
<EditorControls
handleValidate={handleValidate}
handleBeautify={handleBeautify}
isValidating={isValidating}
resetCode={resetCode}
nextStepPath={nextStepPath}
Expand Down
2 changes: 1 addition & 1 deletion app/components/MyBtn/MyBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function MyBtn({
size = "xs",
}: {
children: React.ReactNode;
variant: "success" | "error" | "default";
variant: "success" | "error" | "default" | "secondary";
onClick: () => void;
isDisabled?: boolean;
tooltip?: string;
Expand Down
13 changes: 13 additions & 0 deletions app/styles/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ const Button = {
bg: "hsl(var(--primary) / 0.6)",
},
},
secondary: {
color: "hsl(var(--text))",
bg: "hsl(var(--background2))",
borderColor: "hsl(var(--border-color))",
borderWidth: "1px",
_hover: {
bg: "hsl(var(--primary) / 0.12)",
borderColor: "hsl(var(--primary))",
},
_active: {
bg: "hsl(var(--primary) / 0.2)",
},
},
success: {
color: "hsl(var(--success))",
borderColor: "hsl(var(--success))",
Expand Down