rightpanel theme changed

This commit is contained in:
amit
2024-11-10 14:30:33 +05:30
parent 0f801b7ac7
commit 5354282aef
3 changed files with 54 additions and 34 deletions

View File

@@ -4,19 +4,23 @@ import { Typography, FormControlLabel, Checkbox, Box } from '@mui/material';
import { useActionContext } from '../../context/browserActions'; import { useActionContext } from '../../context/browserActions';
import MaxunLogo from "../../assets/maxunlogo.png"; import MaxunLogo from "../../assets/maxunlogo.png";
const CustomBoxContainer = styled.div` interface CustomBoxContainerProps {
isDarkMode: boolean;
}
const CustomBoxContainer = styled.div<CustomBoxContainerProps>`
position: relative; position: relative;
min-width: 250px; min-width: 250px;
width: auto; width: auto;
min-height: 100px; min-height: 100px;
height: auto; height: auto;
// border: 2px solid #ff00c3;
border-radius: 5px; border-radius: 5px;
background-color: white; background-color: ${({ isDarkMode }) => (isDarkMode ? '#313438' : 'white')};
color: ${({ isDarkMode }) => (isDarkMode ? 'white' : 'black')};
margin: 80px 13px 25px 13px; margin: 80px 13px 25px 13px;
`; `;
const Triangle = styled.div` const Triangle = styled.div<CustomBoxContainerProps>`
position: absolute; position: absolute;
top: -15px; top: -15px;
left: 50%; left: 50%;
@@ -25,7 +29,7 @@ const Triangle = styled.div`
height: 0; height: 0;
border-left: 20px solid transparent; border-left: 20px solid transparent;
border-right: 20px solid transparent; border-right: 20px solid transparent;
border-bottom: 20px solid white; border-bottom: 20px solid ${({ isDarkMode }) => (isDarkMode ? '#313438' : 'white')};
`; `;
const Logo = styled.img` const Logo = styled.img`
@@ -43,7 +47,7 @@ const Content = styled.div`
text-align: left; text-align: left;
`; `;
const ActionDescriptionBox = () => { const ActionDescriptionBox = ({ isDarkMode }: { isDarkMode: boolean }) => {
const { getText, getScreenshot, getList, captureStage } = useActionContext() as { const { getText, getScreenshot, getList, captureStage } = useActionContext() as {
getText: boolean; getText: boolean;
getScreenshot: boolean; getScreenshot: boolean;
@@ -52,14 +56,14 @@ const ActionDescriptionBox = () => {
}; };
const messages = [ const messages = [
{ stage: 'initial' as const, text: 'Select the list you want to extract along with the texts inside it' }, { stage: 'initial', text: 'Select the list you want to extract along with the texts inside it' },
{ stage: 'pagination' as const, text: 'Select how the robot can capture the rest of the list' }, { stage: 'pagination', text: 'Select how the robot can capture the rest of the list' },
{ stage: 'limit' as const, text: 'Choose the number of items to extract' }, { stage: 'limit', text: 'Choose the number of items to extract' },
{ stage: 'complete' as const, text: 'Capture is complete' }, { stage: 'complete', text: 'Capture is complete' },
]; ];
const stages = messages.map(({ stage }) => stage); // Create a list of stages const stages = messages.map(({ stage }) => stage);
const currentStageIndex = stages.indexOf(captureStage); // Get the index of the current stage const currentStageIndex = stages.indexOf(captureStage);
const renderActionDescription = () => { const renderActionDescription = () => {
if (getText) { if (getText) {
@@ -89,11 +93,21 @@ const ActionDescriptionBox = () => {
key={stage} key={stage}
control={ control={
<Checkbox <Checkbox
checked={index < currentStageIndex} // Check the box if we are past this stage checked={index < currentStageIndex}
disabled disabled
sx={{
color: isDarkMode ? 'white' : 'default',
'&.Mui-checked': {
color: isDarkMode ? '#90caf9' : '#1976d2',
},
}}
/> />
} }
label={<Typography variant="body2" gutterBottom>{text}</Typography>} label={
<Typography variant="body2" gutterBottom color={isDarkMode ? 'white' : 'textPrimary'}>
{text}
</Typography>
}
/> />
))} ))}
</Box> </Box>
@@ -110,9 +124,9 @@ const ActionDescriptionBox = () => {
}; };
return ( return (
<CustomBoxContainer> <CustomBoxContainer isDarkMode={isDarkMode}>
<Logo src={MaxunLogo} alt="Maxun Logo" /> <Logo src={MaxunLogo} alt="Maxun Logo" />
<Triangle /> <Triangle isDarkMode={isDarkMode} />
<Content> <Content>
{renderActionDescription()} {renderActionDescription()}
</Content> </Content>

View File

@@ -1,16 +1,15 @@
import React, { useRef } from 'react'; import React, { useRef } from 'react';
import styled from "styled-components"; import styled from "styled-components";
import { Button } from "@mui/material"; import { Button } from "@mui/material";
//import { ActionDescription } from "../organisms/RightSidePanel";
import * as Settings from "./action-settings"; import * as Settings from "./action-settings";
import { useSocketStore } from "../../context/socket"; import { useSocketStore } from "../../context/socket";
interface ActionSettingsProps { interface ActionSettingsProps {
action: string; action: string;
darkMode?: boolean;
} }
export const ActionSettings = ({ action }: ActionSettingsProps) => { export const ActionSettings = ({ action, darkMode = false }: ActionSettingsProps) => {
const settingsRef = useRef<{ getSettings: () => object }>(null); const settingsRef = useRef<{ getSettings: () => object }>(null);
const { socket } = useSocketStore(); const { socket } = useSocketStore();
@@ -20,30 +19,27 @@ export const ActionSettings = ({ action }: ActionSettingsProps) => {
return <Settings.ScreenshotSettings ref={settingsRef} />; return <Settings.ScreenshotSettings ref={settingsRef} />;
case 'scroll': case 'scroll':
return <Settings.ScrollSettings ref={settingsRef} />; return <Settings.ScrollSettings ref={settingsRef} />;
case 'scrape': case 'scrape':
return <Settings.ScrapeSettings ref={settingsRef} />; return <Settings.ScrapeSettings ref={settingsRef} />;
case 'scrapeSchema': case 'scrapeSchema':
return <Settings.ScrapeSchemaSettings ref={settingsRef} />; return <Settings.ScrapeSchemaSettings ref={settingsRef} />;
default: default:
return null; return null;
} }
} };
const handleSubmit = (event: React.SyntheticEvent) => { const handleSubmit = (event: React.SyntheticEvent) => {
event.preventDefault(); event.preventDefault();
//get the data from settings
const settings = settingsRef.current?.getSettings(); const settings = settingsRef.current?.getSettings();
//Send notification to the server and generate the pair
socket?.emit(`action`, { socket?.emit(`action`, {
action, action,
settings settings
}); });
} };
return ( return (
<div> <div>
{/* <ActionDescription>Action settings:</ActionDescription> */} <ActionSettingsWrapper action={action} darkMode={darkMode}>
<ActionSettingsWrapper action={action}>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<DisplaySettings /> <DisplaySettings />
<Button <Button
@@ -64,10 +60,13 @@ export const ActionSettings = ({ action }: ActionSettingsProps) => {
); );
}; };
const ActionSettingsWrapper = styled.div<{ action: string }>` // Ensure that the Wrapper accepts the darkMode prop for styling adjustments.
const ActionSettingsWrapper = styled.div<{ action: string; darkMode: boolean }>`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: ${({ action }) => action === 'script' ? 'stretch' : 'center'};; align-items: ${({ action }) => (action === 'script' ? 'stretch' : 'center')};
justify-content: center; justify-content: center;
margin-top: 20px; margin-top: 20px;
background-color: ${({ darkMode }) => (darkMode ? '#1E1E1E' : 'white')};
color: ${({ darkMode }) => (darkMode ? 'white' : 'black')};
`; `;

View File

@@ -395,8 +395,8 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
{/* <SimpleBox height={60} width='100%' background='lightGray' radius='0%'> {/* <SimpleBox height={60} width='100%' background='lightGray' radius='0%'>
<Typography sx={{ padding: '10px' }}>Last action: {` ${lastAction}`}</Typography> <Typography sx={{ padding: '10px' }}>Last action: {` ${lastAction}`}</Typography>
</SimpleBox> */} </SimpleBox> */}
<ActionDescriptionBox /> <ActionDescriptionBox isDarkMode={isDarkMode} />
<Box display="flex" flexDirection="column" gap={2} style={{ margin: '13px' }}> <Box display="flex" flexDirection="column" gap={2} style={{ margin: '13px',background: isDarkMode?'#1E2124': 'inherit',color: isDarkMode ? 'white' : 'inherit' }}>
{!getText && !getScreenshot && !getList && showCaptureList && <Button variant="contained" onClick={startGetList}>Capture List</Button>} {!getText && !getScreenshot && !getList && showCaptureList && <Button variant="contained" onClick={startGetList}>Capture List</Button>}
{getList && ( {getList && (
<> <>
@@ -426,7 +426,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
)} )}
{showLimitOptions && ( {showLimitOptions && (
<FormControl> <FormControl>
<FormLabel> <FormLabel style={{ marginBottom: '10px', background: isDarkMode ? "#1E2124" : 'white', color: isDarkMode ? "white" : 'black' }}>
<h4>What is the maximum number of rows you want to extract?</h4> <h4>What is the maximum number of rows you want to extract?</h4>
</FormLabel> </FormLabel>
<RadioGroup <RadioGroup
@@ -452,9 +452,11 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
marginLeft: '10px', marginLeft: '10px',
'& input': { '& input': {
padding: '10px', padding: '10px',
background: 'white',
}, },
width: '150px', // Ensure the text field does not go outside the panel width: '150px',
background: isDarkMode ? "#1E2124" : 'white',
color: isDarkMode ? "white" : 'black', // Ensure the text field does not go outside the panel
}} }}
/> />
)} )}
@@ -503,6 +505,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
</InputAdornment> </InputAdornment>
) )
}} }}
sx={{ background: isDarkMode ? "#1E2124" : 'white', color: isDarkMode ? "white" : 'black' }}
/> />
<TextField <TextField
label="Data" label="Data"
@@ -517,6 +520,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
</InputAdornment> </InputAdornment>
) )
}} }}
sx={{ background: isDarkMode ? "#1E2124" : 'white', color: isDarkMode ? "white" : 'black' }}
/> />
{!confirmedTextSteps[step.id] && ( {!confirmedTextSteps[step.id] && (
<Box display="flex" justifyContent="space-between" gap={2}> <Box display="flex" justifyContent="space-between" gap={2}>
@@ -553,6 +557,8 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
</InputAdornment> </InputAdornment>
) )
}} }}
style={{ background: isDarkMode ? "#1E2124" : 'white' }}
/> />
<TextField <TextField
label="Field Data" label="Field Data"
@@ -567,6 +573,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
</InputAdornment> </InputAdornment>
) )
}} }}
style={{ background: isDarkMode ? "#1E2124" : 'white' }}
/> />
{!confirmedListTextFields[step.id]?.[key] && ( {!confirmedListTextFields[step.id]?.[key] && (
<Box display="flex" justifyContent="space-between" gap={2}> <Box display="flex" justifyContent="space-between" gap={2}>