Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General UI/UX Improvements #133

Merged
merged 1 commit into from
Sep 1, 2022
Merged
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
17 changes: 17 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,31 @@ const StyledButton = styled.button<{
color: #ffffff;
padding: 8px 16px;
min-width: 60px;
min-height: 32px;
border-radius: 3px;
font-size: 14px;
font-weight: 500;
font-family: "Catamaran", sans-serif;
width: ${({ block }) => (block ? "100%" : "fit-content")};
height: 40px;
background-image: none;

:disabled {
cursor: not-allowed;
opacity: 0.5;
}

div {
white-space: normal;
margin: 0 auto;
text-overflow: ellipsis;
overflow: hidden;
}

&:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
}

@media only screen and (max-width: 768px) {
font-size: 14px;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ErrorContainer/ErrorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const StyledErrorWrapper = styled.div`
`;

const StyledErrorExpand = styled.button<{ error: boolean }>`
position: relative;
display: flex;
width: 100%;
padding: 4px 16px;
Expand All @@ -25,10 +26,10 @@ const StyledErrorExpand = styled.button<{ error: boolean }>`
background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
box-shadow: 0 1px 0px ${({ theme }) => theme.BACKGROUND_TERTIARY};
cursor: pointer;
z-index: 100;

&:hover {
color: ${({ theme }) => theme.TEXT_DANGER};
box-shadow: none;
}
`;

Expand Down
3 changes: 3 additions & 0 deletions src/components/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const StyledEditorWrapper = styled.div<{ isWidget: boolean }>`
width: 100%;
height: ${({ isWidget }) => (isWidget ? "100vh" : "calc(100vh - 36px)")};
background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
background-image: ${({ theme }) => `radial-gradient(#505050 0.5px, ${theme.BACKGROUND_SECONDARY} 0.5px)`};
background-size: 10px 10px;
z-index: 0;

:active {
cursor: move;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ModalWrapper = styled.div`
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, 0.85);
z-index: 36;
z-index: 100;

* {
box-sizing: border-box;
Expand Down
53 changes: 34 additions & 19 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AiOutlineLink,
AiOutlineEdit,
} from "react-icons/ai";
import { FiDownload } from "react-icons/fi";

import { Tooltip } from "src/components/Tooltip";
import { useRouter } from "next/router";
Expand All @@ -24,6 +25,7 @@ import { HiHeart } from "react-icons/hi";
import shallow from "zustand/shallow";
import { MdCenterFocusWeak } from "react-icons/md";
import { getNextLayout } from "src/utils/getNextLayout";
import { DownloadModal } from "src/containers/Modals/DownloadModal";

const StyledSidebar = styled.div`
display: flex;
Expand All @@ -41,19 +43,19 @@ const StyledSidebar = styled.div`
}
`;

const StyledElement = styled.div<{ beta?: boolean }>`
const StyledElement = styled.button`
position: relative;
display: flex;
justify-content: center;
text-align: center;
font-size: 26px;
font-weight: 600;
width: 100%;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
width: fit-content;
color: ${({ theme }) => theme.SIDEBAR_ICONS};
cursor: pointer;

svg {
padding: 8px;
padding: 12px 8px;
vertical-align: middle;
}

Expand All @@ -64,11 +66,20 @@ const StyledElement = styled.div<{ beta?: boolean }>`
&:hover :is(a, svg) {
color: ${({ theme }) => theme.INTERACTIVE_HOVER};
}

@media only screen and (max-width: 768px) {
font-size: 22px;

svg {
padding: 8px 4px;
vertical-align: middle;
}
}
`;

const StyledText = styled.span<{ secondary?: boolean }>`
color: ${({ theme, secondary }) =>
secondary ? theme.INTERACTIVE_NORMAL : theme.ORANGE};
secondary ? theme.INTERACTIVE_HOVER : theme.ORANGE};
`;

const StyledFlowIcon = styled(TiFlowMerge)<{ rotate: number }>`
Expand All @@ -82,21 +93,14 @@ const StyledTopWrapper = styled.nav`
align-items: center;
width: 100%;

& > div:nth-child(n + 1) {
border-bottom: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
}

.mobile {
display: none;
}

@media only screen and (max-width: 768px) {
justify-content: space-evenly;
flex-direction: row;

& > div:nth-child(n + 1) {
border-bottom: none;
}

.mobile {
display: initial;
}
Expand All @@ -114,18 +118,19 @@ const StyledBottomWrapper = styled.nav`
align-items: center;
width: 100%;

& > div,
a:nth-child(0) {
border-top: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
}

@media only screen and (max-width: 768px) {
display: none;
}
`;

const StyledLogo = styled.div`
const StyledLogo = styled.a`
color: ${({ theme }) => theme.FULL_WHITE};
padding: 8px 4px;
border-bottom: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};

@media only screen and (max-width: 768px) {
border-bottom: 0;
}
`;

function rotateLayout(layout: "LEFT" | "RIGHT" | "DOWN" | "UP") {
Expand All @@ -142,6 +147,7 @@ export const Sidebar: React.FC = () => {
const [uploadVisible, setUploadVisible] = React.useState(false);
const [clearVisible, setClearVisible] = React.useState(false);
const [shareVisible, setShareVisible] = React.useState(false);
const [isDownloadVisible, setDownloadVisible] = React.useState(false);
const { push } = useRouter();

const [expand, layout, hideEditor] = useConfig(
Expand Down Expand Up @@ -215,6 +221,11 @@ export const Sidebar: React.FC = () => {
<AiOutlineSave />
</StyledElement>
</Tooltip>
<Tooltip className="mobile" title="Download Image">
<StyledElement onClick={() => setDownloadVisible(true)}>
<FiDownload />
</StyledElement>
</Tooltip>
<Tooltip title="Clear JSON">
<StyledElement onClick={() => setClearVisible(true)}>
<AiOutlineDelete />
Expand Down Expand Up @@ -252,6 +263,10 @@ export const Sidebar: React.FC = () => {
<ImportModal visible={uploadVisible} setVisible={setUploadVisible} />
<ClearModal visible={clearVisible} setVisible={setClearVisible} />
<ShareModal visible={shareVisible} setVisible={setShareVisible} />
<DownloadModal
visible={isDownloadVisible}
setVisible={setDownloadVisible}
/>
</StyledSidebar>
);
};
4 changes: 2 additions & 2 deletions src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ interface TooltipProps extends React.ComponentPropsWithoutRef<"div"> {

const StyledTooltipWrapper = styled.div`
position: relative;
width: 100%;
width: fit-content;
height: 100%;
`;

const StyledTooltip = styled.div<{ visible: boolean }>`
position: absolute;
top: 0;
right: 0;
transform: translate(calc(100% + 15px), 10%);
transform: translate(calc(100% + 15px), 25%);
z-index: 5;
background: ${({ theme }) => theme.BACKGROUND_PRIMARY};
color: ${({ theme }) => theme.TEXT_NORMAL};
Expand Down
4 changes: 2 additions & 2 deletions src/constants/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Example taken from https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json
export const defaultJson = {
export const defaultJson = JSON.stringify({
squadName: "Super hero squad",
homeTown: "Metro City",
formed: 2016,
Expand Down Expand Up @@ -35,4 +35,4 @@ export const defaultJson = {
],
},
],
};
});
22 changes: 5 additions & 17 deletions src/constants/globalStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,14 @@ const GlobalStyle = createGlobalStyle`
}

button {
min-height: 32px;
border: none;
border-radius: 3px;
outline: none;
font-family: 'Catamaran', sans-serif;
font-weight: 500;
font-size: 14px;
background-image: none;
-webkit-tap-highlight-color: transparent;
background: transparent;
width: fit-content;
margin: 0;
padding: 0;
cursor: pointer;

div {
white-space: normal;
margin: 0 auto;
text-overflow: ellipsis;
overflow: hidden;
}

&:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
}
}

#carbonads * {
Expand Down
2 changes: 2 additions & 0 deletions src/constants/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const darkTheme: DefaultTheme = {
SILVER_DARK: "#4D4D4D",
NODE_KEY: "#FAA81A",
OBJECT_KEY: "#59b8ff",
SIDEBAR_ICONS: "#8B8E90",

INTERACTIVE_NORMAL: "#b9bbbe",
INTERACTIVE_HOVER: "#dcddde",
Expand All @@ -44,6 +45,7 @@ export const lightTheme: DefaultTheme = {
SILVER_DARK: "#CCCCCC",
NODE_KEY: "#DC3790",
OBJECT_KEY: "#0260E8",
SIDEBAR_ICONS: "#6D6E70",

INTERACTIVE_NORMAL: "#4f5660",
INTERACTIVE_HOVER: "#2e3338",
Expand Down
5 changes: 2 additions & 3 deletions src/containers/Editor/JsonEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from "react";
import styled from "styled-components";
import Editor from "@monaco-editor/react";
import parseJson from "parse-json";
import { loader } from "@monaco-editor/react";
import MonacoEditor, { loader } from "@monaco-editor/react";
import { ErrorContainer } from "src/components/ErrorContainer/ErrorContainer";
import useConfig from "src/hooks/store/useConfig";
import { Loading } from "src/components/Loading";
Expand Down Expand Up @@ -76,7 +75,7 @@ export const JsonEditor: React.FC = () => {
<StyledEditorWrapper>
<ErrorContainer error={error} />
<StyledWrapper>
<Editor
<MonacoEditor
height="100%"
defaultLanguage="json"
value={value}
Expand Down
24 changes: 13 additions & 11 deletions src/containers/Editor/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ import {
AiOutlinePlus,
} from "react-icons/ai";
import { FiDownload } from "react-icons/fi";
import { HiOutlineSun, HiOutlineMoon } from "react-icons/hi";
import { MdCenterFocusWeak } from "react-icons/md";
import { SearchInput } from "src/components/SearchInput";
import styled from "styled-components";
import useConfig from "src/hooks/store/useConfig";
import shallow from "zustand/shallow";
import { DownloadModal } from "../Modals/DownloadModal";
import useStored from "src/hooks/store/useStored";
import { TbSettings } from "react-icons/tb";
import { Settings } from "./Settings";
import { SettingsModal } from "src/containers/Modals/SettingsModal";

export const StyledTools = styled.div`
position: relative;
display: flex;
align-items: center;
gap: 4px;
Expand All @@ -26,6 +24,7 @@ export const StyledTools = styled.div`
background: ${({ theme }) => theme.BACKGROUND_PRIMARY};
color: ${({ theme }) => theme.SILVER};
box-shadow: 0 1px 0px ${({ theme }) => theme.BACKGROUND_TERTIARY};
z-index: 36;

@media only screen and (max-width: 768px) {
display: none;
Expand All @@ -38,6 +37,12 @@ const StyledToolElement = styled.button`
font-size: 20px;
background: none;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
padding: 6px;
border-radius: 3px;

&:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
}

&:hover {
color: ${({ theme }) => theme.INTERACTIVE_HOVER};
Expand All @@ -49,8 +54,6 @@ const StyledToolElement = styled.button`
export const Tools: React.FC = () => {
const [settingsVisible, setSettingsVisible] = React.useState(false);
const [isDownloadVisible, setDownloadVisible] = React.useState(false);
const lightmode = useStored((state) => state.lightmode);
const setLightTheme = useStored((state) => state.setLightTheme);

const hideEditor = useConfig((state) => state.hideEditor);
const setConfig = useConfig((state) => state.setConfig);
Expand All @@ -59,7 +62,6 @@ export const Tools: React.FC = () => {
const zoomOut = useConfig((state) => state.zoomOut);
const centerView = useConfig((state) => state.centerView);
const toggleEditor = () => setConfig("hideEditor", !hideEditor);
const toggleTheme = () => setLightTheme(!lightmode);

return (
<StyledTools>
Expand All @@ -72,9 +74,6 @@ export const Tools: React.FC = () => {
>
<TbSettings />
</StyledToolElement>
<StyledToolElement aria-label="switch theme" onClick={toggleTheme}>
{lightmode ? <HiOutlineMoon /> : <HiOutlineSun />}
</StyledToolElement>
<SearchInput />
<StyledToolElement
aria-label="save"
Expand All @@ -95,7 +94,10 @@ export const Tools: React.FC = () => {
visible={isDownloadVisible}
setVisible={setDownloadVisible}
/>
<Settings visible={settingsVisible} setVisible={setSettingsVisible} />
<SettingsModal
visible={settingsVisible}
setVisible={setSettingsVisible}
/>
</StyledTools>
);
};
1 change: 1 addition & 0 deletions src/containers/Modals/NodeModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const NodeModal = ({
},
2
)}
readOnly
/>
</Modal.Content>
<Modal.Controls setVisible={closeModal}>
Expand Down
Loading