Skip to content

Commit

Permalink
[๐ŸŽ€ : style] ์‚ฌ์ด๋“œ ๋ฉ”๋‰ด + ํ™ˆ ์Šคํƒ€์ผ๋ง
Browse files Browse the repository at this point in the history
- ๊ณตํ†ต ์ปดํฌ๋„ŒํŠธ ๊ด€๋ฆฌ ๋ฐ ์Šคํƒ€์ผ ๊ฐœํŽธ
- styles ๋ ˆํฌ ์ •๋ฆฌ
  • Loading branch information
sryung1225 committed Dec 14, 2023
1 parent 0c74507 commit 453ec15
Show file tree
Hide file tree
Showing 28 changed files with 352 additions and 142 deletions.
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Profile from './routes/profile.tsx';
import Auth from './routes/auth.tsx';
import Layout from './components/layout.tsx';
import LoadingScreen from './components/loading-screen.tsx';
import * as S from './styles/App.ts';
import * as S from './styles/app.ts';

const router = createBrowserRouter([
{
Expand Down Expand Up @@ -44,10 +44,10 @@ function App() {
init();
}, []);
return (
<S.Wrapper>
<>
<S.GlobalStyles />
{isLoading ? <LoadingScreen /> : <RouterProvider router={router} />}
</S.Wrapper>
</>
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/assets/images/i-window1.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: 4 additions & 0 deletions src/assets/images/i-window2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/images/i-window3.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 src/components/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Outlet } from 'react-router-dom';
import Wrapper from '../styles/layout.ts';
import Menu from './menu.tsx';
import { Wrapper } from '../styles/layout.ts';
import Search from './search.tsx';

export default function Layout() {
return (
<Wrapper>
<Menu />
<Outlet />
<Search />
</Wrapper>
);
}
86 changes: 64 additions & 22 deletions src/components/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,77 @@
import { Link, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { auth } from '../firebase.ts';
import * as S from '../styles/components/menu.ts';
import WindowTop from './window-top.tsx';
import * as W from '../styles/window.ts';
import * as S from '../styles/menu.ts';
import * as P from '../styles/popup.ts';
import ImageComputer from '../assets/images/logo-small.png';
import { ReactComponent as IconUser } from '../assets/images/i-user.svg';
import { ReactComponent as IconHome } from '../assets/images/i-home.svg';
import { ReactComponent as IconLogout } from '../assets/images/i-arrowleft.svg';

export default function Menu() {
const navigate = useNavigate();
const [logoutPopup, setLogoutPopup] = useState(false);
const toggleLogoutPopup = () => {
setLogoutPopup(!logoutPopup);
};
useEffect(() => {
const handleEscKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
setLogoutPopup(false);
}
};
document.addEventListener('keydown', handleEscKey);
return () => {
document.removeEventListener('keydown', handleEscKey);
};
}, [logoutPopup]);
const onLogout = async () => {
// eslint-disable-next-line no-restricted-globals
const ok = confirm('๋กœ๊ทธ์•„์›ƒ ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?');
if (ok) {
await auth.signOut();
navigate('/auth');
}
await auth.signOut();
navigate('/auth');
};
return (
<S.MenuList>
<S.MenuItem>
<Link to="/profile">
<IconUser />
</Link>
</S.MenuItem>
<S.MenuItem>
<Link to="/">
<IconHome />
</Link>
</S.MenuItem>
<S.MenuItem onClick={onLogout} className="log-out">
<IconLogout />
</S.MenuItem>
</S.MenuList>
<W.Window as="nav">
<WindowTop />
<S.Logo>
<S.LogoTitle>
<span>Z</span>witter
</S.LogoTitle>
<S.LogoImage src={ImageComputer}></S.LogoImage>
</S.Logo>
<S.MenuList>
<S.MenuItem>
<Link to="/">
<IconHome /> ํ™ˆ
</Link>
</S.MenuItem>
<S.MenuItem>
<Link to="/profile">
<IconUser /> ํ”„๋กœํ•„
</Link>
</S.MenuItem>
<S.MenuItem>
<S.Button onClick={toggleLogoutPopup}>
<IconLogout /> ๋กœ๊ทธ์•„์›ƒ
</S.Button>
</S.MenuItem>
{logoutPopup ? (
<P.PopupWrapper>
<P.MiniPopup>
<P.Text>๋กœ๊ทธ์•„์›ƒ ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?</P.Text>
<P.ButtonWrapper>
<P.Button onClick={onLogout} type="button">
์˜ˆ
</P.Button>
<P.Button onClick={toggleLogoutPopup} type="button">
์•„๋‹ˆ์š”
</P.Button>
</P.ButtonWrapper>
</P.MiniPopup>
</P.PopupWrapper>
) : null}
</S.MenuList>
</W.Window>
);
}
2 changes: 1 addition & 1 deletion src/components/post-tweet-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { addDoc, collection, updateDoc } from 'firebase/firestore';
import { getDownloadURL, ref, uploadBytes } from 'firebase/storage';
import { auth, db, storage } from '../firebase.ts';
import * as S from '../styles/components/post-tweet-form.ts';
import * as S from '../styles/post-tweet-form.ts';
import { ReactComponent as IconPhoto } from '../assets/images/i-photo.svg';

export default function PostTweetForm() {
Expand Down
33 changes: 33 additions & 0 deletions src/components/search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react';
import WindowTop from './window-top.tsx';
import * as W from '../styles/window.ts';
import * as S from '../styles/search.ts';
import LoadingScreen from './loading-screen.tsx';

export default function Search() {
const [error, setError] = useState('');
const [isLoading, setLoading] = useState(false);
const [searchKeyword, setSearchKeyword] = useState('');
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchKeyword(e.target.value);
};
return isLoading ? (
<LoadingScreen />
) : (
<W.Window>
<WindowTop />
<S.Form>
<S.FormInput
onChange={onChange}
name="searchKeyword"
value={searchKeyword}
placeholder="๊ฒ€์ƒ‰ํ•˜๊ธฐ"
type="text"
required
></S.FormInput>
<button type="submit">๊ฒ€์ƒ‰</button>
{error ? <p>{error}</p> : null}
</S.Form>
</W.Window>
);
}
6 changes: 3 additions & 3 deletions src/components/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { Unsubscribe } from 'firebase/auth';
import { db } from '../firebase.ts';
import Tweet from './tweet.tsx';
import * as S from '../styles/layout.ts';
import TimelineWrapper from '../styles/timeline.ts';
import ITweet from '../interfaces/ITweet.ts';

export default function Timeline() {
Expand Down Expand Up @@ -45,10 +45,10 @@ export default function Timeline() {
};
}, []);
return (
<S.TimeLineWrapper>
<TimelineWrapper>
{tweets.map((tweet) => (
<Tweet key={tweet.id} {...tweet} />
))}
</S.TimeLineWrapper>
</TimelineWrapper>
);
}
2 changes: 1 addition & 1 deletion src/components/tweet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { deleteObject, ref } from 'firebase/storage';
import { auth, db, storage } from '../firebase.ts';
import ITweet from '../interfaces/ITweet.ts';
import FormattedDate from '../utils/formattedDate.tsx';
import * as S from '../styles/components/tweet.ts';
import * as S from '../styles/tweet.ts';

