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

Improve sidebar design #23

Merged
merged 3 commits into from
Jul 21, 2023
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
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SpinerLoader } from "./components/SpinerLoader";

function App() {
return (
<div className="flex h-screen">
<div className="flex h-screen font-sans">
<div className="w-64 bg-gray-2000" aria-label="Sidebar">
<Sidebar />
</div>
Expand Down
16 changes: 5 additions & 11 deletions src/components/ClassObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MainContext } from "../contexts/MainContext";

export const ClassObj = ({ classProps }) => {
const { activeClass, dispatchSetActiveClass } = useContext(MainContext);
const isActive = activeClass && activeClass.name === classProps.name;

const setActiveClass = (class_) => {
dispatchSetActiveClass({
Expand All @@ -15,17 +16,10 @@ export const ClassObj = ({ classProps }) => {

return (
<li
className={`subMenuHeader hoverAnimation`}
style={{
background: `${
activeClass && activeClass.name === classProps.name
? activeClass.color
: ""
}`,
}}
onClick={() => {
setActiveClass(classProps);
}}
className={`subMenuHeader hoverAnimation ${
isActive ? "bg-slate-300" : "bg-white"
}`}
onClick={() => setActiveClass(classProps)}
>
<span className="text-xs block float-left">
<BsSquareFill style={{ color: classProps.color }}></BsSquareFill>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ export const Badge = ({ activeClass }) => {
export const Classes = () => {
const { activeProject, activeClass } = useContext(MainContext);
const [classes, setClasses] = useState([]);
const [openMenu, setOpenMenu] = useState(true);
const [isOpen, setIsOpen] = useState(true);

useEffect(() => {
const classLayers = getClassLayers(activeProject);
setClasses(classLayers);
setOpenMenu(true);
setIsOpen(true);
}, [activeProject]);
return (
<MenuTemplate
title={"Classes"}
badge={<Badge activeClass={activeClass} />}
title="Classes"
badge={isOpen ? false : <Badge activeClass={activeClass} />}
icon={<BsListUl />}
openMenu={openMenu}
setOpenMenu={setOpenMenu}
openMenu={isOpen}
setOpenMenu={setIsOpen}
>
<ul className="pt-1">
{classes.map((classProps, index) => (
Expand Down
10 changes: 3 additions & 7 deletions src/components/EncodeCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
} = useContext(MainContext);

const [samApiStatus, setSamApiStatus] = useState(null);

const [notificationShown, setNotificationShown] = useState(false);
const reset = () => {
setSpinnerLoading(false);
setSamApiStatus(null);
};

const [notificationShown, setNotificationShown] = useState(false);

// Request segment-anything-services
const requestSAM = async (requestProps, isEncode) => {
setSpinnerLoading(true);
Expand Down Expand Up @@ -137,7 +135,7 @@
);
}
}
}, [pointsSelector]);

Check warning on line 138 in src/components/EncodeCanvas.js

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'activeEncodeImageItem', 'map', 'requestSAM', and 'showNotification'. Either include them or remove the dependency array

Check warning on line 138 in src/components/EncodeCanvas.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'activeEncodeImageItem', 'map', 'requestSAM', and 'showNotification'. Either include them or remove the dependency array

const requestPrediction = async () => {
const requestProps = getPropertiesRequest(map, pointsSelector);
Expand All @@ -147,10 +145,8 @@
return (
<>
<button
className="custom_button"
onClick={() => {
requestPrediction();
}}
className="custom_button bg-orange-ds text-white hover:bg-orange-ds hover:bg-opacity-80"
onClick={() => requestPrediction()}
disabled={samApiStatus || false}
>
New SAM AOI
Expand Down
11 changes: 4 additions & 7 deletions src/components/EncodeExpImp.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,23 @@ export const EncodeExpImp = () => {

return (
<div
className="relative inline-block"
className="relative inline-block text-right"
onMouseLeave={() => setIsOpen(false)} // Add this line
>
{encodeItems.length === 0 ? (
<EncodeImport />
) : (
<button
className="custom_button px-1 inline-flex"
className="custom_button text-center pl-3"
onClick={toggleDropdown}
>
Export AOIs
<BsChevronDown
size="1.5em"
className="w-6 h-3 ml-2 mt-[3px] text-red"
/>
<BsChevronDown size="1.5em" className="inline w-6 h-3 text-red" />
</button>
)}

{isOpen && (
<div className="absolute text-xs right-0 left-0 mt-0 bg-white border border-gray-200 rounded shadow-lg">
<div className="absolute text-left text-xs right-0 left-0 mt-0 bg-white border border-gray-200 rounded shadow-lg">
<ul>
<li
className="py-2 custom_button border-none px-1"
Expand Down
20 changes: 10 additions & 10 deletions src/components/EncodeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@

return (
<div className=" relative inline-flex justify-center items-center pr-1 pl-1 ml-1 text-xs text-slate-900 font-medium rounded-full cursor-pointer">
<img

Check warning on line 60 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / test

Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop

Check warning on line 60 in src/components/EncodeItem.js

View workflow job for this annotation

GitHub Actions / lint

Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop
src={encodeItem.canvas}
alt={`Encode Image`}
alt={`Encoded Image for ${encodeItem.canvas}`}
className={`w-full h-full object-cover opacity-100 transition-opacity duration-500 ease-in-out transform hover:opacity-90 mb-2
${
activeEncodeImageItem && encodeItem.id === activeEncodeImageItem.id
? "border border-green-400 border-2"
: "border border-gray-300 border-2"
? "border border-orange-ds border-2"
: "border border-orange-ds border-opacity-50 border-2"
}`}
style={{
width: "100px",
Expand All @@ -73,21 +73,21 @@
onClick={() => zoomTo(encodeItem)}
/>
<div
className={`absolute w-22 top-1 mr-1 ml-1 pl-1 pr-1 text-xxs bg-${
className={`absolute w100 top-1 mr-1 ml-1 pl-1 pr-1 text-xxs ${
activeEncodeImageItem && activeEncodeImageItem.id === encodeItem.id
? "green"
: "yellow"
}-500 rounded opacity-80 backdrop-filter backdrop-blur-md flex items-center space-x-2`}
? "bg-orange-ds"
: "bg-grey"
} rounded opacity-80 backdrop-filter backdrop-blur-md flex items-center space-x-2`}
>
<p className="font-bold text-gray">
<span className="font-bold text-white">
{activeEncodeImageItem && activeEncodeImageItem.id === encodeItem.id
? "Active"
: `[${encodeItem.image_shape[1]},${
encodeItem.image_shape[0]
}] - z${Math.round(encodeItem.zoom)} `}
</p>
</span>
</div>
<div className="absolute bottom-1 right-1 p-1 text-xs bg-red-500 rounded opacity-90 backdrop-filter backdrop-blur-md flex items-center space-x-2">
<div className="absolute bottom-1 right-1 p-1 text-xs bg-orange-ds rounded opacity-90 backdrop-filter backdrop-blur-md flex items-center space-x-2">
<BsTrash
onClick={() => handleRemoveEncodeItem(encodeItem)}
className="text-white fill-current w-3 h-3 cursor-pointer"
Expand Down
8 changes: 5 additions & 3 deletions src/components/EncodeItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { openDatabase, storeEncodeItems } from "../store/indexedDB";
import { fetchListURLS } from "../utils/requests";
import { getFileNameFromURL } from "../utils/utils";
import { BsLayers } from "react-icons/bs";
import { BsLayoutWtf } from "react-icons/bs";

export const Badge = () => {
const { activeEncodeImageItem } = useContext(MainContext);
Expand Down Expand Up @@ -64,13 +64,13 @@
};
fetchData();
setOpenMenu(true);
}, [activeProject]);

Check warning on line 67 in src/components/EncodeItems.js

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has a missing dependency: 'dispatchEncodeItems'. Either include it or remove the dependency array

Check warning on line 67 in src/components/EncodeItems.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'dispatchEncodeItems'. Either include it or remove the dependency array

return (
<MenuTemplate
title={"SAM AOIs"}
badge={<Badge />}
icon={<BsLayers />}
icon={<BsLayoutWtf />}
openMenu={openMenu}
setOpenMenu={setOpenMenu}
>
Expand All @@ -80,7 +80,9 @@
<EncodeItem key={index} encodeItem={encodeItem} />
))}
{!encodeItems?.length && (
<p className="text-sm text-center text-slate-500 my-1">No AOI is available yet</p>
<p className="text-sm text-center text-slate-500 my-1">
No AOI is available yet
</p>
)}
</div>
<div className="grid grid-cols-2 gap-2">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useContext } from "react";

Check warning on line 1 in src/components/Header.js

View workflow job for this annotation

GitHub Actions / test

'useState' is defined but never used

Check warning on line 1 in src/components/Header.js

View workflow job for this annotation

GitHub Actions / lint

'useState' is defined but never used
import { BsInfoCircleFill } from "react-icons/bs";

import { MainContext } from "./../contexts/MainContext";
Expand All @@ -7,15 +7,15 @@
export const Header = () => {
const { setDisplayModal } = useContext(MainContext);
return (
<div className="flex items-center bg-gray-100 pt-2 pb-2 pl-3">
<div className="flex items-center pt-2 pb-2 pl-3">
<a href="https://devseed.com/" target="_blank" rel="noopener noreferrer">
<img
src={DevSeedLogo}
alt="Development Seed logo"
className="text-4xl cursor-pointer block float-left mr-2 h-9"
/>
</a>
<span className="self-center text-xl text-slate-900 font-semibold whitespace-nowrap">
<span className="self-center text-xl text-slate-900 font-base font-bold whitespace-nowrap">
DS-Annotate
</span>
<div className="self-center text-lg pt-1 text-slate-400 ml-3 cursor-pointer">
Expand Down
7 changes: 3 additions & 4 deletions src/components/Items.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { MenuTemplate } from "./MenuTemplate";
import React from "react";
import { ItemsDataActions } from "./ItemsDataActions";
import { BsLayoutWtf } from "react-icons/bs";
import { BsBoundingBoxCircles } from "react-icons/bs";

export const Items = () => {
const { items, dispatchSetItems, activeProject } = useContext(MainContext);
Expand Down Expand Up @@ -42,7 +42,7 @@
};
fetchData();
setOpenMenu(true);
}, [activeProject]);

Check warning on line 45 in src/components/Items.js

View workflow job for this annotation

GitHub Actions / test

React Hook useLayoutEffect has a missing dependency: 'dispatchSetItems'. Either include it or remove the dependency array

Check warning on line 45 in src/components/Items.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useLayoutEffect has a missing dependency: 'dispatchSetItems'. Either include it or remove the dependency array

useEffect(() => {
if (scrollDivRef.current) {
Expand All @@ -52,9 +52,8 @@
}, [items]);
return (
<MenuTemplate
title={"Drawn items"}
badge={""}
icon={<BsLayoutWtf />}
title={"Drawn Items"}
icon={<BsBoundingBoxCircles />}
openMenu={openMenu}
setOpenMenu={setOpenMenu}
>
Expand Down
18 changes: 12 additions & 6 deletions src/components/MenuExpData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MainContext } from "../contexts/MainContext";
import { downloadInJOSM } from "../utils/requests";
import { downloadGeojsonFile } from "../utils/utils";
import { olFeatures2geojson } from "../utils/convert";
import { BsFileArrowDown, BsFileArrowUp } from "react-icons/bs";
import { BsDownload, BsUpload } from "react-icons/bs";

export const MenuExpData = () => {
const { items, activeProject } = useContext(MainContext);
Expand All @@ -21,14 +21,20 @@ export const MenuExpData = () => {

return (
<div className="grid grid-cols-2 gap-2 mt-6">
<button className="custom_button" onClick={() => downloadGeojson()}>
<div style={{ display: "flex", alignItems: "center" }}>
<BsFileArrowDown style={{ marginRight: "5px" }} /> GeoJSON
<button
className="custom_button"
onClick={() => downloadGeojson()}
title="Download data as GeoJSON"
>
<div className="text-center">
<BsDownload className="mr-2 inline" />
GeoJSON
</div>
</button>
<button className="custom_button" onClick={() => josm()}>
<div style={{ display: "flex", alignItems: "center" }}>
<BsFileArrowUp style={{ marginRight: "5px" }} /> JOSM
<div className="text-center">
<BsUpload className="mr-2 inline" />
JOSM
</div>
</button>
</div>
Expand Down
10 changes: 2 additions & 8 deletions src/components/MenuTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,15 @@ export const MenuTemplate = ({
}) => {
return (
<>
<div
className="menuHeader"
onClick={() => {
setOpenMenu(!openMenu);
}}
>
<div className="menuHeader" onClick={() => setOpenMenu(!openMenu)}>
{icon}
<span className="text-sm text-base font-small flex-1 duration-200 false">
<span className="text-sm font-semibold flex-1 duration-200 false text-ellipsis truncate">
{title}
</span>
{badge}
{openMenu ? <BsChevronUp /> : <BsChevronDown />}
</div>
{openMenu && <div>{children}</div>}
{openMenu && <div className="border-t border-gray-200 my-1"></div>}
</>
);
};
10 changes: 5 additions & 5 deletions src/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Modal = () => {
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
{/*header*/}
<div className="flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t">
<h3 className="text-3xl font-semibold">DS Annotate Tool</h3>
<h3 className="text-3xl font-semibold">DS-Annotate</h3>

<BsXLg
className="p-1 cursor-pointer ml-auto border-0 text-black-900 float-right text-3xl leading-none font-semibold outline-none focus:outline-none"
Expand All @@ -32,7 +32,7 @@ export const Modal = () => {
DS-Annotate empowers users to draw intricate polygons over
aerial imagery using the{" "}
<a
className="text-red-500"
className="text-orange-ds"
href="https://github.com/facebookresearch/segment-anything"
target="_blank"
rel="noreferrer"
Expand All @@ -41,7 +41,7 @@ export const Modal = () => {
</a>
and the{" "}
<a
className="text-red-500"
className="text-orange-ds"
href="https://github.com/Tamersoul/ol-magic-wand"
target="_blank"
rel="noreferrer"
Expand Down Expand Up @@ -101,7 +101,7 @@ export const Modal = () => {

<p className="my-4 text-md">
<a
className="text-red-500"
className="text-orange-ds"
href="https://github.com/developmentseed/ds-annotate/issues"
target="_blank"
rel="noreferrer"
Expand All @@ -113,7 +113,7 @@ export const Modal = () => {
</div>
<div className="flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b">
<button
className="text-red-500 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
className="text-orange-ds background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button"
onClick={() => modalStatus("none")}
>
Expand Down
14 changes: 9 additions & 5 deletions src/components/Projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
dispatchActiveEncodeImageItem,
} = useContext(MainContext);
const [projectName, setProjectName] = useState("Projects");
const [openMenu, setOpenMenu] = useState(false);
const [isOpen, setIsOpen] = useState(false);

const setProject = useCallback(
(project) => {
Expand All @@ -40,7 +40,7 @@
payload: null,
});
},
[dispatchSetActiveClass, dispatchSetActiveProject]

Check warning on line 43 in src/components/Projects.js

View workflow job for this annotation

GitHub Actions / test

React Hook useCallback has a missing dependency: 'dispatchActiveEncodeImageItem'. Either include it or remove the dependency array

Check warning on line 43 in src/components/Projects.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has a missing dependency: 'dispatchActiveEncodeImageItem'. Either include it or remove the dependency array
);

// Load project from query
Expand All @@ -63,25 +63,29 @@
if (projectFeature) {
setProject(projectFeature);
}
}, [searchParams]);

Check warning on line 66 in src/components/Projects.js

View workflow job for this annotation

GitHub Actions / test

React Hook useEffect has missing dependencies: 'projects.features' and 'setProject'. Either include them or remove the dependency array

Check warning on line 66 in src/components/Projects.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'projects.features' and 'setProject'. Either include them or remove the dependency array

return (
<MenuTemplate
title={projectName}
badge={""}
icon={<BsFolder2 />}
openMenu={openMenu}
setOpenMenu={setOpenMenu}
openMenu={isOpen}
setOpenMenu={setIsOpen}
>
<div>
<ul className="pt-1">
{projects.features.map((feature) => (
<Link
key={feature.properties.slug}
className="subMenuHeader hoverAnimation"
className={`subMenuHeader hoverAnimation ${
projectName === feature.properties.name
? "bg-slate-300"
: "bg-white"
}`}
onClick={() => {
setProject(feature);
setOpenMenu(false);
setIsOpen(false);
}}
to={`?project=${feature.properties.slug}`}
>
Expand Down
Loading
Loading