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

[4์ฃผ์ฐจ-TS] ๐ŸŽค๋…ธ์ธ์ฝ”๋ž˜๋ฐฉ๐ŸŽค #7

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
b3347a6
init: ์ดˆ๊ธฐ ์„ธํŒ…
leeseooo Jun 23, 2022
38b80a5
chore: ํด๋” ๊ตฌ์กฐ ์„ธํŒ…
leeseooo Jun 23, 2022
24b583c
chore: ์Šคํƒ€์ผ ๋ฐ ํƒ€์ž… ํด๋” ์ƒ์„ฑ, ์ „์—ญ ์Šคํƒ€์ผ ์ถ”๊ฐ€
leeseooo Jun 23, 2022
f965535
feat: ๊ฒ€์ƒ‰ ์„น์…˜ ๊ตฌํ˜„
leeseooo Jun 23, 2022
19a0b9f
feat: ์ง€์—ญ๊ธฐ๋ฐ˜ ๊ฒ€์ƒ‰ api ์—ฐ๊ฒฐ
leeseooo Jun 23, 2022
b7cce01
feat: ๊ฒ€์ƒ‰๊ฒฐ๊ณผ ํŽ˜์ด์ง€ ๊ตฌํ˜„
leeseooo Jun 23, 2022
795497d
chore: ์ง€์—ญ๊ธฐ๋ฐ˜๊ฒ€์ƒ‰ ์‘๋‹ต data.documents ์˜คํƒ€์ˆ˜์ •
leeseooo Jun 23, 2022
61fe632
feat: ์Šค์ผˆ๋ ˆํ†ค UI ์ถ”๊ฐ€
leeseooo Jun 23, 2022
a906ab3
feat: ๋™๋„ค ๊ธฐ๋ฐ˜ ์œ„์น˜๊ฒ€์ƒ‰ api ์ถ”๊ฐ€
leeseooo Jun 23, 2022
8e6d000
feat: ์นด๋“œ ์ปดํฌ๋„ŒํŠธ๋ถ„๋ฆฌ ๋ฐ ๊ตฌํ˜„
leeseooo Jun 23, 2022
b28ed64
chore: ์ฒดํฌ๋ฐ•์Šค ์ฒดํฌ ์‹œ ๊ฒ€์ƒ‰์ฐฝ ์ดˆ๊ธฐํ™”
leeseooo Jun 23, 2022
39bb6b0
chore: ๊ฒ€์ƒ‰๊ฒฐ๊ณผ ์—†์Œ ์ฒ˜๋ฆฌ ์ถ”๊ฐ€
leeseooo Jun 24, 2022
c910b98
chore: ์ง€์—ญ๊ธฐ๋ฐ˜์ผ ๋•Œ ๊ฑฐ๋ฆฌ ํ‘œ์ถœ
leeseooo Jun 24, 2022
332b879
chore: ๊ฒฐ๊ณผ ์ถœ๋ ฅ ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋กœ ์ˆ˜์ •
leeseooo Jun 24, 2022
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
25 changes: 25 additions & 0 deletions week4-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.env.local
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions week4-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions week4-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "week4-ts",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@types/styled-components": "^5.1.25",
Comment on lines +10 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํƒ€์ž… ๊ด€๋ จ ์˜์กด์„ฑ์€ ๊ฐœ๋ฐœํ™˜๊ฒฝ์—์„œ ํ•„์š”ํ•˜๊ธฐ ๋–„๋ฌธ์— devDependencies ์— ์„ ์–ธํ•ด์ฃผ์–ด๋„ ์ข‹์•„

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ํ•˜ ์˜คํ‚ค์˜คํ‚ค

"axios": "^0.27.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"styled-components": "^5.3.5",
"styled-reset": "^4.4.1"
},
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@vitejs/plugin-react": "^1.3.0",
"typescript": "^4.6.3",
"vite": "^2.9.9"
}
}
10 changes: 10 additions & 0 deletions week4-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import GlobalStyle from "./styles/global";
import MainPage from "./pages/MainPage";
export default function App() {
return (
<>
<GlobalStyle />
<MainPage />
</>
);
}
31 changes: 31 additions & 0 deletions week4-ts/src/components/ResultSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Store } from "../types";
import Skeleton from "../components/Skeleton";
import StoreCard from "./StoreCard";

