diff --git a/ui-common/package.json b/ui-common/package.json index d255267fd..511f081d1 100644 --- a/ui-common/package.json +++ b/ui-common/package.json @@ -26,15 +26,16 @@ "@material-ui/core": "^4.11.3", "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.60", + "@types/jest": "^26.0.22", + "@types/node": "^12.20.10", "node-sass": "^6.0.0", "react": "^17.0.2", - "react-dom": "^17.0.2", - "recoil": "^0.5.2", "react-copy-to-clipboard": "^5.0.3", - "@types/jest": "^26.0.22", - "@types/node": "^12.20.10" + "react-dom": "^17.0.2", + "recoil": "^0.5.2" }, "dependencies": { + "@craco/craco": "^6.4.3", "@types/lodash": "^4.14.179", "@uiw/react-textarea-code-editor": "^1.4.12", "axios": "^0.25.0", @@ -49,7 +50,6 @@ "node-fetch": "^3.1.1", "numeral": "^2.0.6", "protobuf-decoder": "^0.1.0", - "react-resizable": "^3.0.4", "react-graph-vis": "^1.0.7", "react-lowlight": "^3.0.0", "react-router-dom": "^6.2.1", @@ -59,8 +59,7 @@ "redoc": "^2.0.0-rc.59", "styled-components": "^5.3.3", "web-vitals": "^1.1.1", - "xml-formatter": "^2.6.0", - "@craco/craco": "^6.4.3" + "xml-formatter": "^2.6.0" }, "devDependencies": { "@rollup/plugin-node-resolve": "^13.1.3", diff --git a/ui-common/src/components/ServiceMapModal/ServiceMapModal.module.sass b/ui-common/src/components/ServiceMapModal/ServiceMapModal.module.sass index e481416a7..433c87bc8 100644 --- a/ui-common/src/components/ServiceMapModal/ServiceMapModal.module.sass +++ b/ui-common/src/components/ServiceMapModal/ServiceMapModal.module.sass @@ -2,7 +2,6 @@ .modalContainer display: flex - flex-wrap: nowrap width: 100% height: 100% @@ -11,8 +10,6 @@ .filterSection flex: 15% - border-right: 1px solid $blue-color - margin-right: 2% height: 100% .filters table @@ -38,6 +35,7 @@ display: flex flex-direction: column margin-right: 10px + width: 100% .servicesFilterSearch width: calc(100% - 10px) @@ -47,7 +45,7 @@ margin-bottom: 5px .servicesFilter - margin-top: clamp(25px,15%,35px) + margin-top: 15px height: 100% overflow: hidden diff --git a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx index 5f6024541..9737891c4 100644 --- a/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx +++ b/ui-common/src/components/ServiceMapModal/ServiceMapModal.tsx @@ -12,10 +12,9 @@ import closeIcon from "assets/close.svg" import styles from './ServiceMapModal.module.sass' import SelectList from "../UI/SelectList"; import { GraphData, ServiceMapGraph } from "./ServiceMapModalTypes" -import { ResizableBox } from "react-resizable" -import "react-resizable/css/styles.css" import { Utils } from "../../helpers/Utils"; import { TOAST_CONTAINER_ID } from "../../configs/Consts"; +import Resizeable from "../UI/Resizeable" const modalStyle = { position: 'absolute', @@ -176,9 +175,8 @@ export const ServiceMapModal: React.FC = ({ isOpen, onClos
- {/* TODO: remove error missing height */} - -
+
+
= ({ isOpen, onClos
-
-
+ +
- - close onClose()} style={{ cursor: "pointer" }}> + close onClose()} style={{ cursor: "pointer", userSelect: "none" }}>
{isLoading &&
spinner diff --git a/ui-common/src/components/TrafficViewer/TrafficViewer.module.sass b/ui-common/src/components/TrafficViewer/TrafficViewer.module.sass index eba4ac330..a2730ab88 100644 --- a/ui-common/src/components/TrafficViewer/TrafficViewer.module.sass +++ b/ui-common/src/components/TrafficViewer/TrafficViewer.module.sass @@ -16,9 +16,8 @@ justify-content: space-between .TrafficPageStreamStatus - display: flex - align-items: center - + display: flex + align-items: center .TrafficPageHeaderImage width: 22px diff --git a/ui-common/src/components/UI/Resizeable.tsx b/ui-common/src/components/UI/Resizeable.tsx new file mode 100644 index 000000000..305b3ea73 --- /dev/null +++ b/ui-common/src/components/UI/Resizeable.tsx @@ -0,0 +1,61 @@ +import React, { useRef, useState } from "react"; + +import styles from './style/Resizeable.module.sass' + +export interface Props { + children + minWidth: number +} + +const Resizeable: React.FC = ({ children, minWidth }) => { + const resizeble = useRef(null) + let mousePos = { x: 0, y: 0 } + let elementDimention = { w: 0, h: 0 } + let isPressed = false + const [elemWidth, setElemWidth] = useState(resizeble?.current?.style?.width) + + const mouseDownHandler = function (e) { + // Get the current mouse position + mousePos = { x: e.clientX, y: e.clientY } + isPressed = true + + // Calculate the dimension of element + const styles = resizeble.current.getBoundingClientRect(); + elementDimention = { w: parseInt(styles.width, 10), h: parseInt(styles.height, 10) } + // Attach the listeners to `document` + window.addEventListener('mousemove', mouseMoveHandler); + window.addEventListener('mouseup', mouseUpHandler); + }; + + + const mouseMoveHandler = function (e) { + if (isPressed) { + // How far the mouse has been moved + const dx = e.clientX - mousePos.x; + const widthEl = elementDimention.w + dx + + if (widthEl >= minWidth) + // Adjust the dimension of element + setElemWidth(widthEl) + } + }; + + const mouseUpHandler = function () { + window.removeEventListener('mousemove', mouseMoveHandler); + window.removeEventListener('mouseup', mouseUpHandler); + isPressed = false + }; + + return ( + +
+ {children} +
+ {/*
-- FutureUse*/} +
+ +
+ ); +}; + +export default Resizeable; \ No newline at end of file diff --git a/ui-common/src/components/UI/style/Resizeable.module.sass b/ui-common/src/components/UI/style/Resizeable.module.sass new file mode 100644 index 000000000..ca21ffd97 --- /dev/null +++ b/ui-common/src/components/UI/style/Resizeable.module.sass @@ -0,0 +1,29 @@ +@import "../../../variables.module" + +.resizable + position: relative + align-items: center + display: flex + overflow: hidden + border-right: 1px solid $blue-color + height: 100% + width: 100% + padding-right: 3px + +.resizer + position: absolute + + &Right + cursor: col-resize + height: 100% + right: 0 + top: 0 + width: 5px + + // FutureUse + &Bottom + bottom: 0 + cursor: row-resize + height: 5px + left: 0 + width: 100% diff --git a/ui-common/src/components/UI/style/SelectList.module.sass b/ui-common/src/components/UI/style/SelectList.module.sass index 618ce93f6..02af14f07 100644 --- a/ui-common/src/components/UI/style/SelectList.module.sass +++ b/ui-common/src/components/UI/style/SelectList.module.sass @@ -3,6 +3,7 @@ .selectListTable overflow: auto height: 100% + user-select: none // when resizble moved we get unwanted beheviour table width: 100%