-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from bankidz/feature/component-navigate
feat: topAppBar, TabBar components
- Loading branch information
Showing
16 changed files
with
15,691 additions
and
12,815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import TabBar from './TabBar'; | ||
import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
import { storiesOf } from '@storybook/react'; | ||
import StoryRouter from 'storybook-react-router'; | ||
|
||
export default { | ||
title: 'Common/TabBar', | ||
component: TabBar, | ||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes | ||
argTypes: {}, | ||
decorators: [ | ||
(Story) => ( | ||
<BrowserRouter> | ||
<Routes> | ||
<Route | ||
path="*" | ||
element={ | ||
<div | ||
style={{ | ||
backgroundColor: '#F7F7F8', | ||
width: '100%', | ||
height: 'calc(var(--vh, 1vh) * 100)', | ||
}} | ||
> | ||
<Story /> | ||
</div> | ||
} | ||
/> | ||
</Routes> | ||
</BrowserRouter> | ||
), | ||
], | ||
} as ComponentMeta<typeof TabBar>; | ||
|
||
const Template: ComponentStory<typeof TabBar> = (args) => <TabBar {...args} />; | ||
|
||
export const 자녀 = Template.bind({}); | ||
자녀.args = { | ||
isKid: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useState } from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
import styled from 'styled-components'; | ||
import { ReactComponent as Home } from '../../assets/icons/home.svg'; | ||
import { ReactComponent as Contents } from '../../assets/icons/contents.svg'; | ||
import { ReactComponent as Mypage } from '../../assets/icons/mypage.svg'; | ||
import { theme } from '../../lib/styles/theme'; | ||
|
||
interface TabBarProps { | ||
/** | ||
* 부모-자식 여부 (금융콘텐츠-돈길모아보기) | ||
*/ | ||
isKid: boolean; | ||
} | ||
|
||
function TabBar({ isKid }: TabBarProps) { | ||
// 현재 active된 link (0,1,2) : child 컴포넌트에 active 전달해주기 위해 직접.. | ||
// 이걸 state로 관리할지, 아니면 navigate할때마다 dispatch해서 스토어에서 관리할지.. 아님 컴포넌트 자체를 전역으로 보여줄지 | ||
const [activeLink, setActiveLink] = useState(0); | ||
const active = [theme.palette.gray[3], theme.palette.yellow[0]]; | ||
|
||
return ( | ||
<Wrapper> | ||
<NavLink to="/" onClick={() => setActiveLink(0)}> | ||
<Home stroke={activeLink === 0 ? active[1] : active[0]} /> | ||
</NavLink> | ||
<NavLink | ||
to={isKid ? '/challenge' : '/contents'} | ||
onClick={() => setActiveLink(1)} | ||
> | ||
<Contents fill={activeLink === 1 ? active[1] : active[0]} /> | ||
</NavLink> | ||
<NavLink to="/mypage" onClick={() => setActiveLink(2)}> | ||
<Mypage fill={activeLink === 2 ? active[1] : active[0]} /> | ||
</NavLink> | ||
</Wrapper> | ||
); | ||
} | ||
|
||
export default TabBar; | ||
|
||
const Wrapper = styled.div` | ||
width: calc(100% + 2px); | ||
height: 48px; | ||
background-color: ${({ theme }) => theme.palette.white}; | ||
border-radius: 12px 12px 0px 0px; | ||
/* 테두리 위에만 */ | ||
border: 1px solid ${({ theme }) => theme.palette.gray[1]}; | ||
position: fixed; | ||
bottom: -1px; | ||
left: -1px; | ||
display: flex; | ||
justify-content: space-around; | ||
a { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import TopAppBar from './TopAppBar'; | ||
import { BrowserRouter, Routes, Route } from 'react-router-dom'; | ||
|
||
export default { | ||
title: 'Common/TopAppBar', | ||
component: TopAppBar, | ||
argTypes: {}, | ||
decorators: [ | ||
(Story) => ( | ||
<BrowserRouter> | ||
<Routes> | ||
<Route | ||
path="*" | ||
element={ | ||
<div | ||
style={{ | ||
backgroundColor: '#F7F7F8', | ||
width: '100%', | ||
height: 'calc(var(--vh, 1vh) * 100)', | ||
}} | ||
> | ||
<Story /> | ||
</div> | ||
} | ||
/> | ||
</Routes> | ||
</BrowserRouter> | ||
), | ||
], | ||
} as ComponentMeta<typeof TopAppBar>; | ||
|
||
const Template: ComponentStory<typeof TopAppBar> = (args) => ( | ||
<TopAppBar {...args} /> | ||
); | ||
|
||
export const 내_정보_수정 = Template.bind({}); | ||
내_정보_수정.args = { | ||
previous: '내정보 수정', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import styled from 'styled-components'; | ||
import { ReactComponent as Arrow } from '../../assets/icons/arrow-left.svg'; | ||
interface TopAppBarProps { | ||
/** | ||
* 이전 페이지명 | ||
*/ | ||
previous: string; | ||
} | ||
|
||
function TopAppBar({ previous }: TopAppBarProps) { | ||
const navigate = useNavigate(); | ||
|
||
const onClickTopAppBar = () => { | ||
navigate(-1); | ||
}; | ||
|
||
return ( | ||
<Wrapper onClick={onClickTopAppBar}> | ||
<Arrow /> | ||
<p>{previous}</p> | ||
</Wrapper> | ||
); | ||
} | ||
|
||
export default TopAppBar; | ||
|
||
const Wrapper = styled.div` | ||
width: 100%; | ||
height: 48px; | ||
padding: 0px 18px; | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
p { | ||
font-weight: bold; | ||
font-size: 15px; | ||
margin-left: 18px; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
function HomeKid() { | ||
return <>자녀 홈</>; | ||
const [height, setHeight] = useState(window.innerHeight); | ||
|
||
const handleResize = () => { | ||
setHeight(window.innerHeight); | ||
}; | ||
|
||
useEffect(() => { | ||
window.addEventListener('resize', handleResize); | ||
return () => { | ||
// cleanup | ||
window.removeEventListener('resize', handleResize); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{height} | ||
<input type="text" /> | ||
</> | ||
); | ||
} | ||
|
||
export default HomeKid; |
Oops, something went wrong.