From 803b28218c327ff25d631ffa7cec62effaf0fd48 Mon Sep 17 00:00:00 2001 From: Anthony Buchholz Date: Mon, 13 Jan 2025 16:26:36 -0600 Subject: [PATCH] feat: add minifier functionality (#63) Add in the minifier function and general formatJson function to the services.ts file for JSONFormatter. Add the minify button and connect it to the function to actually work as expected. --- src/containers/JSONFormatter/index.tsx | 17 ++++++++++++++++- src/containers/JSONFormatter/services.ts | 22 +++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/containers/JSONFormatter/index.tsx b/src/containers/JSONFormatter/index.tsx index d76997e..58f2bc9 100644 --- a/src/containers/JSONFormatter/index.tsx +++ b/src/containers/JSONFormatter/index.tsx @@ -1,6 +1,7 @@ import React from 'react'; import SaveIcon from '@mui/icons-material/Save'; +import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen'; import WrapTextIcon from '@mui/icons-material/WrapText'; import { Box, Toolbar } from '@mui/material'; import Button from '@mui/material/Button'; @@ -48,9 +49,14 @@ const JSONFormatter: React.FC = ({ inputText, storeInputText }) => { const [formatted, setFormatted] = React.useState(''); React.useEffect(() => { - setFormatted(services.formatJson(inputText)); + setFormatted(services.prettifyJson(inputText)); }, [inputText]); + const handleMinify = (event: React.MouseEvent) => { + event.preventDefault(); + setFormatted(services.minifyJson(inputText)); + }; + const handleSaveAs = (event: React.MouseEvent) => { event.preventDefault(); fileService.saveJsonAs(formatted); @@ -81,6 +87,15 @@ const JSONFormatter: React.FC = ({ inputText, storeInputText }) => { +