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

충남대 FE_강병현_3주차 과제 Step3 #76

Open
wants to merge 31 commits into
base: kang-kibong
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
341ec1a
init
kang-kibong Jul 10, 2024
ac2e30a
docs(README): update feature list
kang-kibong Jul 10, 2024
8288f49
chore: install axios
kang-kibong Jul 10, 2024
2de14ac
feat: define separated request and response types and improve file st…
kang-kibong Jul 10, 2024
e7b2bbe
chore: update absolute path
kang-kibong Jul 11, 2024
3f1d19b
feat: add useFetch custom hooks
kang-kibong Jul 11, 2024
6b1248d
feat: add Spinner component
kang-kibong Jul 11, 2024
f0e5339
feat: add ErrorMessage component
kang-kibong Jul 11, 2024
fcad1f9
chore: add .env file with REACT_APP_BASE_URL
kang-kibong Jul 11, 2024
a1b5493
feat: implement SectionHeader component using /api/v1/themes API
kang-kibong Jul 11, 2024
5eff078
feat: Add real-time trending gift ranking section
kang-kibong Jul 11, 2024
370cf92
design: change ErrorMessage component
kang-kibong Jul 11, 2024
52f2f20
feat: display 'No products to show!' message when there are no products
kang-kibong Jul 12, 2024
9c02130
feat: redirect to home page if themeKey is invalid
kang-kibong Jul 12, 2024
78197e5
feat: implement product list API with pagination for 20 items
kang-kibong Jul 12, 2024
009433e
feat: add FilterProvider context and useFilter hook to Storybook stories
kang-kibong Jul 12, 2024
c75b5af
docs: update feature list
kang-kibong Jul 12, 2024
9df3e9e
feat: add StatusHandler component
kang-kibong Jul 12, 2024
f75b91c
feat: add UI handling for empty data state
kang-kibong Jul 12, 2024
b11b351
feat: handle different error messages based on HTTP status codes
kang-kibong Jul 12, 2024
ed55fa6
docs: update feature list
kang-kibong Jul 12, 2024
fa3b794
docs: update feature list
kang-kibong Jul 12, 2024
5d755cd
refactor: simplify isEmpty check
kang-kibong Jul 12, 2024
19ca755
refactor: change SectionHeader component to ThemeHeader component
kang-kibong Jul 12, 2024
6ee5a69
refactor: remove mocks
kang-kibong Jul 12, 2024
14c66bd
docs: update feature list
kang-kibong Jul 12, 2024
3b12c92
feat: implement API calls using react-query
kang-kibong Jul 12, 2024
52e9d51
feat: add useGoodsItemListQuery hooks
kang-kibong Jul 12, 2024
4f0f37c
feat: add useInfiniteScroll hooks
kang-kibong Jul 12, 2024
551d692
feat: add infinite scroll with pagination for theme-based gift recomm…
kang-kibong Jul 12, 2024
5ebb22d
feat(storybook): add QueryClientProvider to Storybook
kang-kibong Jul 12, 2024
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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["@emotion"]
}
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_BASE_URL=https://kakao-tech-campus-mock-server.vercel.app
63 changes: 63 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["react-app", "eslint:recommended", "plugin:import/typescript", "airbnb", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"no-var": "error",
"no-multiple-empty-lines": "error",
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
"eqeqeq": "error",
"dot-notation": "error",
"import/extensions": ["error", "ignorePackages", {
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}],
"react/jsx-props-no-spreading": "off",
"import/prefer-default-export": "off",
"react/jsx-filename-extension": ["error", { "extensions": [".tsx"] }],
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"react/require-default-props": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error", { "variables": false , "functions": false,"classes": false}],
"react/prop-types": "off",
"import/no-cycle": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"jsx-a11y/label-has-associated-control": [ 2, {
"some": [ "nesting", "id" ]
}],
"react-hooks/exhaustive-deps": "off"
},
"settings": {
"import/resolver": {
"alias": {
"map": [
["@", "./src"],
["@components", "./src/components"],
["@assets", "./src/assets"],
["@hooks", "./src/hooks"],
["@pages", "./src/pages"],
["@routes", "./src/routes"],
["@utils", "./src/utils"],
["@context", "./src/context"],
["@types", "./src/types"],
["@apis", "./src/apis"]
],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
59 changes: 0 additions & 59 deletions .eslintrc.js

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Workflow name
name: 'Chromatic Deployment'

# Event for the workflow
on: push

# List of jobs
jobs:
test:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- run: yarn
#👇 Adds Chromatic as a step in the workflow
- uses: chromaui/action@v1
# Options required for Chromatic's GitHub Action
with:
#👇 Chromatic projectToken, see https://storybook.js.org/tutorials/intro-to-storybook/react/ko/deploy/ to obtain it
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

- name: Create comment PR
uses: thollander/actions-comment-pull-request@v1
env:
TOKEN: ${{ secrets.TOKEN }}
with:
message: "🚀storybook: ${{ steps.chromatic.outputs.storybookUrl }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.eslintcache
.yaml

*storybook.log
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"singleQuote": true,
"parser": "typescript",
"semi": true,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 100,
"printWidth": 120,
"arrowParens": "always"
}
35 changes: 15 additions & 20 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import path from 'path';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-create-react-app',
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
],
webpackFinal: async (config) => {
config.resolve?.plugins?.push(
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, '../tsconfig.json'),
}),
);

