Skip to content

Feature(#17, #19, #20, #21, #205): home 페이지 API 연동, modernizr 적용 #229

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

Conversation

LellowMellow
Copy link
Collaborator

@LellowMellow LellowMellow commented Dec 7, 2023

작업 개요

작업 사항

  • modernizr 적용
  • 적용한 modernizr 바탕으로 touchEvent 판별
  • 판별 기준으로 발표자 페이지 접근 제한
  • modernizr type 선언
  • home 강의 생성과 참여 관련 API 연동
  • 이동할 page URL 처리

고민한 점들(필수 X)

modernizr 처리

🔗Modernizr download builder

상단 페이지에서 touch events를 선택하여 modernizr-custom.js를 빌드하여 이를 src 폴더에 위치시킵니다. 전역으로 Modernizr를 사용하기 위하여 index.htmlscript 태그를 이용하여 이를 불러옵니다.

<script type="text/javascript" src="/src/modernizr.js"></script>

TypeScript 환경에서 작업하고 있기 때문에 이에 대한 type을 선언하였습니다. types 폴더 하위에 다양한 type들을 정의할 수 있도록 작업하려 하였으나 기존에 작업하였던 "types": ["vite-plugin-svgr/client"],typesRoot 설정이 겹쳐 svg 관련 코드가 정상적으로 동작하지 않을 것을 고려하여 global로 관리할 수 있도록 하였습니다.

src 하위에 global.d.ts를 정의하여 아래와 같이 type을 정의하였습니다.

declare global {
  interface ModernizrStatic {
    touchevents: boolean;
  }
  var Modernizr: ModernizrStatic;
}

export {};

이를 적용하기 위해 tsconfig.json에 다음을 추가하였습니다.

"include": ["src/**/*", "src/global.d.ts"],

이를 바탕으로 Modernizr는 아래와 같이 활용할 수 있습니다.

{Modernizr.touchevents ? (
            ""
          ) : ( ...

API 연결

강의 생성과 강의 참여에 관련된 API 연동을 완료하였습니다. env 파일에 추가적인 환경변수를 정의하였습니다.

VITE_API_SERVER_URL= ...

이를 활용하여 각각 API를 연동하였습니다.

스크린샷(필수 X)

2023-12-07.20-57-26.mp4

- 강의 생성과 강의 조회에 관련된 API 코드를 작성했습니다.
- 강의 생성과 강의 조회에 관련된 API 코드를 작성했습니다.
- set method만 사용하는 useToast에서 recoil method를 교체하였습니다.
- 발표자 페이지 접근을 막기 위해 Modernizr를 적용하였습니다.
- ts type 오류를 해결하였습니다.
- 강의 생성과 강의 조회에 관련된 API 코드를 작성했습니다.
- set method만 사용하는 useToast에서 recoil method를 교체하였습니다.
- 발표자 페이지 접근을 막기 위해 Modernizr를 적용하였습니다.
- 강의 생성과 강의 조회에 관련된 API 코드를 작성했습니다.
- API 요청과 관련하여 처리를 완료하였습니다.
@LellowMellow LellowMellow added ✨ Feat 기능 개발 FE 프론트엔드 작업 labels Dec 7, 2023
@LellowMellow LellowMellow added this to the 5주차 milestone Dec 7, 2023
@LellowMellow LellowMellow self-assigned this Dec 7, 2023
Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for boarlog ready!

Name Link
🔨 Latest commit f8fca18
🔍 Latest deploy log https://app.netlify.com/sites/boarlog/deploys/6571b65c6a6a7400084448e6
😎 Deploy Preview https://deploy-preview-229--boarlog.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

- 배포를 위해 불필요한 코드를 제거하였습니다.
Comment on lines +1 to +9
declare global {
interface ModernizrStatic {
touchevents: boolean;
}

var Modernizr: ModernizrStatic;
}

export {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

아 이렇게 타입을 처리하는 방법이 있군요.
혹시 문제가 되지 않는다면 var를 const나 let으로 바꿔주는건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

헉 그렇네요! 바로 반영해보겠습니다 :)

- var를 let으로 변경하였습니다.
Comment on lines +18 to +31
const handleCreateButtonClicked = () => {
axios
.post(`${import.meta.env.VITE_API_SERVER_URL}/lecture`, {
title,
description,
email: "[email protected]"
})
.then((result) => {
navigate(`/instructor?roomid=${result.data.code}`);
})
.catch((error) => {
console.log(error);
});
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

아하 이렇게 API 요청을 하는 군요!
배웠습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

사실 이 코드는 예전에 제가 사용했던 방법이라 좋은 방식인지는 잘 모르겠어요 ㅠㅠ 나중에 개선할 때 좀 더 생각해봐요 :)

Copy link
Collaborator

@Jw705 Jw705 left a comment

Choose a reason for hiding this comment

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

동령님 오늘 하루 너무 고생 많으셨습니다. ㅠㅠ LGTM 👍👍

interface ModernizrStatic {
touchevents: boolean;
}
var Modernizr: ModernizrStatic;
Copy link
Collaborator

Choose a reason for hiding this comment

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

let으로 바꿔도 좋을 것 같습니다!

Suggested change
var Modernizr: ModernizrStatic;
let Modernizr: ModernizrStatic;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

변경 완료!!~~

@@ -0,0 +1,123 @@
/*! modernizr 3.6.0 (Custom Build) | MIT *
Copy link
Collaborator

Choose a reason for hiding this comment

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

modernizr는 어렵네요..

Copy link
Collaborator

@Byeonjin Byeonjin left a comment

Choose a reason for hiding this comment

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

고생 진짜 많으셨어요ㅜㅜ

@LellowMellow LellowMellow merged commit 772c378 into boostcampwm2023:dev Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment