feat: resize log on browser size change
This commit is contained in:
@@ -37,6 +37,19 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
const { width } = useBrowserDimensionsStore();
|
const { width } = useBrowserDimensionsStore();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const { currentWorkflowActionsState, shouldResetInterpretationLog, notify } = useGlobalInfoStore();
|
const { currentWorkflowActionsState, shouldResetInterpretationLog, notify } = useGlobalInfoStore();
|
||||||
|
const [dimensions, setDimensions] = useState({
|
||||||
|
drawerHeight: window.innerHeight * 0.7,
|
||||||
|
drawerWidth: window.innerWidth * 0.716,
|
||||||
|
buttonWidth: window.innerWidth * 0.7
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleResize = useCallback(() => {
|
||||||
|
setDimensions({
|
||||||
|
drawerHeight: window.innerHeight * 0.7,
|
||||||
|
drawerWidth: window.innerWidth * 0.716,
|
||||||
|
buttonWidth: window.innerWidth * 0.7
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const toggleDrawer = (newOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
const toggleDrawer = (newOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
||||||
if (
|
if (
|
||||||
@@ -95,6 +108,14 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
setCustomValue(event.target.value);
|
setCustomValue(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
|
}, [handleResize]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldResetInterpretationLog) {
|
if (shouldResetInterpretationLog) {
|
||||||
setLog('');
|
setLog('');
|
||||||
@@ -142,7 +163,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
background: '#ff00c3',
|
background: '#ff00c3',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
padding: '10px 20px',
|
padding: '10px 20px',
|
||||||
width: window.innerWidth * 0.7,
|
width: dimensions.buttonWidth,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
textAlign: 'left',
|
textAlign: 'left',
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
@@ -164,8 +185,8 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
background: `${darkMode ? '#1e2124' : 'white'}`,
|
background: `${darkMode ? '#1e2124' : 'white'}`,
|
||||||
color: `${darkMode ? 'white' : 'black'}`,
|
color: `${darkMode ? 'white' : 'black'}`,
|
||||||
padding: '10px',
|
padding: '10px',
|
||||||
height: window.innerHeight * 0.7,
|
height: dimensions.drawerHeight,
|
||||||
width: window.innerWidth * 0.716,
|
width: dimensions.drawerWidth,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
borderRadius: '10px 10px 0 0',
|
borderRadius: '10px 10px 0 0',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user