✅ Tab
import { useState } from 'react';
import styled from 'styled-components';
const TabMenu = styled.ul`
background-color: #dcdcdc;
color: rgba(73, 73, 73, 0.5);
font-weight: bold;
display: flex;
flex-direction: row;
justify-items: center;
align-items: center;
list-style: none;
margin-bottom: 7rem;
cursor : pointer;
.submenu {
${'' }
display: flex;
justify-content: space-between;
width : 100px;
height : 30px;
padding : 10px;
font-size : 15px;
}
.focused {
${'' }
background-color: darkblue;
color : white
}
& div.desc {
text-align: center;
}
`;
const Desc = styled.div`
padding-left : 180px
`;
export const Tab = () => {
const [currentTab,setTab] = useState(0);
const menuArr = [
{ name: 'Tab1', content: 'Tab menu ONE' },
{ name: 'Tab2', content: 'Tab menu TWO' },
{ name: 'Tab3', content: 'Tab menu THREE' },
];
const selectMenuHandler = (index) => {
setTab(index);
};
return (
<>
<div>
<TabMenu>
{}
{}
{menuArr.map( (tap,index) => {
return (
<li key={index} className={currentTab === index ? "submenu focused" : "submenu"}
onClick={() => selectMenuHandler(index)}>{tap.name}</li>
)
})}
</TabMenu>
<Desc>
{}
<p>{menuArr[currentTab].content}</p>
</Desc>
</div>
</>
);
};