Skip to content

Commit

Permalink
Merge branch 'features/EPMUII-4812-respons-settingl-component' into d…
Browse files Browse the repository at this point in the history
…evelop

# Conflicts:
#	src/ui/Button/Button.module.css
#	src/ui/Layout/Container.module.css
#	src/ui/Main.jsx
#	src/ui/Main.module.css
#	src/ui/OpenFile/UiOpenMenu.module.css
#	src/ui/Tooltip/Tooltip.module.css
  • Loading branch information
katrysja committed Sep 22, 2023
2 parents 20522a1 + 309926d commit d9c2d80
Show file tree
Hide file tree
Showing 11 changed files with 432 additions and 22 deletions.
3 changes: 3 additions & 0 deletions public/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions src/ui/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ button:hover,
@media screen and (min-width: 768px) {
.reset {
display: flex;
justify-content: end;
justify-content: flex-end;
}

}
Expand Down Expand Up @@ -217,6 +217,3 @@ button:hover,
.button.accent.active svg {
fill: var(--black);
}

}

6 changes: 5 additions & 1 deletion src/ui/Form/Slider.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

.slider {
flex: 1;
flex: 1;
}

.caption {
Expand All @@ -17,3 +17,7 @@
line-height: 20px;
color: var(--white);
}

@media screen and(min-width: 768px) {

}
2 changes: 1 addition & 1 deletion src/ui/Layout/Container.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

.vertical {
flex-direction: column;
width: 50px;

}

