Skip to content

Commit

Permalink
chore: checkpoint splitting components
Browse files Browse the repository at this point in the history
  • Loading branch information
marabesi committed Jul 17, 2022
1 parent 8030454 commit 626b73a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 28 deletions.
76 changes: 49 additions & 27 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import JsonMenu from "./components/JsonMenu";

const cleanUp = new CleanUp();

function Header() {
return <div className="bg-blue-900 flex justify-between p-5 text-white">
<div className="flex">
<h2 className="text-yellow-400 font-bold">JSON tool</h2> |
<a href="https://github.com/marabesi/json-tool" target="_blank" rel="noreferrer">by marabesi</a>
</div>
<a data-testid="buy-me-a-coffee" href="https://www.buymeacoffee.com/marabesi" target="_blank" rel="noreferrer">Buy
me a coffee</a>
</div>;
}

function App() {
const [originalJson, setOriginalResult] = useState<string>('');
const [result, setResult] = useState<string>('');
Expand Down Expand Up @@ -80,17 +91,11 @@ function App() {
const updateSpacing = (newSpacing: string) => setSpacing(newSpacing);

return (
<div className="bg-gray-500">
<div className="bg-blue-900 flex justify-between p-5 text-white">
<div className="flex">
<h2 className="text-yellow-400 font-bold">JSON tool</h2> |
<a href="https://github.com/marabesi/json-tool" target="_blank" rel="noreferrer">by marabesi</a>
</div>
<a data-testid="buy-me-a-coffee" href="https://www.buymeacoffee.com/marabesi" target="_blank" rel="noreferrer">Buy me a coffee</a>
</div>
<div className="h-screen p-1">
<div className="bg-gray-500 flex flex-col h-screen">
<Header />
<div className="p-1 h-full">
<div className="flex h-5/6">
<div className="w-3/6 flex flex-col h-full m-1">
<EditorContainer>
<JsonMenu
pasteFromClipboard={pasteFromClipboard}
cleanup={cleanup}
Expand All @@ -101,30 +106,47 @@ function App() {
onChange={eventValue => onJsonChange(eventValue.value)}
data-testid="json"
/>
</div>
<div className="w-3/6 flex flex-col h-full m-1">
<ResultMenu
spacing={spacing}
updateSpacing={updateSpacing}
writeToClipboard={writeToClipboard}
cleanWhiteSpaces={cleanWhiteSpaces}
cleanNewLines={cleanNewLines}
cleanNewLinesAndSpaces={cleanNewLinesAndSpaces}
/>

<JsonEditor
input={result}
className="result"
data-testid="result"
/>
</div>
</EditorContainer>
<EditorContainer>
<ResultMenu
spacing={spacing}
updateSpacing={updateSpacing}
writeToClipboard={writeToClipboard}
cleanWhiteSpaces={cleanWhiteSpaces}
cleanNewLines={cleanNewLines}
cleanNewLinesAndSpaces={cleanNewLinesAndSpaces}
/>

<JsonEditor
input={result}
className="result"
data-testid="result"
/>
</EditorContainer>
</div>
<div className="bg-red-600 m-1 text-center text-white">
{error && <p data-testid="error">{error}</p>}
</div>
</div>
<div className="flex bg-gray-200 text-white p-5">
<span>
Footer text or link about CC
</span>
|
<span>
Other foot text with usual legal stuff
</span>
</div>
</div>
);
}

export default App;

function EditorContainer({ children }: any) {
return (
<div className="w-3/6 flex flex-col h-full m-1">
{children}
</div>
);
}
10 changes: 10 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function Header() {
return <div className="bg-blue-900 flex justify-between p-5 text-white">
<div className="flex">
<h2 className="text-yellow-400 font-bold">JSON tool</h2> |
<a href="https://github.com/marabesi/json-tool" target="_blank" rel="noreferrer">by marabesi</a>
</div>
<a data-testid="buy-me-a-coffee" href="https://www.buymeacoffee.com/marabesi" target="_blank" rel="noreferrer">Buy
me a coffee</a>
</div>;
}
2 changes: 1 addition & 1 deletion src/components/JsonEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function JsonEditor({ input, onChange, className, ...rest }: Prop
<CodeMirror
value={input}
onChange={handleChange}
className={[className, 'h-full'].join(' ')}
className={[className, 'h-full mt-5'].join(' ')}
style={{
fontSize: 12,
backgroundColor: fullConfig.theme.backgroundColor.gray['200'],
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ module.exports = {
extend: {},
},
plugins: [],
extend: {}
};

0 comments on commit 626b73a

Please sign in to comment.