Skip to content

Commit a0ceb47

Browse files
committed
Worked on making dark mode word correctly on context manager tab
1 parent 397aa02 commit a0ceb47

File tree

7 files changed

+94
-59
lines changed

7 files changed

+94
-59
lines changed

app/src/components/ContextAPIManager/AssignTab/AssignContainer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Button } from '@mui/material';
99
import DoubleArrowIcon from '@mui/icons-material/DoubleArrow';
1010
// import * as actions from '../../../redux/actions/actions';
1111
import StateContext from '../../../context/context';
12-
import { addComponentToContext } from '../../../redux/reducers/slice/contextReducer'
13-
import { useSelector, useDispatch, useStore, } from 'react-redux';
12+
import { addComponentToContext } from '../../../redux/reducers/slice/contextReducer';
13+
import { useSelector, useDispatch, useStore } from 'react-redux';
1414
import { deleteElement } from '../../../redux/reducers/slice/appStateSlice';
1515

1616
const AssignContainer = () => {
@@ -26,15 +26,15 @@ const AssignContainer = () => {
2626
// const [stateContext, dispatchContext] = useContext(StateContext);
2727
const { state, contextParam } = useSelector((store) => ({
2828
state: store.appState,
29-
contextParam: store.contextSlice,
29+
contextParam: store.contextSlice
3030
}));
3131

3232
//fetching data from redux store
3333
// useEffect(() => {
3434
// setState(allContext);
3535
// }, [allContext]);
3636

37-
const renderTable = targetContext => {
37+
const renderTable = (targetContext) => {
3838
if (targetContext === null || !targetContext.values) {
3939
setTableState(defaultTableData);
4040
} else {
@@ -43,7 +43,7 @@ const AssignContainer = () => {
4343
};
4444

4545
//construct data for table displaying component table
46-
const renderComponentTable = targetComponent => {
46+
const renderComponentTable = (targetComponent) => {
4747
//target Component is main
4848

4949
const listOfContexts = [];
@@ -52,7 +52,7 @@ const AssignContainer = () => {
5252
targetComponent !== null &&
5353
targetComponent.name
5454
) {
55-
contextParam.allContext.forEach(context => {
55+
contextParam.allContext.forEach((context) => {
5656
if (context.components.includes(targetComponent.name)) {
5757
listOfContexts.push(context.name);
5858
}
@@ -77,7 +77,7 @@ const AssignContainer = () => {
7777
})
7878
);
7979
//trigger generateCode(), update code preview tab
80-
dispatch(deleteElement({id:'FAKE_ID', contextParam: contextParam}))
80+
dispatch(deleteElement({ id: 'FAKE_ID', contextParam: contextParam }));
8181

8282
// dispatchContext({
8383
// type: 'DELETE ELEMENT',

app/src/components/ContextAPIManager/AssignTab/components/ComponentDropDrown.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const ComponentDropDown = ({
1515
}) => {
1616
const { allContext } = contextStore;
1717
// const [componentList] = useContext(StateContext);
18-
const state = useSelector(store => store.appState)
18+
const { state, isDarkMode } = useSelector((store) => ({
19+
state: store.appState,
20+
isDarkMode: store.darkMode.isDarkMode
21+
}));
1922

2023
const onChange = (event, newValue) => {
2124
if (typeof newValue === 'string') {
@@ -40,7 +43,7 @@ const ComponentDropDown = ({
4043
const filtered = filter(options, params);
4144
const { inputValue } = params;
4245
// Suggest the creation of a new contextInput
43-
const isExisting = options.some(option => inputValue === option.name);
46+
const isExisting = options.some((option) => inputValue === option.name);
4447
if (inputValue !== '' && !isExisting) {
4548
filtered.push({
4649
inputValue,
@@ -53,7 +56,7 @@ const ComponentDropDown = ({
5356
return filtered;
5457
};
5558

56-
const getOptionLabel = option => {
59+
const getOptionLabel = (option) => {
5760
// Value selected with enter, right from the input
5861
if (typeof option === 'string') {
5962
return option;
@@ -67,6 +70,7 @@ const ComponentDropDown = ({
6770
};
6871

6972
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
73+
const color = isDarkMode ? 'lightgray' : 'black';
7074

7175
return (
7276
<Fragment>
@@ -84,8 +88,15 @@ const ComponentDropDown = ({
8488
renderOption={renderOption}
8589
sx={{ width: 425 }}
8690
freeSolo
87-
renderInput={params => (
88-
<TextField {...params} label="Select Component" helperText='Select a component for your selected context to consume' />
91+
renderInput={(params) => (
92+
<TextField
93+
{...params}
94+
label="Select Component"
95+
helperText="Select a component for your selected context to consume"
96+
InputLabelProps={{ style: { color } }}
97+
FormHelperTextProps={{ style: { color } }}
98+
InputProps={{ style: { color } }}
99+
/>
89100
)}
90101
/>
91102
</Box>

app/src/components/ContextAPIManager/AssignTab/components/ContextDropDown.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
44
import Button from '@mui/material/Button';
55
import Box from '@mui/material/Box';
66
import { Typography } from '@mui/material';
7+
import { useSelector } from 'react-redux';
78

89
const filter = createFilterOptions();
910

@@ -14,6 +15,7 @@ const ContextDropDown = ({
1415
setContextInput
1516
}) => {
1617
const { allContext } = contextStore;
18+
const isDarkMode = useSelector((store) => store.darkMode.isDarkMode);
1719

1820
const onChange = (event, newValue) => {
1921
if (typeof newValue === 'string') {
@@ -38,7 +40,7 @@ const ContextDropDown = ({
3840
const filtered = filter(options, params);
3941
const { inputValue } = params;
4042
// Suggest the creation of a new contextInput
41-
const isExisting = options.some(option => inputValue === option.name);
43+
const isExisting = options.some((option) => inputValue === option.name);
4244
if (inputValue !== '' && !isExisting) {
4345
filtered.push({
4446
inputValue,
@@ -51,7 +53,7 @@ const ContextDropDown = ({
5153
return filtered;
5254
};
5355

54-
const getOptionLabel = option => {
56+
const getOptionLabel = (option) => {
5557
// Value selected with enter, right from the input
5658
if (typeof option === 'string') {
5759
return option;
@@ -65,6 +67,7 @@ const ContextDropDown = ({
6567
};
6668

6769
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
70+
const color = isDarkMode ? 'lightgray' : 'black';
6871

6972
return (
7073
<Fragment>
@@ -82,8 +85,15 @@ const ContextDropDown = ({
8285
renderOption={renderOption}
8386
sx={{ width: 425 }}
8487
freeSolo
85-
renderInput={params => (
86-
<TextField {...params} label="Select Context" helperText='Select a context you would like to assign'/>
88+
renderInput={(params) => (
89+
<TextField
90+
{...params}
91+
label="Select Context"
92+
helperText="Select a context you would like to assign"
93+
InputLabelProps={{ style: { color } }}
94+
FormHelperTextProps={{ style: { color } }}
95+
InputProps={{ style: { color } }}
96+
/>
8797
)}
8898
/>
8999
</Box>

app/src/components/ContextAPIManager/ContextManager.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import TabPanel from '@mui/lab/TabPanel';
99
import CreateContainer from './CreateTab/CreateContainer';
1010
import AssignContainer from './AssignTab/AssignContainer';
1111
import DisplayContainer from './DisplayTab/DisplayContainer';
12-
import { useSelector } from 'react-redux'
13-
12+
import { useSelector } from 'react-redux';
1413

1514
const useStyles = makeStyles({
1615
contextContainer: {
@@ -20,26 +19,27 @@ const useStyles = makeStyles({
2019
});
2120

2221
const ContextManager = (props): JSX.Element => {
23-
const isDarkMode = useSelector(state => state.darkMode.isDarkMode);
22+
const isDarkMode = useSelector((state) => state.darkMode.isDarkMode);
2423
const classes = useStyles();
2524
const [value, setValue] = React.useState<string>('1');
26-
25+
2726
const handleChange = (event: React.SyntheticEvent, newValue: string) => {
2827
setValue(newValue);
2928
};
3029

31-
const background_Color = isDarkMode ? '#21262b' : 'white'
30+
const backgroundColor = isDarkMode ? '#21262b' : 'white';
31+
const color = isDarkMode ? 'lightgray' : 'black';
3232

3333
return (
3434
<React.Fragment>
35-
<div className={classes.contextContainer} style={{backgroundColor: background_Color}}>
35+
<div className={classes.contextContainer} style={{ backgroundColor }}>
3636
<Box sx={{ width: '100%', typography: 'body1' }}>
3737
<TabContext value={value}>
3838
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
3939
<TabList onChange={handleChange} centered={true}>
40-
<Tab label="Create/Edit" value="1" />
41-
<Tab label="Assign" value="2" />
42-
<Tab label="Display" value="3" />
40+
<Tab label="Create/Edit" value="1" style={{ color }} />
41+
<Tab label="Assign" value="2" style={{ color }} />
42+
<Tab label="Display" value="3" style={{ color }} />
4343
</TabList>
4444
</Box>
4545
<TabPanel value="1">

app/src/components/ContextAPIManager/CreateTab/CreateContainer.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ import AddContextForm from './components/AddContextForm';
88
// import * as actions from '../../../redux/actions/actions';
99
import { Typography } from '@mui/material';
1010
import StateContext from '../../../context/context';
11-
import { addContext, deleteContext } from '../../../redux/reducers/slice/contextReducer';
11+
import {
12+
addContext,
13+
deleteContext
14+
} from '../../../redux/reducers/slice/contextReducer';
1215
import { useSelector, useDispatch } from 'react-redux';
1316
import { deleteElement } from '../../../redux/reducers/slice/appStateSlice';
1417

1518
const CreateContainer = () => {
1619
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
17-
const state = useSelector(store => store.contextSlice);
20+
const { state, isDarkMode } = useSelector((store) => ({
21+
state: store.appState,
22+
isDarkMode: store.darkMode.isDarkMode
23+
}));
1824

1925
const store = useStore();
2026
// const [state, setState] = useState([]);
@@ -31,8 +37,6 @@ const CreateContainer = () => {
3137

3238
// }, [allContext]);
3339

34-
35-
3640
//update data store when user adds a new context
3741
const handleClickSelectContext = () => {
3842
//prevent user from adding duplicate context
@@ -49,9 +53,7 @@ const CreateContainer = () => {
4953

5054
//update data store when user add new key-value pair to context
5155
const handleClickInputData = ({ name }, { inputKey, inputValue }) => {
52-
dispatch(
53-
addContext({ name, inputKey, inputValue })
54-
);
56+
dispatch(addContext({ name, inputKey, inputValue }));
5557
// setState(allContext);
5658
};
5759

@@ -62,15 +64,15 @@ const CreateContainer = () => {
6264
// setState(allContext);
6365
setTableState(defaultTableData);
6466

65-
dispatch(deleteElement({id:'FAKE_ID', contextParam: state}))
67+
dispatch(deleteElement({ id: 'FAKE_ID', contextParam: state }));
6668
// dispatchContext({
6769
// type: 'DELETE ELEMENT',
6870
// payload: 'FAKE_ID'
6971
// });
7072
};
7173

7274
//re-render data table when there's new changes
73-
const renderTable = targetContext => {
75+
const renderTable = (targetContext) => {
7476
if (
7577
targetContext === null ||
7678
targetContext === undefined ||
@@ -82,6 +84,9 @@ const CreateContainer = () => {
8284
setTableState(targetContext.values);
8385
}
8486
};
87+
88+
const color = isDarkMode ? 'lightgray' : 'black';
89+
8590
return (
8691
<>
8792
<Grid container display="flex" justifyContent="space-evenly">
@@ -116,11 +121,7 @@ const CreateContainer = () => {
116121
</Grid>
117122
<Divider orientation="vertical" variant="middle" flexItem />
118123
<Grid item>
119-
<Typography
120-
style={{ color: 'black' }}
121-
variant="h6"
122-
gutterBottom={true}
123-
>
124+
<Typography style={{ color }} variant="h6" gutterBottom={true}>
124125
Context Data Table
125126
</Typography>
126127
<DataTable target={tableState} contextInput={contextInput} />

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const AddContextForm = ({
2020
const { allContext } = contextStore;
2121
const [btnDisabled, setBtnDisabled] = useState(false);
2222
// const [state, dispatch] = useContext(StateContext);
23-
const state = useSelector(store => store.appState)
23+
// const state = useSelector(store => store.appState)
24+
const isDarkMode = useSelector((state) => state.darkMode.isDarkMode);
2425

2526
const handleClick = () => {
2627
if (contextInput === '' || contextInput === null) return;
@@ -50,7 +51,7 @@ const AddContextForm = ({
5051
const filtered = filter(options, params);
5152
const { inputValue } = params;
5253
// Suggest the creation of a new contextInput
53-
const isExisting = options.some(option => inputValue === option.name);
54+
const isExisting = options.some((option) => inputValue === option.name);
5455
if (inputValue !== '' && !isExisting) {
5556
filtered.push({
5657
inputValue,
@@ -63,7 +64,7 @@ const AddContextForm = ({
6364
return filtered;
6465
};
6566

66-
const getOptionLabel = option => {
67+
const getOptionLabel = (option) => {
6768
// Value selected with enter, right from the input
6869
if (typeof option === 'string') {
6970
return option;
@@ -77,13 +78,14 @@ const AddContextForm = ({
7778
};
7879

7980
const renderOption = (props, option) => <li {...props}>{option.name}</li>;
81+
const color = isDarkMode ? 'lightgray' : 'black';
8082

8183
return (
8284
<Fragment>
83-
<Typography style={{ color: 'black' }} variant="h6" gutterBottom={true}>
85+
<Typography style={{ color }} variant="h6" gutterBottom={true}>
8486
Context Input
8587
</Typography>
86-
<Box sx={{ display: 'flex', gap: 2, mb: 4 }}>
88+
<Box sx={{ display: 'flex', gap: 2, mb: 4, color }}>
8789
<Autocomplete
8890
id="autoCompleteContextField"
8991
value={contextInput}
@@ -97,8 +99,14 @@ const AddContextForm = ({
9799
renderOption={renderOption}
98100
sx={{ width: 425 }}
99101
freeSolo
100-
renderInput={params => (
101-
<TextField {...params} label="Create/Select Context" />
102+
renderInput={(params) => (
103+
<TextField
104+
{...params}
105+
variant="outlined"
106+
label="Create/Select Context"
107+
InputLabelProps={{ style: { color } }}
108+
InputProps={{ style: { color } }}
109+
/>
102110
)}
103111
/>
104112
<Button

0 commit comments

Comments
 (0)