export default function Tweet({
id,
Expand Down
6 changes: 3 additions & 3 deletions src/components/user-timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'firebase/firestore';
import { auth, db } from '../firebase.ts';
import Tweet from './tweet.tsx';
import * as S from '../styles/layout.ts';
import TimelineWrapper from '../styles/timeline.ts';
import ITweet from '../interfaces/ITweet.ts';

export default function UserTimeline() {
Expand Down Expand Up @@ -40,10 +40,10 @@ export default function UserTimeline() {
fetchTweets();
}, []);
return (
<S.UserTimeLineWrapper>
<TimelineWrapper>
{tweets.map((tweet) => (
<Tweet key={tweet.id} {...tweet} />
))}
</S.UserTimeLineWrapper>
</TimelineWrapper>
);
}
16 changes: 16 additions & 0 deletions src/components/window-top.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as W from '../styles/window.ts';
import { ReactComponent as IconWindow1 } from '../assets/images/i-window1.svg';
import { ReactComponent as IconWindow2 } from '../assets/images/i-window2.svg';
import { ReactComponent as IconWindow3 } from '../assets/images/i-window3.svg';

export default function WindowTop() {
return (
<W.TopBar>
<W.IconWrapper>
<IconWindow1 />
<IconWindow2 />
<IconWindow3 />
</W.IconWrapper>
</W.TopBar>
);
}
8 changes: 5 additions & 3 deletions src/routes/home.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import WindowTop from '../components/window-top.tsx';
import PostTweetForm from '../components/post-tweet-form.tsx';
import Timeline from '../components/timeline.tsx';
import * as S from '../styles/layout.ts';
import * as W from '../styles/window.ts';

export default function Home() {
return (
<S.HomeCenterWrapper>
<W.Window>
<WindowTop />
<PostTweetForm />
<Timeline />
</S.HomeCenterWrapper>
</W.Window>
);
}
29 changes: 17 additions & 12 deletions src/routes/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useState } from 'react';
import { getDownloadURL, ref, uploadBytes } from 'firebase/storage';
import { updateProfile } from 'firebase/auth';
import { auth, storage } from '../firebase.ts';
import WindowTop from '../components/window-top.tsx';
import UserTimeline from '../components/user-timeline.tsx';
import * as W from '../styles/window.ts';
import * as S from '../styles/profile.ts';
import { ReactComponent as IconUser } from '../assets/images/i-user.svg';

