-
{
- setItemColorStatus(false);
- }}
- />
-
-
- ) : null}
+ ) : null}
+ >
+ )}
>
);
}
diff --git a/src/components/main-app/sidebar-wrapper/colors-output.js b/src/components/main-app/sidebar-wrapper/colors-output.js
new file mode 100644
index 0000000..e986e1b
--- /dev/null
+++ b/src/components/main-app/sidebar-wrapper/colors-output.js
@@ -0,0 +1,48 @@
+import React, { useState } from 'react';
+import JSONPretty from 'react-json-pretty';
+import { CopyToClipboard } from 'react-copy-to-clipboard';
+import * as JSONPrettyMon from 'react-json-pretty/dist/acai';
+import { Collapse } from 'utils';
+
+export default function ColorsOutput({ text, setColorFormat }) {
+ const [toggleCollapse, setToggleCollapse] = useState(true);
+
+ const handleColorFormatChange = event => {
+ setColorFormat(event.target.value);
+ };
+
+ return (
+ <>
+
+ {toggleCollapse ? (
+ true
+ ) : (
+ <>
+
+
+
+
+
+
+
+ >
+ )}
+ >
+ );
+}
diff --git a/src/components/main-app/sidebar-wrapper/index.js b/src/components/main-app/sidebar-wrapper/index.js
index 85523ca..7ef9dc0 100644
--- a/src/components/main-app/sidebar-wrapper/index.js
+++ b/src/components/main-app/sidebar-wrapper/index.js
@@ -2,3 +2,4 @@ export { default as TilesInput } from './tiles-input';
export { default as ShapeInput } from './shape-input';
export { default as ColorsInput } from './colors-input';
export { default as AlphaInput } from './alpha-input';
+export { default as ColorsOutput } from './colors-output';
diff --git a/src/components/main-app/sidebar-wrapper/shape-input.js b/src/components/main-app/sidebar-wrapper/shape-input.js
index 348a43b..75550be 100644
--- a/src/components/main-app/sidebar-wrapper/shape-input.js
+++ b/src/components/main-app/sidebar-wrapper/shape-input.js
@@ -1,20 +1,30 @@
-import React from 'react';
+import React, { useState } from 'react';
import { URL_SHAPE, URL_UPDATE_PUSH } from 'config';
import { StringParam, useQueryParam } from 'use-query-params';
+import { Collapse } from 'utils';
export default function ShapeInput() {
const [shape, onChangeShape] = useQueryParam(URL_SHAPE, StringParam);
+ const [toggleCollapse, setToggleCollapse] = useState(true);
return (
<>
-
Shape URL (Only Topo JSON)
-
onChangeShape(e.target.value, URL_UPDATE_PUSH)}
+
+ {toggleCollapse ? (
+ true
+ ) : (
+
onChangeShape(e.target.value, URL_UPDATE_PUSH)}
+ />
+ )}
>
);
}
diff --git a/src/components/main-app/sidebar-wrapper/tiles-input.js b/src/components/main-app/sidebar-wrapper/tiles-input.js
index 9da0d05..5ce3a33 100644
--- a/src/components/main-app/sidebar-wrapper/tiles-input.js
+++ b/src/components/main-app/sidebar-wrapper/tiles-input.js
@@ -1,20 +1,30 @@
-import React from 'react';
+import React, { useState } from 'react';
import { URL_TILES, URL_UPDATE_PUSH } from 'config';
import { StringParam, useQueryParam } from 'use-query-params';
+import { Collapse } from 'utils';
export default function TilesInput() {
const [tiles, onChangeTiles] = useQueryParam(URL_TILES, StringParam);
+ const [toggleCollapse, setToggleCollapse] = useState(true);
return (
<>
-
Tiles URL (XYZ Format)
-
onChangeTiles(e.target.value, URL_UPDATE_PUSH)}
+
+ {toggleCollapse ? (
+ true
+ ) : (
+
onChangeTiles(e.target.value, URL_UPDATE_PUSH)}
+ />
+ )}
>
);
}
diff --git a/src/components/main-app/sidebar.js b/src/components/main-app/sidebar.js
index 681493e..5b5beec 100644
--- a/src/components/main-app/sidebar.js
+++ b/src/components/main-app/sidebar.js
@@ -6,15 +6,12 @@ import {
TilesInput,
ShapeInput,
ColorsInput,
+ ColorsOutput,
AlphaInput,
} from './sidebar-wrapper';
import { ThemeProvider } from 'styled-components';
import { GlobalStyles } from './themes/global-styles';
import { lightTheme, darkTheme } from './themes/themes';
-import '../../sass/index.sass';
-import JSONPretty from 'react-json-pretty';
-import { CopyToClipboard } from 'react-copy-to-clipboard';
-import * as JSONPrettyMon from 'react-json-pretty/dist/acai';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faWindowMinimize } from '@fortawesome/free-solid-svg-icons';
@@ -31,17 +28,16 @@ export default function Sidebar({ setShowSidebar, setTheme, theme }) {
);
}, [colors, opacity, colorFormat]);
- const handleColorFormatChange = event => {
- setColorFormat(event.target.value);
- };
-
return (
-
diff --git a/src/components/main-app/themes/global-styles.js b/src/components/main-app/themes/global-styles.js
index 3acc370..e5fb953 100644
--- a/src/components/main-app/themes/global-styles.js
+++ b/src/components/main-app/themes/global-styles.js
@@ -7,9 +7,13 @@ export const GlobalStyles = createGlobalStyle`
transition: all 0.5s linear;
}
+ .sidebar::-webkit-scrollbar-thumb{
+ background-color: ${({ theme }) => theme.btnBgColor};
+ }
+
#json-pretty > pre::-webkit-scrollbar-thumb{
background-color: ${({ theme }) => theme.scroll};
- }
+ }
#json-pretty > pre{
background-color: ${({ theme }) => theme.background} !important;
@@ -33,7 +37,7 @@ export const GlobalStyles = createGlobalStyle`
color: ${({ theme }) => theme.text};
}
- .fa.iconButton, #color-format, .copy-btn{
+ .fa.iconButton, #color-format, .copy-btn, .minimize-btn{
background-color: ${({ theme }) => theme.btnBgColor};
color: ${({ theme }) => theme.btnColor};
}
diff --git a/src/sass/_app.sass b/src/sass/_app.sass
index 988356b..9ec3ca3 100644
--- a/src/sass/_app.sass
+++ b/src/sass/_app.sass
@@ -22,7 +22,14 @@
margin-bottom: 10px
span
font-weight: 300
-
+
+.sidebar::-webkit-scrollbar
+ width: 9px
+
+.sidebar::-webkit-scrollbar-thumb
+ border-radius: 10px
+ -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1)
+
.theme-toggle
.switch
display: flex
@@ -159,6 +166,9 @@
border-radius: 10px
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1)
+.color-output-btns
+ margin-top: 0.6rem
+
#color-format
border: none
border-radius: 6px
@@ -190,6 +200,31 @@
align-items: center
margin-top: 2%
+.collapsible-title
+ cursor: pointer
+
+.minimize-btn
+ border: none
+ border-radius: 2px
+ position: absolute
+ top: 0.5rem
+ left: 0.5rem
+ text-align: center
+ line-height: 0.4rem
+
+.minimize-btn:active
+ opacity: 0.5
+
+.max-btn-container
+ z-index: 1
+ top: 1rem
+ left: 1rem
+
+.maximize-btn
+ border: none
+ height: 1.5rem
+ width: 3rem
+
@media only screen and (max-width: 1440px)
.sidebar
width: 400px
diff --git a/src/utils/collapsible.js b/src/utils/collapsible.js
index e69de29..677c00e 100644
--- a/src/utils/collapsible.js
+++ b/src/utils/collapsible.js
@@ -0,0 +1,17 @@
+import React from 'react';
+
+export default function Collapse({ title, toggleCollapse, setToggleCollapse }) {
+ return (
+ <>
+
{
+ setToggleCollapse(!toggleCollapse);
+ console.log(toggleCollapse);
+ }}
+ >
+ {title}
+
+ >
+ );
+}
diff --git a/src/utils/index.js b/src/utils/index.js
index 3cfb176..7a65ef5 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -5,3 +5,4 @@ export { default as copyColor } from './copy-color';
export { setMap, handleLocationButton } from './current-location';
export { default as addSearchControl } from './add-search-control';
export { default as themeToggler } from './theme-toggler';
+export { default as Collapse } from './collapsible';
From 6ede4a867ccfc55c50c177c747becbcdba81218e Mon Sep 17 00:00:00 2001
From: Hanumanth P <48819979+vildar@users.noreply.github.com>
Date: Thu, 21 Jan 2021 19:45:16 +0530
Subject: [PATCH 4/4] hiding sidebar instead of unmounting [build deploy]
---
src/components/main-app/index.js | 16 +++-------------
src/components/main-app/ol-init.js | 6 ++++--
src/components/main-app/sidebar.js | 6 ++++--
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/src/components/main-app/index.js b/src/components/main-app/index.js
index 2e4c5d1..c2718ba 100644
--- a/src/components/main-app/index.js
+++ b/src/components/main-app/index.js
@@ -1,22 +1,12 @@
-import React, { useState } from 'react';
+import React from 'react';
import OlInit from './ol-init';
import Sidebar from './sidebar';
export default function MainApp({ setTheme, theme }) {
- const [showSidebar, setShowSidebar] = useState(false);
-
return (
<>
-
- {showSidebar ? (
-
- ) : (
- false
- )}
+
+
>
);
}
diff --git a/src/components/main-app/ol-init.js b/src/components/main-app/ol-init.js
index a472070..1b2643c 100644
--- a/src/components/main-app/ol-init.js
+++ b/src/components/main-app/ol-init.js
@@ -9,7 +9,7 @@ import { faCompass, faBars } from '@fortawesome/free-solid-svg-icons';
import { handleLocationButton } from 'utils';
import { setSource } from '../../api/map-data';
-export default function OlInit({ setShowSidebar }) {
+export default function OlInit() {
const [shape] = useQueryParam(URL_SHAPE, StringParam);
const [tiles] = useQueryParam(URL_TILES, StringParam);
const [colors] = useQueryParam(URL_COLORS, StringParam);
@@ -59,7 +59,9 @@ export default function OlInit({ setShowSidebar }) {
setShowSidebar(true)}
+ onClick={() => {
+ document.querySelector('.sidebar').style.display = 'block';
+ }}
>
diff --git a/src/components/main-app/sidebar.js b/src/components/main-app/sidebar.js
index 5b5beec..2cecab1 100644
--- a/src/components/main-app/sidebar.js
+++ b/src/components/main-app/sidebar.js
@@ -15,7 +15,7 @@ import { lightTheme, darkTheme } from './themes/themes';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faWindowMinimize } from '@fortawesome/free-solid-svg-icons';
-export default function Sidebar({ setShowSidebar, setTheme, theme }) {
+export default function Sidebar({ setTheme, theme }) {
const [colors] = useQueryParam(URL_COLORS, StringParam);
const [opacity] = useQueryParam(URL_OPACITY, StringParam);
const [text, setText] = useState('');
@@ -35,7 +35,9 @@ export default function Sidebar({ setShowSidebar, setTheme, theme }) {
setShowSidebar(false)}
+ onClick={() => {
+ document.querySelector('.sidebar').style.display = 'none';
+ }}
>