λ±λ‘νλ©΄μ μλ£λμμΌλ, μ΄μ νΈμ§νλ©΄μ κ°λ°ν΄ 보μ.
#13. λ±λ‘νλ©΄μμ λ΄μ© μ μ₯ λ° μ΄λ―Έμ§ μ μ₯ κΈ°λ₯ ꡬν
νΈμ§νλ©΄μ κ°λ°νκΈ°μ μ κ°κ° λ³ νλ©΄μ μ μνλ€ λ³΄λ, νλ©΄ νλ¦μ΄ λλλ‘ κ°λ°μ μΆκ° νλ€.
νλ©΄ νλ¦μ λλ΅μ μΌλ‘ μλ μμΌλ‘ ꡬνμ νλ€.
κ΄λ¦¬μλͺ¨λ νλ©΄μ λ§λ€μ΄ λ±λ‘/νΈμ§/μμ /μμλ³κ²½μ΄ κ°λ₯νκ² Prototype UIμ ꡬμ±ν΄ 보μ.
ββμ΄ νλ©΄ νλ¨μ λ©λ΄ μ μ
β menu.jsx ( μμΉ: linkservice/client/src/component/menu.jsx )
---------------------------------------------------------------------------------------------------
Reactμμ λ§μ΄ μ¬μ©νλ Material UI Icon μ μ¬μ©νμ¬ λ©λ΄λ€μ μμ±ν΄ 보μ.
ν°λ―Έλμ μ΄μ΄ λΌμ΄λΈλ¬λ¦¬λ₯Ό μ€μΉνλ€.
γγ yarn add @mui/icons-material @mui/material @emotion/styled @emotion/react
μμ΄μ½μ https://mui.com/material-ui/material-icons/ μ¬κΈ°μ μ°Ύμ μ μ©νλ€.
μ°μ HOME κ³Ό κ΄λ¦¬μ(SETTING) μμ΄μ½μ μ°Ύμ λ§μ λλ μμ΄μ½μ ν΄λ¦νλ©΄ import λ΄μ©μ΄ λμ¨λ€. 볡μ¬νμ¬ λΆμΈλ€.
import HomeIcon from '@mui/icons-material/Home';
import SettingsIcon from '@mui/icons-material/Settings';
export default function MenuIcon(props) {
return (
<>
<div className='menu-wrap'>
<div className='menu-box'>
<HomeIcon fontSize='large' color="secondary"/>
<SettingsIcon fontSize='large' color="secondary" />
</div>
</div>
</>
)
CSS μ μΆκ°νλ€. ( links.css νμΌμ μΆκ° )
.menu-wrap {
display: flex;
margin: 0 auto;
justify-content: center;
}
.menu-box {
padding: 20px;
text-align: center;
}
Material Iconμ μμκ³Ό ν¬κΈ°λ₯Ό μ μ© νλ€.
Icon ν΄λ¦ μ ν΄λΉ νμ΄μ§λ‘ μ΄λνλ onClick()μ HandleIcon() ν¨μλ₯Ό μ μνλ€.
import HomeIcon from '@mui/icons-material/Home';
import SettingsIcon from '@mui/icons-material/Settings';
import { useNavigate } from 'react-router-dom';
export default function MenuIcon(props) {
const navigator = useNavigate()
const handleIcon = (e) => {
switch (e) {
case 'A' : return navigator('/manager')
case 'M' : return navigator('/')
default : return navigator('/')
}
}
return (
<>
<div className='menu-wrap'>
<div className='menu-box'>
<HomeIcon fontSize='large' color="secondary"
onClick={() => handleIcon('M')}
/>
<SettingsIcon fontSize='large' color="secondary"
onClick={() => handleIcon('A')}
/>
</div>
</div>
</>
)
}
λͺ¨λ νμ΄μ§μ λ©λ΄κ° 보μ΄λλ‘ App.jsμ μμ νλ€.