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

[ 7์ฃผ์ฐจ-TS/Recoil] โค๏ธ๐Ÿ’›๐Ÿ’š ์งฑ๊ตฌ๋Š” ๋ชป๋ง๋ ค! ๐Ÿ’š๐Ÿ’›โค๏ธ #9

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion week3/Zzangu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div id="root"></div>
<div id="modal"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/src/main.tsx" crossorigin></script>
</body>

</html>
2 changes: 2 additions & 0 deletions week3/Zzangu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"preview": "vite preview"
},
"dependencies": {
"@types/recoil": "^0.0.9",
"@types/styled-components": "^5.1.26",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"recoil": "^0.7.7",
"styled-components": "^5.3.10",
"styled-reset": "^4.4.6"
},
Expand Down
3 changes: 2 additions & 1 deletion week3/Zzangu/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ThemeProvider } from 'styled-components';

import Game from './pages/Game';
import GlobalStyle from './styles/GlobalStyle';
import theme from './styles/theme';
import Game from './pages/Game';

function App() {
return (
Expand Down
136 changes: 136 additions & 0 deletions week3/Zzangu/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import styled, { css } from 'styled-components';

interface ButtonProps {
onClick: () => void;
children: string;
isReset?: boolean;
}

export const Button = ({ onClick, children, isReset }: ButtonProps) => (
<StButton type='button' onClick={onClick} isReset={isReset}>
{children}
</StButton>
);

const StButton = styled.button<{ isReset?: boolean }>`
padding: 1rem 2rem;
${({ theme }) => theme.fonts.ZZangu_Button2};

color: ${({ theme }) => theme.colors.Zzangu_PinkBorder};
background: ${({ theme }) => theme.colors.Zzangu_LightPink};
border: 0.2rem solid ${({ theme }) => theme.colors.Zzangu_PinkBorder};
border-radius: 1.5rem;
transform-style: preserve-3d;
transition: transform 150ms cubic-bezier(0, 0, 0.58, 1);

&::before {
content: '';

position: absolute;
top: 0;
left: 0;

width: 100%;
height: 100%;

background: ${({ theme }) => theme.colors.Zzangu_DarkPink};
border-radius: inherit;
box-shadow: 0 0 0 0.2rem ${({ theme }) => theme.colors.Zzangu_PinkBorder};

transform: translate3d(0, 0.75rem, -1rem);
transition: transform 150ms cubic-bezier(0, 0, 0.58, 1),
box-shadow 150ms cubic-bezier(0, 0, 0.58, 1);
}

&:hover {
background: ${({ theme }) => theme.colors.Zzangu_Pink};
transform: translate(0, 0.25em);

&::before {
box-shadow: 0 0 0 0.2rem ${({ theme }) => theme.colors.Zzangu_PinkBorder},
0 0.5rem 0 0 ${({ theme }) => theme.colors.Zzangu_PinkShadow};
transform: translate3d(0, 0.5rem, -1rem);
}
}

&:active {
background: ${({ theme }) => theme.colors.Zzangu_Pink};
transform: translate(0rem, 0.75rem);

&::before {
box-shadow: 0 0 0 0.2rem ${({ theme }) => theme.colors.Zzangu_PinkBorder},
0 0 ${({ theme }) => theme.colors.Zzangu_PinkShadow};
transform: translate3d(0, 0, -1em);
}
}

${({ isReset }) =>
isReset &&
css`
position: absolute;
right: 11%;
overflow: hidden;
z-index: 10;

padding: 1rem 4rem;

color: ${({ theme }) => theme.colors.Zzangu_YellowBorder};
background: ${({ theme }) => theme.colors.Zzangu_Yellow};
${({ theme }) => theme.fonts.ZZangu_Button1};
border: 0.3rem solid ${({ theme }) => theme.colors.Zzangu_YellowBorder};
border-radius: 5rem;

transition: all 0.3s ease-in-out;

&:hover {
border: 0.1rem solid ${({ theme }) => theme.colors.Zzangu_YellowBorder};
color: ${({ theme }) => theme.colors.Zzangu_White};
}
&::before {
content: '';
display: block;
position: absolute;
top: -11%;
left: -10%;
z-index: -12;
opacity: 1;

width: 0%;
height: 100%;

background: ${({ theme }) => theme.colors.Zzangu_YellowBorder};

transform: skewX(-20deg);
transition: all 0.7s cubic-bezier(0.77, 0, 0.175, 1);
box-shadow: 0.2rem 0rem 1.4rem rgba(0, 0, 0, 0.6);
}
&::after {
content: '';
display: block;
position: absolute;
top: 0;
left: -10%;
z-index: -15;
opacity: 0;

width: 0%;
height: 100%;

background: ${({ theme }) => theme.colors.Zzangu_White};

transform: skewX(-20deg);
transition: all 0.4s cubic-bezier(0.2, 0.95, 0.57, 0.99);
box-shadow: 0.2rem, 0rem 1.4rem rgba(0, 0, 0, 0.6);
}
&:hover::before {
opacity: 1;

width: 116%;
}
&:hover::after {
opacity: 1;

width: 120%;
}
`}
`;
1 change: 0 additions & 1 deletion week3/Zzangu/src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled, { css } from 'styled-components';

import { ImgZzanguBack } from '../assets/images';
Expand Down
12 changes: 6 additions & 6 deletions week3/Zzangu/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';

interface HeaderProps {
mode: number;
score: number;
}
import { ModeState, ScoreState } from '../recoil/atom';

const Header = () => {
const mode = useRecoilValue(ModeState);
const score = useRecoilValue(ScoreState);

const Header = ({ mode, score }: HeaderProps) => {
return (
<StHeader>
<h1>์งฑ๊ตฌ๋Š” ๋ชป๋ง๋ ค!</h1>
Expand Down
1 change: 0 additions & 1 deletion week3/Zzangu/src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { createPortal } from 'react-dom';
import styled from 'styled-components';

Expand Down
3 changes: 3 additions & 0 deletions week3/Zzangu/src/datas/mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const EASY_MODE = 5;
export const NORMAL_MODE = 7;
export const HARD_MODE = 9;
6 changes: 5 additions & 1 deletion week3/Zzangu/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { RecoilRoot } from 'recoil';

import App from './App.tsx';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
<RecoilRoot>
<App />
</RecoilRoot>
</React.StrictMode>,
);
Loading