Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

feat: add tooltip for open editor button and enhance BottomBar styling

AykutSarac86bfa3bb4ca5
diff --git a/apps/www/src/features/editor/BottomBar.tsx b/apps/www/src/features/editor/BottomBar.tsx
index 25de396e..78010ebd 100644
--- a/apps/www/src/features/editor/BottomBar.tsx
+++ b/apps/www/src/features/editor/BottomBar.tsx
@@ -1,10 +1,10 @@
import React from "react";
-import { Flex, Menu, Popover, Text } from "@mantine/core";
+import { Flex, Menu, Popover, Text, Tooltip } from "@mantine/core";
import styled from "styled-components";
import { event as gaEvent } from "nextjs-google-analytics";
-import { BiSolidDockLeft } from "react-icons/bi";
import { IoMdCheckmark } from "react-icons/io";
-import { MdArrowUpward } from "react-icons/md";
+import { LuPanelLeftClose } from "react-icons/lu";
+import { LuChevronDown } from "react-icons/lu";
import { VscCheck, VscError, VscRunAll, VscSync, VscSyncIgnored } from "react-icons/vsc";
import { formats } from "../../enums/file.enum";
import useConfig from "../../store/useConfig";
@@ -16,12 +16,11 @@ const StyledBottomBar = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
- border-top: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
+ padding: 4px 6px;
+ border-bottom: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT};
background: ${({ theme }) => theme.TOOLBAR_BG};
- max-height: 27px;
- height: 27px;
- z-index: 35;
- padding-right: 6px;
+ z-index: 2;
+ flex-shrink: 0;
@media screen and (max-width: 320px) {
display: none;
@@ -31,9 +30,7 @@ const StyledBottomBar = styled.div`
const StyledLeft = styled.div`
display: flex;
align-items: center;
- justify-content: left;
- gap: 4px;
- padding-left: 8px;
+ gap: 0;
@media screen and (max-width: 480px) {
display: none;
@@ -43,33 +40,42 @@ const StyledLeft = styled.div`
const StyledRight = styled.div`
display: flex;
align-items: center;
- justify-content: right;
- gap: 4px;
+ gap: 0;
`;
const StyledBottomBarItem = styled.button<{ $bg?: string }>`
display: flex;
align-items: center;
+ justify-content: center;
gap: 4px;
width: fit-content;
margin: 0;
- height: 28px;
- padding: 4px;
+ height: 26px;
+ padding: 2px 8px;
font-size: 12px;
- font-weight: 400;
+ font-weight: 500;
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
- background: ${({ $bg }) => $bg};
+ background: ${({ $bg }) => $bg || "transparent"};
+ border: none;
+ border-radius: 6px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
+ cursor: pointer;
+ transition:
+ background-color 120ms ease,
+ color 120ms ease;
&:hover:not(&:disabled) {
- background-image: linear-gradient(rgba(0, 0, 0, 0.1) 0 0);
+ background-color: ${({ theme }) =>
+ theme.BACKGROUND_SECONDARY === "#f2f3f5"
+ ? "rgba(0, 0, 0, 0.05)"
+ : "rgba(255, 255, 255, 0.05)"};
color: ${({ theme }) => theme.INTERACTIVE_HOVER};
}
&:disabled {
- opacity: 0.6;
+ opacity: 0.4;
cursor: default;
}
`;
@@ -97,9 +103,11 @@ export const BottomBar = () => {
return (
<StyledBottomBar>
<StyledLeft>
- <StyledBottomBarItem onClick={toggleEditor}>
- <BiSolidDockLeft />
- </StyledBottomBarItem>
+ <Tooltip label="Close editor" position="bottom" withArrow openDelay={750}>
+ <StyledBottomBarItem onClick={toggleEditor} aria-label="close editor">
+ <LuPanelLeftClose size={14} />
+ </StyledBottomBarItem>
+ </Tooltip>
<StyledBottomBarItem>
{error ? (
<Popover width="auto" shadow="md" position="top" withArrow>
@@ -144,8 +152,8 @@ export const BottomBar = () => {
<Menu.Target>
<StyledBottomBarItem>
<Flex align="center" gap={2}>
- <MdArrowUpward />
<Text size="xs">{currentFormat?.toUpperCase()}</Text>
+ <LuChevronDown size={12} />
</Flex>
</StyledBottomBarItem>
</Menu.Target>
@@ -153,7 +161,6 @@ export const BottomBar = () => {
{formats.map(format => (
<Menu.Item
key={format.value}
- fz={12}
onClick={() => setFormat(format.value)}
rightSection={currentFormat === format.value && <IoMdCheckmark />}
>
diff --git a/apps/www/src/pages/editor.tsx b/apps/www/src/pages/editor.tsx
index dc16df64..0755c38c 100644
--- a/apps/www/src/pages/editor.tsx
+++ b/apps/www/src/pages/editor.tsx
@@ -2,12 +2,14 @@ import { useEffect } from "react";
import dynamic from "next/dynamic";
import Head from "next/head";
import { useRouter } from "next/router";
-import { useMantineColorScheme } from "@mantine/core";
+import { Tooltip, useMantineColorScheme } from "@mantine/core";
import "@mantine/dropzone/styles.css";
import styled, { ThemeProvider } from "styled-components";
import { Allotment } from "allotment";
import "allotment/dist/style.css";
import { generateNextSeo } from "next-seo/pages";
+import { event as gaEvent } from "nextjs-google-analytics";
+import { LuChevronsRight } from "react-icons/lu";
import { SEO } from "../constants/seo";
import { darkTheme, lightTheme } from "../constants/theme";
import { BottomBar } from "../features/editor/BottomBar";
@@ -39,6 +41,7 @@ export const StyledPageWrapper = styled.div`
`;
export const StyledEditorWrapper = styled.div`
+ position: relative;
width: 100%;
height: 100%;
overflow: hidden;
@@ -61,6 +64,33 @@ const StyledTextEditor = styled.div`
height: 100%;
`;
+const StyledOpenEditorButton = styled.button<{ $dark?: boolean }>`
+ position: absolute;
+ left: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ z-index: 5;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 120px;
+ padding: 0;
+ border: none;
+ border-radius: 0 8px 8px 0;
+ background: ${({ $dark }) => ($dark ? "#e8e8e8" : "#1c1c1e")};
+ color: ${({ $dark }) => ($dark ? "#1c1c1e" : "#ffffff")};
+ cursor: pointer;
+ transition:
+ background-color 150ms ease,
+ width 150ms ease;
+
+ &:hover {
+ width: 32px;
+ background: ${({ $dark }) => ($dark ? "#ffffff" : "#333")};
+ }
+`;
+
const TextEditor = dynamic(() => import("../features/editor/TextEditor"), {
ssr: false,
});
@@ -75,6 +105,12 @@ const EditorPage = () => {
const checkEditorSession = useFile(state => state.checkEditorSession);
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
const fullscreen = useGraph(state => state.fullscreen);
+ const toggleFullscreen = useGraph(state => state.toggleFullscreen);
+
+ const openEditor = () => {
+ toggleFullscreen(false);
+ gaEvent("toggle_fullscreen");
+ };
useEffect(() => {
if (isReady) checkEditorSession(query?.json);
@@ -111,14 +147,26 @@ const EditorPage = () => {
visible={!fullscreen}
>
<StyledTextEditor>
- <TextEditor />
<BottomBar />
+ <TextEditor />
</StyledTextEditor>
</Allotment.Pane>
<Allotment.Pane minSize={0}>
<LiveEditor />
</Allotment.Pane>
</StyledEditor>
+ {fullscreen && (
+ <Tooltip label="Open editor" position="right" withArrow openDelay={750}>
+ <StyledOpenEditorButton
+ $dark={darkmodeEnabled}
+ onClick={openEditor}
+ aria-label="open editor"
+ type="button"
+ >
+ <LuChevronsRight size={16} />
+ </StyledOpenEditorButton>
+ </Tooltip>
+ )}
<FullscreenDropzone />
</StyledEditorWrapper>
</StyledPageWrapper>