Skip to content

Commit

Permalink
improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
AykutSarac committed Jan 28, 2023
1 parent 732208e commit 1c77a14
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 69 deletions.
4 changes: 4 additions & 0 deletions src/components/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const StyledEditorWrapper = styled.div`
rect {
fill: ${({ theme }) => theme.BACKGROUND_NODE};
}
@media only screen and (max-width: 320px) {
height: 100vh;
}
`;

const GraphComponent = ({ isWidget = false, openModal, setSelectedNode }: GraphProps) => {
Expand Down
1 change: 0 additions & 1 deletion src/components/Modal/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const HeaderWrapper = styled.div`
`;

export const ContentWrapper = styled.div`
color: ${({ theme }) => theme.TEXT_NORMAL};
background: ${({ theme }) => theme.MODAL_BACKGROUND};
padding: 16px;
overflow: hidden auto;
Expand Down
24 changes: 7 additions & 17 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from "react";
import toast from "react-hot-toast";
import { AiOutlineDelete, AiOutlineSave, AiOutlineFileAdd, AiOutlineEdit } from "react-icons/ai";
import { CgArrowsMergeAltH, CgArrowsShrinkH } from "react-icons/cg";
import { FiDownload } from "react-icons/fi";
import { MdCenterFocusWeak } from "react-icons/md";
import { TiFlowMerge } from "react-icons/ti";
import {
VscAccount,
Expand Down Expand Up @@ -213,13 +211,6 @@ export const Sidebar: React.FC = () => {
component={<StyledFlowIcon rotate={rotateLayout(direction)} />}
/>

<SidebarButton
title="Center View"
deviceDisplay="mobile"
onClick={centerView}
component={<MdCenterFocusWeak />}
/>

<SidebarButton
title={foldNodes ? "Unfold Nodes" : "Fold Nodes"}
deviceDisplay="desktop"
Expand All @@ -229,7 +220,6 @@ export const Sidebar: React.FC = () => {

<SidebarButton
title={graphCollapsed ? "Expand Graph" : "Collapse Graph"}
deviceDisplay="desktop"
onClick={toggleExpandCollapseGraph}
component={graphCollapsed ? <VscExpandAll /> : <VscCollapseAll />}
/>
Expand All @@ -241,13 +231,6 @@ export const Sidebar: React.FC = () => {
component={<AiOutlineSave />}
/>

<SidebarButton
title="Download Image"
deviceDisplay="mobile"
onClick={() => setVisible("download")(true)}
component={<FiDownload />}
/>

<SidebarButton
title="Delete JSON"
onClick={() => setVisible("clear")(true)}
Expand All @@ -260,6 +243,13 @@ export const Sidebar: React.FC = () => {
onClick={() => setVisible("cloud")(true)}
component={<VscCloud />}
/>

<SidebarButton
title="Settings"
deviceDisplay="mobile"
onClick={() => setVisible("settings")(true)}
component={<VscSettingsGear />}
/>
</StyledTopWrapper>
<StyledBottomWrapper>
<SidebarButton
Expand Down
46 changes: 20 additions & 26 deletions src/containers/Editor/LiveEditor/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useGraph from "src/store/useGraph";
import useModal from "src/store/useModal";
import styled from "styled-components";

export const StyledTools = styled.div<{ isWidget: boolean }>`
export const StyledTools = styled.div`
position: relative;
display: flex;
align-items: center;
Expand All @@ -20,11 +20,7 @@ export const StyledTools = styled.div<{ isWidget: boolean }>`
box-shadow: 0 1px 0px ${({ theme }) => theme.BACKGROUND_TERTIARY};
z-index: 1;
@media only screen and (max-width: 768px) {
display: ${({ isWidget }) => !isWidget && "none"};
}
@media only screen and (max-width: 480px) {
@media only screen and (max-width: 320px) {
display: none;
}
`;
Expand Down Expand Up @@ -61,25 +57,23 @@ export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) =>
const toggleEditor = () => toggleFullscreen(!fullscreen);

return (
<>
<StyledTools isWidget={isWidget}>
<StyledToolElement aria-label="fullscreen" hide={isWidget} onClick={toggleEditor}>
<AiOutlineFullscreen />
</StyledToolElement>
<SearchInput />
<StyledToolElement aria-label="save" onClick={() => setVisible("download")(true)}>
<FiDownload />
</StyledToolElement>
<StyledToolElement aria-label="center canvas" onClick={centerView}>
<MdCenterFocusWeak />
</StyledToolElement>
<StyledToolElement aria-label="zoom out" onClick={zoomOut}>
<AiOutlineMinus />
</StyledToolElement>
<StyledToolElement aria-label="zoom in" onClick={zoomIn}>
<AiOutlinePlus />
</StyledToolElement>
</StyledTools>
</>
<StyledTools>
<StyledToolElement aria-label="fullscreen" hide={isWidget} onClick={toggleEditor}>
<AiOutlineFullscreen />
</StyledToolElement>
<SearchInput />
<StyledToolElement aria-label="save" onClick={() => setVisible("download")(true)}>
<FiDownload />
</StyledToolElement>
<StyledToolElement aria-label="center canvas" onClick={centerView}>
<MdCenterFocusWeak />
</StyledToolElement>
<StyledToolElement aria-label="zoom out" onClick={zoomOut}>
<AiOutlineMinus />
</StyledToolElement>
<StyledToolElement aria-label="zoom in" onClick={zoomIn}>
<AiOutlinePlus />
</StyledToolElement>
</StyledTools>
);
};
2 changes: 1 addition & 1 deletion src/containers/ModalController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LoginModal } from "src/containers/Modals/LoginModal";
import { SettingsModal } from "src/containers/Modals/SettingsModal";
import { ShareModal } from "src/containers/Modals/ShareModal";
import useModal from "src/store/useModal";
import shallow from "zustand/shallow";
import { shallow } from "zustand/shallow";

export const ModalController = () => {
const setVisible = useModal(state => state.setVisible);
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Modals/DownloadModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const DownloadModal: React.FC<ModalProps> = ({ visible, setVisible }) =>

if (!blob) return;

navigator.clipboard.write([
navigator.clipboard?.write([
new ClipboardItem({
[blob.type]: blob,
}),
Expand Down
45 changes: 25 additions & 20 deletions src/containers/Modals/NodeModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,59 @@
import React from "react";
import dynamic from "next/dynamic";
import toast from "react-hot-toast";
import { FiCopy } from "react-icons/fi";
import { vscDarkPlus } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { vs } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { Button } from "src/components/Button";
import { Modal } from "src/components/Modal";
import styled from "styled-components";
import useStored from "src/store/useStored";

const SyntaxHighlighter = dynamic(
() => import("react-syntax-highlighter/dist/esm/prism-async").then(c => c),
{
ssr: false,
}
);

interface NodeModalProps {
selectedNode: object;
visible: boolean;
closeModal: () => void;
}

const StyledTextarea = styled.textarea`
resize: none;
width: 100%;
min-height: 200px;
padding: 10px;
background: ${({ theme }) => theme.BACKGROUND_TERTIARY};
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
outline: none;
border-radius: 4px;
line-height: 20px;
border: none;
`;

export const NodeModal = ({ selectedNode, visible, closeModal }: NodeModalProps) => {
const lightmode = useStored(state => state.lightmode);
const nodeData = Array.isArray(selectedNode) ? Object.fromEntries(selectedNode) : selectedNode;

const handleClipboard = () => {
toast.success("Content copied to clipboard!");
navigator.clipboard.writeText(JSON.stringify(nodeData));
navigator.clipboard?.writeText(JSON.stringify(nodeData));
closeModal();
};

return (
<Modal visible={visible} setVisible={closeModal}>
<Modal.Header>Node Content</Modal.Header>
<Modal.Content>
<StyledTextarea
defaultValue={JSON.stringify(
<SyntaxHighlighter
style={lightmode ? vs : vscDarkPlus}
customStyle={{
borderRadius: "4px",
fontSize: "14px",
margin: "0",
}}
language="json"
showLineNumbers
>
{JSON.stringify(
nodeData,
(_, v) => {
if (typeof v === "string") return v.replaceAll('"', "");
return v;
},
2
)}
readOnly
/>
</SyntaxHighlighter>
</Modal.Content>
<Modal.Controls setVisible={closeModal}>
<Button status="SECONDARY" onClick={handleClipboard}>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Modals/SettingsModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Modal, ModalProps } from "src/components/Modal";
import Toggle from "src/components/Toggle";
import useStored from "src/store/useStored";
import styled from "styled-components";
import shallow from "zustand/shallow";
import { shallow } from "zustand/shallow";

const StyledToggle = styled(Toggle)`
flex-flow: row-reverse;
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Modals/ShareModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ShareModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
const shareURL = `https://jsoncrack.com/editor?json=${query.json}`;

const handleShare = (value: string) => {
navigator.clipboard.writeText(value);
navigator.clipboard?.writeText(value);
toast.success(`Link copied to clipboard.`);
setVisible(false);
};
Expand Down
8 changes: 7 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from "react";
import { darkTheme } from "src/constants/theme";
import Home from "src/containers/Home";
import { ThemeProvider } from "styled-components";

const HomePage = () => {
return <Home />;
return (
<ThemeProvider theme={darkTheme}>
<Home />
</ThemeProvider>
);
};

export default HomePage;

0 comments on commit 1c77a14

Please sign in to comment.