Skip to content

Commit

Permalink
Merge pull request #41 from unelmacoin/up-58-expand-and-shrink-on-dou…
Browse files Browse the repository at this point in the history
…ble-click

up-58 expand and shrink on double click added
  • Loading branch information
unellma authored Sep 28, 2023
2 parents b064375 + f895bcb commit 97409be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/renderer/components/Layout/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
90deg,
var(--root-background) 0%,
var(--root-background-grad-1) 52%,
var( --root-background-grad-2) 100%
var(--root-background-grad-2) 100%
);
border-radius: 7px;
padding: 40px 10px 10px;
-webkit-app-region: drag;
-webkit-user-select: none;
user-select: none;
transition: ease all 2s;
}
44 changes: 28 additions & 16 deletions src/renderer/components/TopBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ import React, { useEffect, useState } from "react";
import { MdOutlineMinimize } from "react-icons/md";
import { FiMinimize2, FiMaximize2 } from "react-icons/fi";
import { IoClose } from "react-icons/io5";
import { CLOSE_WINDOW, IS_MAXIMIZED, MAXIMIZE, MINIMIZE, UN_MAXIMIZE } from "../../constants/global/channels";
import {
CLOSE_WINDOW,
IS_MAXIMIZED,
MAXIMIZE,
MINIMIZE,
UN_MAXIMIZE,
} from "../../constants/global/channels";

const TopBar = ({menu , setMenu}) => {
const TopBar = ({ menu, setMenu }) => {
const [maximize, setMaximize] = useState(true);
const handleMaximize = () => {
window.api.send(MAXIMIZE, window.id);
setMaximize(true);
setMaximize(true);
};
const handleUnMaximize = () => {
window.api.send(UN_MAXIMIZE, window.id);
setMaximize(false);
setMaximize(false);
};
const handleMinimize = () => {
window.api.send(MINIMIZE, window.id);

};
const handleClose = () => {
window.api.send(CLOSE_WINDOW, window.id);
Expand All @@ -26,21 +31,28 @@ const TopBar = ({menu , setMenu}) => {
setMaximize(isMaximized);
});
}, [maximize]);
const handle_CloseThreeButtonMenu =() =>{
if (menu === true) setMenu(false)
}
const handle_CloseThreeButtonMenu = () => {
if (menu === true) setMenu(false);
};

return (
<div className="top-bar" onClick={handle_CloseThreeButtonMenu}>
<div
className="top-bar"
onClick={handle_CloseThreeButtonMenu}
onDoubleClick={maximize ? handleUnMaximize : handleMaximize}
>
<button id="window-controls-minimize" onClick={handleMinimize}>
<MdOutlineMinimize fontSize="8px" />
</button>
{!maximize ?<button id="window-controls-maximize" onClick={handleMaximize}>
<FiMaximize2 fontSize="8px" />
</button>
:<button id="window-controls-unmaximize" onClick={handleUnMaximize}>
<FiMinimize2 fontSize="8px" />
</button>}
{!maximize ? (
<button id="window-controls-maximize" onClick={handleMaximize}>
<FiMaximize2 fontSize="8px" />
</button>
) : (
<button id="window-controls-unmaximize" onClick={handleUnMaximize}>
<FiMinimize2 fontSize="8px" />
</button>
)}
<button id="window-controls-close" onClick={handleClose}>
<IoClose fontSize="8px" />
</button>
Expand Down

0 comments on commit 97409be

Please sign in to comment.