.vertical:not(:first-child) {
Expand Down
24 changes: 21 additions & 3 deletions src/ui/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { LeftToolbar } from './LeftToolbar/LeftToolbar';
import { useDispatch, useSelector } from 'react-redux';
import { TopToolbar } from './TopToolbar/TopToolbar';
import { UiAbout } from './Header/UiAbout';
import { MobileSettings } from './MobileSettings/MobileSettings';
import StartScreen from './StartScreen/StartScreen';
import css from './Main.module.css';
import cx from 'classnames';
Expand All @@ -40,8 +41,20 @@ export const Main = () => {
const [strAlertTitle, setStrAlertTitle] = useState('');
const [strAlertText, setStrAlertText] = useState('');
const [isFullMode, setIsFullMode] = useState(false);
const [isMobile, setIsMobile] = useState(window.innerWidth < 1024);
const appRef = useRef();

useEffect(() => {
function handleResize() {
setIsMobile(window.innerWidth < 1024);
}

window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
}, []);
const [, drop] = useDrop(
() => ({
accept: DnDItemTypes.SETTINGS,
Expand Down Expand Up @@ -95,7 +108,6 @@ export const Main = () => {
const onFullScreenChange = () => {
setIsFullMode(!isFullMode);
};

useEffect(() => {
const strSearch = window.location.search;
if (strSearch.length > 0) {
Expand Down Expand Up @@ -141,7 +153,7 @@ export const Main = () => {
return () => {
document.removeEventListener('fullscreenchange', onFullScreenChange);
};
}, [isFullMode]);
}, [isFullMode, isMobile]);

return (
<AppContextProvider>
Expand Down Expand Up @@ -175,7 +187,7 @@ export const Main = () => {
) : (
<StartScreen />
)}
{isReady && (
{isReady && !isMobile && (
<div className={cx(isFullMode && css.fullscreen)}>
<div className={css.left}>
<LeftToolbar />
Expand All @@ -186,6 +198,12 @@ export const Main = () => {
<RightPanel />
</div>
)}
{isReady && isMobile && (
<div className={cx(isFullMode && css.fullscreen)}>
<div className={css.center}>{viewMode === ModeView.VIEW_2D ? <Graphics2d /> : <Graphics3d />}</div>
<MobileSettings />
</div>
)}
{arrErrors.length > 0 && <UiErrConsole />}
{showModalText && (
<UiModalText stateVis={showModalText} onHide={onHideModalText.bind(this)} onShow={onShowModalText.bind(this)} />
Expand Down
84 changes: 71 additions & 13 deletions src/ui/Main.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
}

.header__logo {
margin-right: 25px;
display: none;
}

.header__panels {
display: none;
}
Expand All @@ -25,14 +26,14 @@
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: row-reverse;
z-index: 1000;
width: 100vw;
right: 0;
height: 50px;
padding: 1rem;
background-color: var(--beige);
align-items: center;
z-index: 1000;
}

.header__right > button {
Expand All @@ -57,11 +58,18 @@
}

.bottleft {
display: none;
display: block;
}

.left {
display: none;
display: block;
width: 100px;
height: 50px;
position: absolute;
right: 0;
top:50%;
z-index: 10;

}

.center div {
Expand All @@ -70,9 +78,9 @@
left: 0;
right: 0;
bottom: 0;
z-index: 10;

z-index: 1;
}

.settings {
display: none;
}
Expand All @@ -87,14 +95,17 @@
}

.header__logo {
display: block;
margin-right: 25px;
margin-top: 1rem;
}

.header__panels {
display: flex;
flex-direction: column;
width: 25rem;
}

.fullscreen .header__panels {
position: absolute;
left: 75px;
Expand All @@ -111,11 +122,10 @@
}

.left {
display: flex;
flex-direction: column;
display: block;
position: absolute;
left: 25px;
top: 100px;
top: 10%;
z-index: 1010;
}

Expand All @@ -130,7 +140,9 @@


.settings {
display: none;
display: block;
position: absolute;
z-index: 2000;
}

.center {
Expand Down Expand Up @@ -176,7 +188,6 @@
.settings {
display: flex;
flex-direction: column;
z-index: 1100;
position: absolute;
right: 25px;
top: 100px;
Expand All @@ -187,6 +198,53 @@
cursor: all-scroll;
border-radius: 24px;
transition: opacity 300ms ease-in-out;
z-index: 1100;
}

}
}

@media screen and (min-width: 1024px) and (orientation: landscape) {

.header__panels {
margin-right: 3rem;
}

.header__panels > div {
flex-wrap: nowrap;
margin-right: 1rem;
}

.left {
top:12%;
}

}

@media screen and (min-width: 1024px) and (orientation: portrait) {

.header__panels {
flex-wrap: nowrap;
}

.settings {
top: 4rem;
}

}

@media screen and (min-width: 1440px) {
.header__panels {
flex-wrap: nowrap;
}

}

@media screen and (min-width: 2560px) and (orientation: landscape) {

.left {
top: 5%;
}
.settings {
top: 4rem;
}
}
92 changes: 92 additions & 0 deletions src/ui/MobileSettings/MobileSettings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React, { useState, useEffect, useRef } from 'react';
import css from './MobileSettings.module.css';
import { UIButton } from '../Button/Button';
import { SVG } from '../Button/SVG';
import { TopToolbar } from '../TopToolbar/TopToolbar';
import { LeftToolbar } from '../LeftToolbar/LeftToolbar';
import { Mode2dSettingsPanel } from '../Panels/Mode2dSettingsPanel';

export const MobileSettings = () => {
const [isSettingsMenuOpen, setIsSettingsMenuOpen] = useState(false);
const [is2DMenuOpen, setIs2DMenuOpen] = useState(false);
const [isCursorMenuOpen, setIsCursorMenuOpen] = useState(false);
const [isSmallScreen, setIsSmallScreen] = useState(window.matchMedia('(max-width: 767px)').matches);
const containerRef = useRef(null);
const toggleSettingsMenu = () => {
setIsSettingsMenuOpen(!isSettingsMenuOpen);
setIs2DMenuOpen(false);
setIsCursorMenuOpen(false);
};

const toggle2DMenu = () => {
setIs2DMenuOpen(!is2DMenuOpen);
setIsSettingsMenuOpen(false);
setIsCursorMenuOpen(false);
};
const toggleCursorMenu = () => {
setIsCursorMenuOpen(!isCursorMenuOpen);
setIsSettingsMenuOpen(false);
setIs2DMenuOpen(false);
};
useEffect(() => {
const handleResize = () => {
setIsSmallScreen(window.matchMedia('(max-width: 768px)').matches);
};

window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
}, []);

useEffect(() => {
//TODO: next step is implementation behavior
const handleClickOutside = (event) => {
if (containerRef.current && !containerRef.current.contains(event.target)) {
setIsSettingsMenuOpen(false);
setIs2DMenuOpen(false);
setIsCursorMenuOpen(false);
}
};

const containerElement = containerRef.current;
containerElement.addEventListener('click', handleClickOutside);

return () => {
containerElement.removeEventListener('click', handleClickOutside);
};
}, []);
return (
<div className={css.settings__menu} ref={containerRef}>
<div className={css.buttons__container}>
<UIButton icon="settings-linear" cx={css['settings__menu__button']} handler={toggleSettingsMenu} testId={'buttonSettingsLinear'}>
<SVG name="settings-linear" width={42} height={42} />
</UIButton>
{isSmallScreen && (
<UIButton icon="2D" cx={`${css['settings__menu__button']} ${css.hide}`} handler={toggle2DMenu} testId={'button2D'}>
<SVG name="2D" width={42} height={42} />
</UIButton>
)}
<UIButton icon="cursor" cx={css['settings__menu__button']} handler={toggleCursorMenu} testId={'buttonCursor'}>
<SVG name="cursor" width={42} height={42} />
</UIButton>
</div>
{isSettingsMenuOpen && (
<div className={css.settings__menu_block + ' ' + css.flex}>
<Mode2dSettingsPanel />
</div>
)}
{(is2DMenuOpen || !isSmallScreen) && (
<div className={css.settings__menu_block}>
<LeftToolbar />
</div>
)}
{isCursorMenuOpen && (
<div className={css.settings__menu_block + ' ' + css.horizontal}>
<TopToolbar />
</div>
)}
</div>
);
};
Loading

0 comments on commit d9c2d80

Please sign in to comment.