Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/25 #71

Merged
merged 3 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { ReactElement, useContext, useMemo } from 'react';
import styled from '@emotion/styled';
import MemberContext from 'components/MemberProvider/MemberContext';
import Icon from 'components/Icon';
import UserAvatar from 'components/UserAvatar';
import { useRouter } from 'next/router';
import { IconTypes } from 'components/Icon/Icon';
import Link from 'next/link';

const TAB_LIST = [
{ name: 'home', path: '/' },
{ name: 'explore', path: '/explore' },
{ name: 'newPost', path: '/newPost' },
{ name: 'activity', path: '/accounts/activity' },
];

function Footer(): ReactElement {
const { member } = useContext(MemberContext);
const { pathname } = useRouter();
const tabList = useMemo(
() => TAB_LIST.map(({ name, path }) => ({ name: path === pathname ? `${name}Filled` : name, path })),
[pathname],
);
return (
<Nav>
{tabList.map(({ name, path }) =>
name === 'newPost' ? (
<Button key={`${name}Tab`}>
<Icon name={name as IconTypes} size="big" key={`${name}Icon`} />
</Button>
) : (
<Link href={path} key={`${name}Tab`}>
<Tab>
<Icon name={name as IconTypes} size="big" />
</Tab>
</Link>
),
)}
<Link href={`/profiles/${member?.displayId}`}>
<Tab>
<UserAvatar size="small" thumbnail={member?.profileImageUrl} />
</Tab>
</Link>
</Nav>
);
}

export default Footer;

const Nav = styled.nav`
height: 44px;
background-color: white;
display: flex;
`;

const Tab = styled.a`
all: unset;
cursor: pointer;
height: 100%;
flex: 1 1 auto;
display: flex;
justify-content: center;
align-items: center;
`;

const Button = Tab.withComponent('button');
2 changes: 2 additions & 0 deletions components/Footer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Footer';
export * from './Footer';
8 changes: 4 additions & 4 deletions components/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Activity.args = {
size: 'big',
};

export const Search = Template.bind({});
Search.args = {
name: 'search',
export const Explore = Template.bind({});
Explore.args = {
name: 'explore',
size: 'big',
};

Expand Down Expand Up @@ -63,7 +63,7 @@ Bookmark.args = {

export const Newpost = Template.bind({});
Newpost.args = {
name: 'newpost',
name: 'newPost',
size: 'big',
};

Expand Down
1 change: 1 addition & 0 deletions components/Icon/svg/activity-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion components/Icon/svg/activity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions components/Icon/svg/explore-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions components/Icon/svg/home-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion components/Icon/svg/home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions components/Icon/svg/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export { ReactComponent as menu } from './menu.svg';
export { ReactComponent as home } from './home.svg';
export { ReactComponent as homeFilled } from './home-filled.svg';
export { ReactComponent as activity } from './activity.svg';
export { ReactComponent as search } from './search.svg';
export { ReactComponent as activityFilled } from './activity-filled.svg';
export { ReactComponent as explore } from './explore.svg';
export { ReactComponent as exploreFilled } from './explore-filled.svg';
export { ReactComponent as favorite } from './favorite.svg';
export { ReactComponent as comment } from './comment.svg';
export { ReactComponent as share } from './share.svg';
export { ReactComponent as bookmark } from './bookmark.svg';
export { ReactComponent as newpost } from './newpost.svg';
export { ReactComponent as newPost } from './newpost.svg';
export { ReactComponent as back } from './back.svg';
30 changes: 30 additions & 0 deletions components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { ReactElement, ReactNode } from 'react';
import styled from '@emotion/styled';

export type LayoutProps = {
header: ReactNode;
footer: ReactNode;
children: ReactElement;
};

function Layout({ header, footer, children }: LayoutProps): ReactElement {
return (
<Container>
{header}
<ChildrenContainer>{children}</ChildrenContainer>
{footer}
</Container>
);
}

export default Layout;

const Container = styled.div`
display: flex;
height: 100%;
flex-direction: column;
`;

const ChildrenContainer = styled.div`
flex: 1 1 auto;
`;
3 changes: 1 addition & 2 deletions components/UserAvatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export type UserAvatarType = {
size?: 'small' | 'big';
};

const DEFAULT_THUMBNAIL =
'https://scontent-mxp1-2.cdninstagram.com/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=scontent-mxp1-2.cdninstagram.com&_nc_ohc=q2X-4RcAgecAX-QGx5q&oh=911ea87522a15a1d1657ee9b1070086b&oe=606FB88F&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2';
const DEFAULT_THUMBNAIL = '/img/default_avatar.jpg';

const defaultProps = {
thumbnail: DEFAULT_THUMBNAIL,
Expand Down
8 changes: 5 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = {
const withImages = require('next-images');

module.exports = withImages({
webpack(config) {
config.module.rules.push({
config.module.rules.unshift({
test: /\.svg$/,
use: ['@svgr/webpack'],
});

return config;
},
};
});
7 changes: 6 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { AppProps } from 'next/app';
import { Global, css } from '@emotion/react';
import { CookiesProvider } from 'react-cookie';
import MemberProvider from 'components/MemberProvider/MemberProvider';
import Layout from 'components/Layout/Layout';
import Footer from 'components/Footer';

export default function App({ Component, pageProps }: AppProps) {
const footer = <Footer />;
return (
<>
<Global
Expand All @@ -19,7 +22,9 @@ export default function App({ Component, pageProps }: AppProps) {
/>
<CookiesProvider>
<MemberProvider>
<Component {...pageProps}>_App</Component>
<Layout header={null} footer={footer}>
<Component {...pageProps}>_App</Component>
</Layout>
</MemberProvider>
</CookiesProvider>
</>
Expand Down
7 changes: 7 additions & 0 deletions pages/accounts/activity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { ReactElement } from 'react';

function Activity(): ReactElement {
return <div>Activity</div>;
}

export default Activity;
7 changes: 7 additions & 0 deletions pages/explore.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { ReactElement } from 'react';

function Explore(): ReactElement {
return <div>Explore</div>;
}

export default Explore;
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactElement } from 'react';

function Index(): ReactElement {
return <div>Index</div>;
return <div>test</div>;
}

export default Index;
12 changes: 12 additions & 0 deletions pages/profiles/[displayId].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { ReactElement } from 'react';
import { useRouter } from 'next/router';

export type ProfileProps = {};

function Profile({}: ProfileProps): ReactElement {
const router = useRouter();
const { displayId } = router.query;
return <div>{displayId}</div>;
}

export default Profile;
Binary file added public/img/default_avatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.