Expand All @@ -24,18 +26,21 @@ export default function Profile() {
}
};
return (
<S.Wrapper>
<S.AvatarUpload htmlFor="avatar">
{avatar ? <S.AvatarImage src={avatar} /> : <IconUser />}
</S.AvatarUpload>
<S.AvatarInput
onChange={onAvatarChange}
id="avatar"
type="file"
accept="image/*"
/>
<S.Name>{user?.displayName ?? 'Anonymous'}</S.Name>
<W.Window>
<WindowTop />
<S.Avatar>
<S.AvatarUpload htmlFor="avatar">
{avatar ? <S.AvatarImage src={avatar} /> : <IconUser />}
</S.AvatarUpload>
<S.AvatarInput
onChange={onAvatarChange}
id="avatar"
type="file"
accept="image/*"
/>
<S.Name>{user?.displayName ?? 'Anonymous'}</S.Name>
</S.Avatar>
<UserTimeline />
</S.Wrapper>
</W.Window>
);
}
3 changes: 3 additions & 0 deletions src/routes/search-result.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function SearchResult() {
return null;
}
10 changes: 4 additions & 6 deletions src/styles/App.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { createGlobalStyle, styled } from 'styled-components';
import { createGlobalStyle } from 'styled-components';
import reset from 'styled-reset';

export const primaryColor = '#FF7AB2';
export const grayColor = '#A7A7A7';
export const blackColor = '#070707';
export const whiteColor = '#FAFAFA';

export const Wrapper = styled.div`
display: flex;
justify-content: center;
height: 100vh;
`;
export const LogoTextShadow = (offset: number) =>
`${-offset}px 0px ${blackColor}, 0px ${offset}px ${blackColor}, ${offset}px 0px ${blackColor}, 0px ${-offset}px ${blackColor}`;

export const GlobalStyles = createGlobalStyle`
${reset};
Expand All @@ -34,6 +31,7 @@ export const GlobalStyles = createGlobalStyle`
}
button {
cursor: pointer;
transition: all 0.5s ease;
&:hover,
&:active {
opacity: 0.8;
Expand Down
8 changes: 2 additions & 6 deletions src/styles/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from 'styled-components';
import { blackColor, primaryColor, whiteColor } from './App.ts';
import { LogoTextShadow, blackColor, primaryColor, whiteColor } from './app.ts';
import { LineButton, SolidButton, Input } from './button.ts';

export const Wrapper = styled.div`
Expand Down Expand Up @@ -28,11 +28,7 @@ export const Image = styled.img`
export const Intro = styled.h2`
font-size: 64px;
color: ${whiteColor};
text-shadow:
-3px 0px ${blackColor},
0px 3px ${blackColor},
3px 0px ${blackColor},
0px -3px ${blackColor};
text-shadow: ${LogoTextShadow(3)};
span {
color: ${primaryColor};
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/button.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from 'styled-components';
import { blackColor, grayColor, primaryColor, whiteColor } from './App.ts';
import { blackColor, grayColor, primaryColor, whiteColor } from './app.ts';

const Button = styled.button`
width: 100%;
Expand Down
Loading

0 comments on commit 453ec15

Please sign in to comment.