Skip to content

Commit 67da2d5

Browse files
added new dropdown menu
1 parent 29f4f56 commit 67da2d5

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

src/app/components/Actions/Action.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ActionProps, OptionsCursorTrueWithMargin } from '../../FrontendTypes';
99
import { useDispatch } from 'react-redux';
1010

1111
/*
12-
This render's the individual snapshot components on the left side column
12+
This renders the individual snapshot components on the left side column
1313
*/
1414

1515
/**
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Select from 'react-select';
2+
import React, { useEffect, useState } from 'react';
3+
4+
const DropDown = (): JSX.Element => {
5+
const [hook, setHook] = useState('useState');
6+
7+
const handleChange = (selectedHook: {hooks:string}) => {
8+
setHook(selectedHook);
9+
}
10+
11+
const options = [
12+
{value: 'useState', label: 'useState'},
13+
{value: 'useReducer', label: 'useReducer'},
14+
{value: 'useContext', label: 'useContext'}
15+
];
16+
17+
return (
18+
<Select
19+
placeholder = 'Select Hook'
20+
onChange={handleChange}
21+
options = {options}
22+
/>
23+
)
24+
}
25+
export default DropDown;

src/app/components/Actions/SwitchApp.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const SwitchAppDropdown = (): JSX.Element => {
2828
value: currentTab,
2929
label: tabs[currentTab].title,
3030
};
31+
console.log('tabs', tabs)
3132

3233
const customStyles: {} = {
3334
menu: (provided, state): {} => {
@@ -39,6 +40,11 @@ const SwitchAppDropdown = (): JSX.Element => {
3940
},
4041
};
4142

43+
const customComponents = {
44+
DropdownIndicator: () => null,
45+
IndicatorSeparator: () => null, // Removes the separator line
46+
};
47+
4248
return (
4349
<Select
4450
className='tab-select-container'
@@ -49,6 +55,9 @@ const SwitchAppDropdown = (): JSX.Element => {
4955
dispatch(setTab(parseInt(e.value, 10)));
5056
}}
5157
options={tabsArray}
58+
isSearchable={false} // Disable search functionality
59+
menuIsOpen={false} // Prevent dropdown from opening
60+
components={customComponents}
5261
/>
5362
);
5463
};

src/app/containers/ActionContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import React, { useEffect, useState } from 'react';
33
import Action from '../components/Actions/Action';
44
import SwitchAppDropdown from '../components/Actions/SwitchApp';
5+
// Import new dropdown
56
import { emptySnapshots, changeView, changeSlider } from '../slices/mainSlice';
67
import { useDispatch, useSelector } from 'react-redux';
78
import RouteDescription from '../components/Actions/RouteDescription';
9+
import DropDown from '../components/Actions/DropDown';
810
import { ActionContainerProps, CurrentTab, MainState, Obj, RootState } from '../FrontendTypes';
911
import { Button, Switch } from '@mui/material';
1012

@@ -221,6 +223,8 @@ function ActionContainer(props: ActionContainerProps): JSX.Element {
221223
{recordingActions ? <Switch defaultChecked /> : <Switch />}
222224
</a>
223225
<SwitchAppDropdown />
226+
{/* add new component here for dropdown menu for useStae/ useReducer- ragad */}
227+
<DropDown />
224228
<div className='action-component exclude'>
225229
<Button
226230
className='clear-button'

0 commit comments

Comments
 (0)