Skip to content

Commit

Permalink
Merge pull request #266 from boostcampwm2023/develop
Browse files Browse the repository at this point in the history
[Deploy] Week5 Ver5 배포
  • Loading branch information
bananaba authored Dec 6, 2023
2 parents f07fa96 + bf3d1c9 commit ac2144b
Show file tree
Hide file tree
Showing 35 changed files with 391 additions and 53 deletions.
12 changes: 7 additions & 5 deletions packages/client/src/app/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import {
createBrowserRouter,
createRoutesFromElements,
} from 'react-router-dom';
import Home from '../pages/Home';
import Landing from '../pages/Landing';
import { WritingModal } from 'features/writingModal';
import LoginModal from 'widgets/loginModal';
import Home from '../pages/Home/Home';
import Landing from '../pages/Landing/Landing';
import { WritingModal } from 'features/writingModal/WritingModal';
import LoginModal from 'widgets/loginModal/LoginModal';
import SignUpModal from 'widgets/signupModal/SignUpModal';
import NickNameSetModal from 'widgets/nickNameSetModal/NickNameSetModal';
import LogoAndStart from 'widgets/logoAndStart';
import LogoAndStart from 'widgets/logoAndStart/LogoAndStart';
import { PostModal } from 'features/postModal';
import GalaxyCustomModal from 'widgets/galaxyCustomModal/GalaxyCustomModal';
import StarCustomModal from 'widgets/starCustomModal/StarCustomModal';
import ShareModal from 'widgets/shareModal/ShareModal';