return config;
},
framework: {
name: '@storybook/react-webpack5',
options: {
builder: {
useSWC: true,
},
},
},
docs: {
autodocs: 'tag',
options: {},
},
staticDirs: ['../public'],
webpackFinal: async (config) => {
if (config.resolve) {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: config.resolve.extensions,
}),
];
}
return config;
},
};
export default config;
2 changes: 0 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { Preview } from '@storybook/react';
import '@/styles';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
Expand Down
132 changes: 132 additions & 0 deletions QUESTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# 🤔 2주차 [질문](https://kibong.notion.site/23645b1895664279856437d57eda9a83?pvs=4)

## 1. 페이지별 컴포넌트는 어떻게 관리하는 게 좋을까요?

페이지별로 섹션에 해당하는 컴포넌트나 모든 페이지에서 공통으로 사용하지 않는 컴포넌트를 어떻게 관리하는 게 좋을지 고민입니다.

과제를 진행할 때는 해당 페이지별로 디렉토리화해서 `pages` 폴더에 있는 컴포넌트를 호출하여 관리했습니다. 다른 방법이나 더 좋은 방법이 있을까요?

<br />

## 2. 어떻게 상수화시키는 게 좋을까요?

처음에는 `utils/constants`에 모든 상수를 관리할지, 아니면 각 컴포넌트마다 배치하는 게 좋을지 고민했습니다.

과제를 진행할 때는 상수화할 것이 별로 없으면 컴포넌트 최상단에 배치하거나, 상수가 많거나 길어질 경우 해당 컴포넌트 폴더에 `constants` 파일을 만들어서 관리했습니다.

어떤 방식으로 상수화시키는 게 좋을까요?

<br />

## 3. index 파일 네이밍의 사용 괜찮을까요?

각 컴포넌트를 디렉토리화하고 `index`로 네이밍하여 과제를 진행했습니다. 왜냐하면 컴포넌트를 import할 때 하위 폴더가 많아지면 코드의 길이도 길어질 것 같아서 사용하게 되었습니다.

하지만 `index`로 네이밍하면 코드를 작성하면서 어떤 컴포넌트인지 구분이 잘 안되는 점이 단점인 것 같습니다.

더 좋은 방안이 있거나, 멘토님께서는 어떻게 관리하시는지 궁금합니다.

<br />

## 4. Story 파일들을 stories 폴더로 관리하는 게 좋을까요? 아니면 컴포넌트별로 관리하는 게 좋을까요?

기존에는 `src` 폴더에 `stories` 폴더를 만들어 각 컴포넌트 폴더 구조대로 스토리를 추가했었는데, 이번에는 각 컴포넌트별 폴더에 작성해보았습니다.

그 이유는 다시 `stories` 폴더를 뒤져야 한다는 점에서 개발 시간이 늘어나는 것 같아서입니다.

더 좋은 방안이 있을까요?

<br />

## 5. Storybook 배포 경로를 PR 코멘트로 추가하고 싶은데 어떻게 해야 하나요?

Storybook 배포에 대해 공부하면서 CI를 통해 자동으로 코멘트를 달 수 있다는 것을 알게 되었습니다.

Storybook의 토큰과 사용자의 GitHub 토큰을 repository action의 secret에 설정하면 가능하다는 것을 알게 되었습니다.

먼저 다음과 같이 `yml`을 작성해보았습니다.

```yaml
yaml코드 복사
# Workflow name
name: 'Chromatic Deployment'

# Event for the workflow
on: push

# List of jobs
jobs:
test:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- run: yarn
- uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

- name: Create comment PR
uses: thollander/actions-comment-pull-request@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: "🚀 Storybook: ${{ steps.chromatic.outputs.storybookUrl }}"

```

이후 설정에서 두 개의 secret을 설정했습니다.

`CHROMATIC_PROJECT_TOKEN`은 성공적으로 설정할 수 있었지만, `GITHUB_TOKEN`은 앞에 `GITHUB`로 시작할 수 없다는 경고가 뜨며 설정할 수 없었습니다.

<br />

<img width="783" alt="스크린샷 2024-07-05 오후 4 58 51" src="https://github.com/kang-kibong/kang-kibong/assets/33623123/2fac34f7-9363-42ed-9347-2a9d3c29156b">

<br />


때문에 `TOKEN`이라는 이름으로 secret을 설정하고 `yml`을 다시 작성했습니다.

```yaml
yaml코드 복사
# Workflow name
name: 'Chromatic Deployment'

# Event for the workflow
on: push

# List of jobs
jobs:
test:
# Operating System
runs-on: ubuntu-latest
# Job steps
steps:
- uses: actions/checkout@v1
- run: yarn
- uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

- name: Create comment PR
uses: thollander/actions-comment-pull-request@v1
env:
TOKEN: ${{ secrets.TOKEN }}
with:
message: "🚀 Storybook: ${{ steps.chromatic.outputs.storybookUrl }}"

```

이후 push를 진행하고 제대로 Storybook 배포와 URL 코멘트가 달리는지 확인해보았습니다.

<br />

<img width="578" alt="스크린샷 2024-07-05 오후 5 03 09" src="https://github.com/kang-kibong/kang-kibong/assets/33623123/436a0789-41f7-4316-b088-a877be70415e">

<br />

아쉽게도 코멘트가 달리지 않는 것을 확인할 수 있었습니다.

무슨 이유로 안되는지 잘 모르겠습니다.
Loading