interface ResultSectionProps {
storeInfo: Store[];
isCheck: boolean;
isLoading: boolean;
}

export default function ResultSection({
storeInfo,
isCheck,
isLoading,
}: ResultSectionProps) {
return (
<>
Comment on lines +11 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ปจ๋ฒค์…˜ ์ฐจ์ด์ด์ง€๋งŒ, ์•„๋ž˜์ฒ˜๋Ÿผ ์„ ์–ธํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค! ๊ฐ€๋…์„ฑ์ด ์ข‹๋‹ค๋Š” ์˜๊ฒฌ์ด ์žˆ๋˜ ๊ฒƒ ๊ฐ™์•„์š”,, ๋Š” ์ฃผํ•จ

Suggested change
export default function ResultSection({
storeInfo,
isCheck,
isLoading,
}: ResultSectionProps) {
return (
<>
export default function ResultSection(props: ResultSectionProps) {
const {storeInfo, isCheck, isLoading} = props
return (
<>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜ค..ํ›จ์”ฌ ๋ณด๊ธฐ ํŽธํ•˜๋„ค์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

{isLoading &&
new Array(10).fill(1).map((_, idx) => {
return <Skeleton key={idx} />;
})}
{!isLoading && storeInfo.length === 0 ? (
<div style={{ color: "#fff" }}>๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</div>
) : (
storeInfo?.map((store: Store, idx: number) => (
<StoreCard key={idx} store={store} isCheck={isCheck} />
))
)}
Comment on lines +18 to +28

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜ค ๊ฐœ์ธ์ ์œผ๋กœ ์ค‘์ฒฉ ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋ณด๋‹ค &&์™€ ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋ฅผ ํ•จ๊ป˜ ์“ด ์ด ๋ฐฉ์‹์ด ํ™•์‹คํžˆ ์ข€ ๋” ๊ฐ€๋…์„ฑ ์ข‹์€ ๋ฐฉ์‹์ธ ๊ฑฐ ๊ฐ™์•„์š”!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ณดํŽธ์ ์œผ๋กœ ๋งŽ์ด ์“ฐ์ด๋Š” eslint airbnb js ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ์— ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฃฐ์ด ์žˆ๋Š”๋ฐ ํ•œ ๋ฒˆ ์ฝ์–ด๋ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”! (๋ฌผ๋ก  ์ด ๊ฐ€์ด๋“œ๋Š” ์ ˆ๋Œ€ ์ •๋‹ต์ด ์•„๋‹ˆ๊ณ  ํ˜‘์—…ํ•  ๋•Œ๋งˆ๋‹ค ๋‹ค๋ฅธ lint๋ฃฐ์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋  ๊ฑฐ๋ผ ์ •๋ง ์ฐธ๊ณ ์šฉ์ž…๋ฏธ๋‹ค ! )
image
https://github.com/parksb/javascript-style-guide

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฐธ๊ณ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๊ณ ๋งˆ์›Œ์š”!!

Comment on lines +18 to +28

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{isLoading &&
new Array(10).fill(1).map((_, idx) => {
return <Skeleton key={idx} />;
})}
{!isLoading && storeInfo.length === 0 ? (
<div style={{ color: "#fff" }}>๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</div>
) : (
storeInfo?.map((store: Store, idx: number) => (
<StoreCard key={idx} store={store} isCheck={isCheck} />
))
)}
if(isLoading) {
new Array(10).fill(1).map((_, idx) => {
return <Skeleton key={idx} />;
})
} else {
return (
<>
{storeInfo.length === 0 ? (
<div style={{ color: "#fff" }}>๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</div>
) : (
storeInfo?.map((store: Store, idx: number) => (
<StoreCard key={idx} store={store} isCheck={isCheck} />
))
)}
</>
)
}

ํ˜น์€ ์ด๋Ÿฐ ์‹์œผ๋กœ ์กฐ๊ฑด๋ถ€ ๋ Œ๋”๋ง์„ ํ•˜๋Š” ๋ฐฉ์‹๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์—ฌ !

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜น์€ ๋‚˜์ค‘์— ์„œ๋ฒ„์‚ฌ์ด๋“œ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ์ƒํƒœ๋ฅผ ๋กœ๋”ฉ ์ƒํƒœ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์—๋Ÿฌ ์ƒํƒœ๊นŒ์ง€ ํ™•์žฅ์‹œํ‚จ๋‹ค๋ฉด ์ด๋Ÿฐ ์‹์œผ๋กœ switch-case๋ฌธ์„ ์ด์šฉํ•œ ์กฐ๊ฑด๋ถ€๋ Œ๋”๋ง์„ ํ•  ์ˆ˜๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š” !

function Result({ isEmpty, keywordLocationData, status }: ResultProps) {
  switch (status) {
    case 'LOADING':
      return <Loading />;
    case 'ERROR':
      return <ErrorFallback />;
    default:
      return isEmpty ? <NoResult /> : <CardList keywordLocationData={keywordLocationData} />;
  }
}

๊ทผ๋ฐ ์‚ฌ์‹ค ์ด๊ฑฐ ๋‹ค ๊ฐ ์ทจ์ธ ์˜์—ญ์ด๋ผ ์ •๋‹ต์€ ์—†์–ด์„œ ๊ฐ ์ทจ๋Œ€๋กœ ๊ฐˆ๊ธฐ๋ฉด ๋  ๊ฑฐ ๊ฐ™๊ธด ํ•ด์—ฌ ใ…‹ ใ…‹

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ ์ €๋ ‡๊ฒŒ ํ•˜๋ฉด ๋˜๋Š”๊ตฌ๋‚˜ ใ…‹ใ…‹์ €๋Ÿฐ์‹์œผ๋กœ ๊ฐˆ๊ฒจ๋ณผ๊ฒŒ์—ฌ
switch๋ฌธ ์ƒํƒœ ์ฒ˜๋ฆฌ ์ฝ”๋“œ๋„ ์ฐธ๊ณ ํ• ๊ฒŒ์š” ๊ฐ์‚ผ๋‹ท!

</>
);
}
87 changes: 87 additions & 0 deletions week4-ts/src/components/SearchSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import styled from "styled-components";
import { useState, useEffect } from "react";

interface SearchSectionProps {
onClick: (isCheck: boolean, myTown: string) => void;
}

export default function SearchSection({ onClick }: SearchSectionProps) {
const [isCheck, setIsCheck] = useState<boolean>(false);
const [myTown, setMyTown] = useState<string>("");
Comment on lines +9 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state๋กœ input value๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์žˆ๋‹ค๋ฉด useInput๊ฐ™์€ ์ปค์Šคํ…€ ํ›…์„ ์ •์˜ํ•ด์„œ ์‚ฌ์šฉํ•ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ปค์Šคํ…€ ํ›…์— ๊ด€ํ•ด์„œ https://react.vlpt.us/basic/21-custom-hook.html ์ด๋Ÿฐ ์ž๋ฃŒ๋“ค ๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์—ฌ !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋ฒˆ ๊ธฐํšŒ์— ์ปค์Šคํ…€ ํ›…์„ ํ•œ ๋ฒˆ ์‹œ๋„ํ•ด๋ณผ๊ฒŒ์—ฌ


useEffect(() => {
if (isCheck) setMyTown("");
}, [isCheck]);

return (
<StWrapper>
<StCheckBoxWrapper>
<label htmlFor="checkbox">์ง€์—ญ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒ€์ƒ‰</label>
<input
type="checkbox"
id="checkbox"
onChange={() => setIsCheck(!isCheck)}
/>
</StCheckBoxWrapper>

<StTextInputWrapper>
<label htmlFor="text">์šฐ๋ฆฌ ๋™๋„ค๋Š” ์—ฌ๊ธฐ์—์š”</label>
<input
type="text"
placeholder="์ง€์—ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
Comment on lines +28 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธด id ์†์„ฑ์ด ๋น ์ง„ ๊ฒƒ ๊ฐ™๋„ค์š”??

Suggested change
<label htmlFor="text">์šฐ๋ฆฌ ๋™๋„ค๋Š” ์—ฌ๊ธฐ์—์š”</label>
<input
type="text"
placeholder="์ง€์—ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
<label htmlFor="text">์šฐ๋ฆฌ ๋™๋„ค๋Š” ์—ฌ๊ธฐ์—์š”</label>
<input
type="text"
id="text"
placeholder="์ง€์—ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์‹œ๋ ฅ 3.0์ด์„ธ์š”??

disabled={isCheck}
value={myTown}
onChange={(e) => setMyTown(e.target.value)}
/>
</StTextInputWrapper>

<StSearchButton type="button" onClick={() => onClick(isCheck, myTown)}>
๊ฒ€์ƒ‰ํ•˜๊ธฐ
</StSearchButton>
</StWrapper>
);
}

const StWrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px 0;
gap: 10px;
font-size: 20px;
color: #fff;
border-bottom: 2px solid #fff;
width: 100%;
`;
Comment on lines +16 to +56

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„ formํ…Œ๊ทธ๋กœ wrappingํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

Suggested change
return (
<StWrapper>
<StCheckBoxWrapper>
<label htmlFor="checkbox">์ง€์—ญ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒ€์ƒ‰</label>
<input
type="checkbox"
id="checkbox"
onChange={() => setIsCheck(!isCheck)}
/>
</StCheckBoxWrapper>
<StTextInputWrapper>
<label htmlFor="text">์šฐ๋ฆฌ ๋™๋„ค๋Š” ์—ฌ๊ธฐ์—์š”</label>
<input
type="text"
placeholder="์ง€์—ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
disabled={isCheck}
value={myTown}
onChange={(e) => setMyTown(e.target.value)}
/>
</StTextInputWrapper>
<StSearchButton type="button" onClick={() => onClick(isCheck, myTown)}>
๊ฒ€์ƒ‰ํ•˜๊ธฐ
</StSearchButton>
</StWrapper>
);
}
const StWrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px 0;
gap: 10px;
font-size: 20px;
color: #fff;
border-bottom: 2px solid #fff;
width: 100%;
`;
return (
<StForm onSubmit={(e) => onClick(isCheck, myTown, e)}>
<StCheckBoxWrapper>
<label htmlFor="checkbox">์ง€์—ญ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒ€์ƒ‰</label>
<input
type="checkbox"
id="checkbox"
onChange={() => setIsCheck(!isCheck)}
/>
</StCheckBoxWrapper>
<StTextInputWrapper>
<label htmlFor="text">์šฐ๋ฆฌ ๋™๋„ค๋Š” ์—ฌ๊ธฐ์—์š”</label>
<input
type="text"
placeholder="์ง€์—ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
disabled={isCheck}
value={myTown}
onChange={(e) => setMyTown(e.target.value)}
/>
</StTextInputWrapper>
<StSearchButton type="submit">
๊ฒ€์ƒ‰ํ•˜๊ธฐ
</StSearchButton>
</StForm>
);
}
const StForm = styled.form`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px 0;
gap: 10px;
font-size: 20px;
color: #fff;
border-bottom: 2px solid #fff;
width: 100%;
`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทผ๋ฐ form tag๋ฅผ ์“ฐ๊ณ  onSubmit์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉด ๋””ํดํŠธ๋กœ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ƒˆ๋กœ๊ณ ์นจํ•˜๋Š” ๋™์ž‘์„ ๋„ฃ์–ด๋ฒ„๋ ค์„œ onSubmit์ด๋ฒคํŠธ ๋‚ด๋ถ€์— ๋“ค์–ด์žˆ๋Š” ํ•จ์ˆ˜์—์„œ ๊ทธ๋Ÿฐ ๋ถˆํ•„์š”ํ•œ ๋””ํดํŠธ ๋™์ž‘์„ ๋ง‰์•„์ค˜์•ผ ํ•˜๋Š”๋ฐ (SPA์—์„œ ์ƒˆ๋กœ๊ณ ์นจ์€ ๋ถˆํ•„์š”ํ•œ ๋™์ž‘์ด๋‹ˆ๊นŒ์—ฌ !) ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด์„œ

  1. ์ผ๋‹จ event์ธ์ž๋ฅผ ๋ฐ›์•„์ฃผ๋„๋ก ์ˆ˜์ •ํ•˜๊ณ ,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ 7์ฃผ์ฐจ ๊ณผ์ œ์—์„œ ์ด๋Ÿฐ ์‹์œผ๋กœ ์งฐ์—ˆ๋Š”๋ฐ ์ด๊ฒƒ๋„ ๊ทธ๋ ‡๊ฒŒ ๋ฐ”๊ฟ”๋ณผ๊ฒŒ์š”!
์ด ๋ฐฉ๋ฒ•์ด ๋” ์ข‹์•„๋ณด์ด๋„ค์š”

const StCheckBoxWrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;
gap: 5px;
& > label {
color: #fff;
font-weight: bold;
}
`;
const StTextInputWrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
`;
const StSearchButton = styled.button`
border: none;
border-radius: 10px;
background-color: #fff;
color: #000;
font-weight: 700;

width: 70px;
height: 25px;

&:hover {
background-color: #828282;
color: #fff;
}
`;
72 changes: 72 additions & 0 deletions week4-ts/src/components/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import styled, { keyframes } from "styled-components";

function Skeleton() {
return (
<SkeletonWrapper>
<SkeletonTitle />
<SkeletonInfo>
<SkeletonPhone />
<SkeletonAddress />
</SkeletonInfo>
</SkeletonWrapper>
);
}

const loading = keyframes`
0% {
transform: translateX(0);
}
50%,100%{
transform:translateX(268px);
}
`;

const LoadingAnimation = styled.div`
overflow: hidden;
position: relative;
opacity: 0.5;

&::before {
content: "";
width: 20px;
height: 80px;
position: absolute;
background: linear-gradient(to right, #bdbdbd, #fff, #bdbdbd);
animation: ${loading} 1.5s infinite linear;
}
`;

const SkeletonWrapper = styled.li`
display: flex;
flex-direction: column;
height: 80px;
background-color: #fff;
border-radius: 10px;
`;

const SkeletonTitle = styled(LoadingAnimation)`
margin: 10px 0 20px 20px;
width: 90px;
height: 20px;
background-color: #bdbdbd;
`;

const SkeletonInfo = styled.div`
display: flex;
gap: 20px;
`;

const SkeletonPhone = styled(LoadingAnimation)`
width: 90px;
height: 20px;
margin-left: 20px;
background-color: #bdbdbd;
`;

const SkeletonAddress = styled(LoadingAnimation)`
width: 140px;
margin-right: 20px;
background-color: #bdbdbd;
`;

export default Skeleton;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํฌ. .. .์Šค์ผˆ๋ ˆํ†ค ๋ฉ‹์žˆ์–ด์—ฌ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ๋ธŒ์Šคํ†ค์ด ๋” ๋ฉ‹์žˆ์–ด์—ฌ

74 changes: 74 additions & 0 deletions week4-ts/src/components/StoreCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import styled from "styled-components";
import { Store } from "../types";

interface StoreCardProps {
store: Store;
isCheck: boolean;
}

export default function StoreCard({ store, isCheck }: StoreCardProps) {
const { place_url, place_name, phone, distance, address_name } = store;

return (
<StCard>
<a href={place_url || undefined}>{place_name}</a>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined ์˜ต์…”๋„์„ ๋ถ™์—ฌ์ค€ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค !!

Suggested change
<a href={place_url || undefined}>{place_name}</a>
<a href={place_url}>{place_name}</a>

API ์— place_url ์ด ์—†๋Š” ๊ฒƒ ๋–„๋ฌธ์ด๋ผ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์ž‘์„ฑํ•˜๋Š” ๊ฒŒ ๋” ๋ช…์‹œ์ ์ด์ง€ ์•Š์„๊นŒ ํ•ฉ๋‹ˆ๋‹ค! (css ์ฝ”๋“œ๊ฐ€ ์กฐ๊ธˆ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”,!)

Suggested change
<a href={place_url || undefined}>{place_name}</a>
{place_url && <a href={place_url}>{place_name}</a>}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ™•์ธํ•ด๋ณด๋‹ˆ๊นŒ ๋ถˆํ•„์š”ํ•œ ๋ถ€๋ถ„์ด๋„ค์š”... ๊ผผ๊ผผํ•˜์ง€ ๋ชปํ–ˆ๋„ค์š”
๋งŒ์•ฝ ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ์ค„ ์ˆ˜๋„ ์žˆ๊ณ  ์•ˆ ์ค„์ˆ˜๋„ ์žˆ๋Š” ๊ฒฝ์šฐ๋ผ๋ฉด ์ขœ๋‹˜์ด ๋ฐ‘์— ์จ์ฃผ์‹  ์ฝ”๋“œ๋กœ ์ž‘์„ฑํ•˜๋„๋ก ํ• ๊ฒŒ์š”!๐Ÿ‘

<StCardInfo>
<p className="info__tel">{phone || "๋ฒˆํ˜ธ ์—†์Œ"}</p>
{isCheck ? (
<p>{distance}m</p>
) : (
<p className="info__address">{address_name}</p>
)}
</StCardInfo>
</StCard>
);
}
const StCard = styled.li`
display: flex;
flex-direction: column;
justify-content: center;
gap: 20px;
width: 280px;
height: 80px;
font-size: 14px;
background-color: #fff;
color: #000;
border-radius: 10px;

& > a {
height: fit-content;
font-size: 16px;
font-weight: 700;
padding-left: 20px;
cursor: pointer;
color: inherit;
}
`;

const StCardInfo = styled.div`
display: flex;
gap: 20px;
width: 95%;
font-weight: 400;
justify-content: space-between;

& > .info__tel {
width: 100px;
height: fit-content;
min-height: 20px;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20px;
border-radius: 15px;
background-color: #828282;
color: #fff;
font-size: 12px;
font-weight: 700;
text-align: center;
}

& > .info__address {
max-width: 150px;
}
Comment on lines +69 to +73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜คํ˜ธ ํด๋ž˜์Šค๋ช…์œผ๋กœ ์„ ์–ธํ•ด์ฃผ์‹  ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค

Copy link
Collaborator Author

@leeseooo leeseooo Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋…ธ๋ž˜๋ฐฉ ์นด๋“œ ์•ˆ์˜ ์ •๋ณด ์ค‘์—์„œ ์ œ๋ชฉ ๋นผ๊ณ  ๋‚˜๋จธ์ง€๋ฅผ ๋‹ค pํƒœ๊ทธ๋กœ ํ•ด๋†”์„œ class๋กœ ๊ตฌ๋ถ„ํ–ˆ๋Š”๋ฐ nth-child๋กœ ๋ฐ”๊พธ๋Š”๊ฒŒ ๋” ์ข‹์„๊นŒ์š”?๊ทธ๋•Œ๋Š” nth-child๊ฐ€ ์ƒ๊ฐ์ด ์•ˆ๋‚ฌ์๋‹ˆ๋‹ค ใ…‹ใ…‹ใ…‹

+) ๊ทธ๋ƒฅ ์Šค์ปดํฌ๋„ŒํŠธ๋กœ ๋งŒ๋“œ๋Š”๊ฒŒ ๋‚ซ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SC ๋งŒ๋“ค๊ธฐ ์˜ค์ผ€์ด ~~~~

`;
15 changes: 15 additions & 0 deletions week4-ts/src/favicon.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 week4-ts/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
Loading