export const router = createBrowserRouter(
createRoutesFromElements(
Expand All @@ -33,6 +34,7 @@ export const router = createBrowserRouter(
<Route path="writing" element={<WritingModal />} />
<Route path="galaxy-custom" element={<GalaxyCustomModal />} />
<Route path="star-custom" element={<StarCustomModal />} />
<Route path="share" element={<ShareModal />} />
</Route>
</>,
),
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/assets/icon-check-purple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/client/src/entities/posts/apis/getMyPost.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import instance from 'shared/apis/AxiosInterceptor';

export const getMyPost = async () => {
const { data } = await instance({
method: 'GET',
url: '/star',
});
return data;
};
2 changes: 1 addition & 1 deletion packages/client/src/entities/posts/ui/Post.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Star from 'features/star';
import { useRef } from 'react';
import { useCameraStore } from 'shared/store/useCameraStore';
import { ThreeEvent } from '@react-three/fiber';
Expand All @@ -10,6 +9,7 @@ import { StarType } from 'shared/lib/types/star';
import { useNavigate } from 'react-router-dom';
import { useState } from 'react';
import theme from 'shared/ui/styles/theme';
import Star from 'features/star/Star';

interface PropsType {
data: StarType;
Expand Down
11 changes: 6 additions & 5 deletions packages/client/src/entities/posts/ui/Posts.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { useFetch } from 'shared/hooks';
import Post from './Post';
import { useState } from 'react';
import { StarData } from 'shared/lib/types/star';
import { useOwnerStore } from 'shared/store/useOwnerStore';
import { getPostListByNickName } from 'shared/apis/star';
import { useEffect } from 'react';
import { useViewStore } from 'shared/store';
import { getMyPost } from '../apis/getMyPost';

export default function Posts() {
const [postData, setPostData] = useState<StarData[]>();

const { isMyPage, pageOwnerNickName } = useOwnerStore();
const { view } = useViewStore();

const myPostData = useFetch<StarData[]>('star').data;

useEffect(() => {
if (view !== 'MAIN') return;

if (isMyPage) {
setPostData(myPostData);
(async () => {
const myPostData = await getMyPost();
setPostData(myPostData);
})();
return;
}

(async () => {
const otherPostData = await getPostListByNickName(pageOwnerNickName);
setPostData(otherPostData);
})();
}, [isMyPage, myPostData, view]);
}, [isMyPage, view]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/features/controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Controls() {

useFrame((state, delta) => {
const targetPosition = new THREE.Vector3(0, 0, 0);
const LENGTH_LIMIT = 1000 * delta;
const LENGTH_LIMIT = (cameraToCurrentView * delta) / 2;

if (targetView) targetView.getWorldPosition(targetPosition);
if (view === 'POST') {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/client/src/features/star/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const DISTANCE_LIMIT = 3000;
export const DISTANCE_LIMIT = 5000;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Screen from 'widgets/screen';
import Screen from 'widgets/screen/Screen';
import { useViewStore } from 'shared/store/useViewStore';
import { Outlet, useNavigate } from 'react-router-dom';
import UnderBar from 'shared/ui/underBar/UnderBar';
import UpperBar from './ui/UpperBar';
import UnderBar from 'widgets/underBar/UnderBar';
import UpperBar from '../../widgets/upperBar/UpperBar';
import WarpScreen from 'widgets/warpScreen/WarpScreen';
import { useEffect, useState } from 'react';
import instance from 'shared/apis/AxiosInterceptor';
Expand Down Expand Up @@ -32,21 +32,19 @@ export default function Home() {
const { setSpiral, setStart, setThickness, setZDist } = useGalaxyStore();

useEffect(() => {
const checkLogin = async () => {
(async () => {
try {
const res = await instance({
method: 'GET',
url: `/auth/check-signin`,
});
if (res.status !== 200) {
navigate('/login');
}

if (res.status !== 200) navigate('/login');
} catch (error) {
console.error(error);
navigate('/login');
}
};
checkLogin();
})();

getSignInInfo().then((res) => {
Cookies.set('nickname', res.nickname);
setNickname(res.nickname);
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/pages/Home/ui/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LandingScreen from 'widgets/landingScreen';
import LandingScreen from 'widgets/landingScreen/LandingScreen';
import { useState } from 'react';
import { useToastStore } from 'shared/store/useToastStore';
import { Toast } from 'shared/ui';
Expand Down
Empty file.
3 changes: 1 addition & 2 deletions packages/client/src/shared/apis/login.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios, { AxiosError } from 'axios';
import Cookies from 'js-cookie';
import { NavigateFunction } from 'react-router-dom';
import { useScreenSwitchStore } from 'shared/store/useScreenSwitchStore';
import instance from './AxiosInterceptor';

axios.defaults.withCredentials = true;
Expand All @@ -14,6 +13,7 @@ export const postLogin = async (
setIdState: React.Dispatch<React.SetStateAction<boolean>>,
setPasswordState: React.Dispatch<React.SetStateAction<boolean>>,
navigate: NavigateFunction,
setIsSwitching: (value: boolean) => void,
) => {
try {
await instance({
Expand All @@ -23,7 +23,6 @@ export const postLogin = async (
});
Cookies.set('userId', data.username, { path: '/', expires: 7 });
navigate('/home');
const { setIsSwitching } = useScreenSwitchStore();
setIsSwitching(true);
} catch (err) {
if (err instanceof AxiosError) {
Expand Down
22 changes: 22 additions & 0 deletions packages/client/src/shared/apis/share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import instance from './AxiosInterceptor';

export const getShareLink = async (nickName: string) => {
const { data } = await instance({
method: 'GET',
url: `/auth/sharelink?nickname=${nickName}`,
});

return data;
};

export const patchShareStatus = async (status: 'private' | 'public') => {
const { data } = await instance({
method: 'PATCH',
url: `/auth/status`,
data: {
status,
},
});

return data;
};
2 changes: 1 addition & 1 deletion packages/client/src/shared/store/useViewStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { create } from 'zustand';

type view = 'MAIN' | 'DETAIL' | 'POST' | 'WRITING' | 'CUSTOM';
type view = 'MAIN' | 'DETAIL' | 'POST' | 'WRITING' | 'CUSTOM' | 'SHARE';

interface ViewState {
view: view;
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/shared/ui/inputBar/index.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/client/src/widgets/galaxy/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const STARS_NUM = 10000;
export const STARS_NUM = 6000;

export const DISTANCE_LIMIT = 3000;

Expand Down
48 changes: 48 additions & 0 deletions packages/client/src/widgets/galaxyCustomModal/GalaxyCustom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Modal } from 'shared/ui';
import { useNavigate } from 'react-router-dom';
import { RightButton, SampleScreen, Sliders } from './ui';
import { useViewStore } from 'shared/store';
import styled from '@emotion/styled';
import { useGalaxyStore, useCustomStore } from 'shared/store';

export default function GalaxyCustom() {
const navigate = useNavigate();
const { setView } = useViewStore();
const { setSpiral, setStart, setThickness, setZDist } = useGalaxyStore();
const { spiral, start, thickness, zDist } = useCustomStore();

const handleSubmit = () => {
setSpiral(spiral);
setStart(start);
setThickness(thickness);
setZDist(zDist);
};

return (
<form
onSubmit={(e) => {
e.preventDefault();
handleSubmit();
}}
>
<Modal
title="은하 커스텀"
onClickGoBack={() => {
navigate('/home');
setView('MAIN');
}}
rightButton={<RightButton />}
>
<Container>
<SampleScreen />
<Sliders />
</Container>
</Modal>
</form>
);
}

const Container = styled.div`
display: flex;
gap: 24px;
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Canvas } from '@react-three/fiber';
import BackgroundStars from 'features/backgroundStars';
import { Galaxy } from '../galaxy';
import BackgroundStars from 'features/backgroundStars/BackgroundStars.tsx';
import { Galaxy } from '../galaxy/index.ts';
import { EffectComposer, Bloom } from '@react-three/postprocessing';
import { CAMERA_POSITION, CAMERA_UP, CAMERA_FAR } from './lib/camera.ts';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import Cookies from 'js-cookie';
import { useState } from 'react';
import { postLogin } from 'shared/apis';
import { useCheckLogin } from 'shared/hooks';
import { useScreenSwitchStore } from 'shared/store/useScreenSwitchStore';

export default function LoginModal() {
const [id, setId] = useState(Cookies.get('userId') ?? '');
const [idState, setIdState] = useState(true);
const [password, setPassword] = useState('');
const [passwordState, setPasswordState] = useState(true);
const navigate = useNavigate();
const { setIsSwitching } = useScreenSwitchStore();

const isValid = () => {
return id.length && password.length && idState && passwordState;
Expand All @@ -24,7 +26,13 @@ export default function LoginModal() {
password: password,
};
setPassword('');
await postLogin(data, setIdState, setPasswordState, navigate);
await postLogin(
data,
setIdState,
setPasswordState,
navigate,
setIsSwitching,
);
};

useCheckLogin();
Expand Down
7 changes: 4 additions & 3 deletions packages/client/src/widgets/loginModal/ui/OauthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ export default function OauthLogin() {
return (
<Container>
<a href={NAVER_AUTH_URL}>
<img src={NaverLogo} />
<img src={NaverLogo} alt="네이버로 로그인" />
</a>
<a href={GITHUB_AUTH_URL}>
<img src={GithubLogo} />
<img src={GithubLogo} alt="깃허브로 로그인" />
</a>
<a href={GOOGLE_AUTH_URL}>
<img src={GoogleLogo} />
<img src={GoogleLogo} alt="구글로 로그인" />
</a>
</Container>
);
}

const Container = styled.div`
margin: 20px 0 0 0;
display: flex;
justify-content: space-evenly;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Canvas } from '@react-three/fiber';
import BackgroundStars from 'features/backgroundStars';
import BackgroundStars from 'features/backgroundStars/BackgroundStars';
import { Galaxy } from '../galaxy';
import { EffectComposer, Bloom } from '@react-three/postprocessing';
import { Leva, useControls } from 'leva';
Expand All @@ -9,6 +9,7 @@ import { useCameraStore } from 'shared/store/useCameraStore.ts';
import { Posts } from 'entities/posts';
import styled from '@emotion/styled';
import { useViewStore } from 'shared/store';
import { CameraLight } from './ui';

export default function Screen() {
const { view } = useViewStore();
Expand All @@ -24,7 +25,7 @@ export default function Screen() {
mipmapBlur: { value: false },
});
const { wheelSpeed } = useControls('Controls', {
wheelSpeed: { value: 3, min: 0.1, max: 5, step: 0.01 },
wheelSpeed: { value: 3, min: 0.1, max: 30, step: 0.1 },
});

return (
Expand All @@ -45,11 +46,12 @@ export default function Screen() {
</EffectComposer>

<color attach="background" args={['#070614']} />
<ambientLight color="#fff" intensity={5} />
<ambientLight color="#fff" intensity={2} />
<Controls />
<BackgroundStars />
<Galaxy />
<Posts />
<CameraLight />
</Canvas>
<LevaWrapper>
<Leva fill collapsed hidden={view !== 'MAIN'} />
Expand Down
16 changes: 16 additions & 0 deletions packages/client/src/widgets/screen/ui/CameraLight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useRef } from 'react';
import { useFrame } from '@react-three/fiber';
import { Group, Object3DEventMap } from 'three';

export default function CameraLight() {
const lightRef = useRef<Group<Object3DEventMap>>(null!);

useFrame((state) => {
lightRef.current.position.copy(state.camera.position);
});
return (
<group ref={lightRef}>
<directionalLight intensity={3} />
</group>
);
}
1 change: 1 addition & 0 deletions packages/client/src/widgets/screen/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as CameraLight } from './CameraLight';
Loading

0 comments on commit ac2144b

Please sign in to comment.