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

Feat#2 jisoo/calendar #6

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open

Feat#2 jisoo/calendar #6

wants to merge 44 commits into from

Conversation

seojisoosoo
Copy link
Contributor

@seojisoosoo seojisoosoo commented Jul 3, 2023

๐Ÿ”ฅ Related Issues

๐Ÿ’™ ์ž‘์—… ๋‚ด์šฉ

  • ์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‹ฌ๋ ฅ ๊ตฌํ˜„
  • ํ•ด๋‹นํ•˜๋Š” ๋‚ ์งœ๋ฅผ ํด๋ฆญํ•˜๋ฉด ์ผ์ •์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„

โœ… PR Point

์™„์ „! ์“ธ์• ๊ธฐ ์ฝ”๋“œ! ์ด๋ ‡๊ฒŒ ํ•  ์ˆ˜๋„ ์žˆ๊ฒ ๊ตฌ๋‚˜ ์ •๋„๋กœ๋งŒ ๋ด์ฃผ์„ธ์š”!!! ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌ๋„ ๋„ˆ๋ฌด๋„ˆ๋ฌด ์•ˆ ๋˜์—ˆ๊ณ , ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋œฏ์–ด๊ณ ์น˜๋Š๋ผ๊ณ  ์• ๋งŒ ๋จน์€ ์ฝ”๋“œ์ž…๋‹ˆ๋‹คใ… ใ…  ์“ธ์• ๊ธฐ!

react-calendar react-ios-time-picker ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค

components/jisoo/JisooCalendar.tsx

  • Date ๊ฐ์ฒด๋ฅผ string ํ˜•์‹์œผ๋กœ ๋ณ€๊ฒฝํ•  ๋•Œ์—๋Š” moment(value).format("YYYY-MM-DD") ์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. toIOString()๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•ด๋ณด๊ธฐ๋„ ํ–ˆ๋Š”๋ฐ, ์ž๊พธ ํ•˜๋ฃจ ์ „ ๋‚ ์งœ๋กœ ์ฐํžˆ๋”๋ผ๊ณ ์š”...! ๊ทธ๋ž˜์„œ moment ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค! (import moment from "moment"; ํ•„์š”!)

  • react-calendar์—์„œ ํ•œ์นธํ•œ์นธ์„ tile์ด๋ผ๊ณ  ํ•˜๋”๋ผ๊ณ ์š”! ๋‚ด๊ฐ€ ๊ฐ€์ง„ ์ˆ˜์—…๋ฐ์ดํ„ฐ๋ฅผ map๋Œ๋ฆฌ๊ณ  ๊ทธ ์ค‘์—์„œ๋„ ๋‚ ์งœ๊ฐ€ ํ˜„์žฌ ๋‚ ์งœ์™€ ๋™์ผํ•˜๋ฉด html์ด๋ผ๋Š” ๋ฐฐ์—ด์— ํ•ด๋‹น ํƒœ๊ทธ๋ฅผ ๋„ฃ์–ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 tileContent={({ date, view }) => {
            let html: Element[] = [];
            {
              classData.map(({ id, student, times, color }: calendarDatatTypes) => {
                times.map(
                  ({ dates, time }) =>
                    dates === moment(date).format("YYYY-MM-DD") &&
                    html.push(
                      <Box key={id} $color={color}>
                        <p>{student}</p>
                        <p>{time}</p>
                      </Box>,
                    ),
                );
              });
            }
  • ์‹œ๊ฐ„์„ ์„ ํƒํ•˜๋Š” ๋กœ์ง์€ ์•„๋ž˜์™€ ๊ฐ™์•„์š”! ์ถ”๊ฐ€๋œ ์ƒˆ๋กœ์šด ์‹œ๊ฐ„์ด newTimeData์ด๊ณ , ์›๋ž˜์˜ ์‹œ๊ฐ„์„ map์„ ๋Œ๋ ค์„œ ์ฝ์–ด์˜จ ๋’ค originTimeDatas์— ํ• ๋‹นํ–ˆ์–ด์š”. ์ž…๋ ฅ๋œ ํ•™์ƒ์˜ ์ˆ˜์—…์ด ๋” ์ถ”๊ฐ€๋œ ๋กœ์ง์ด๋ผ์„œ input์œผ๋กœ ์ž…๋ ฅ๋ฐ›์€ ํ•™์ƒ์˜ ์ด๋ฆ„๊ณผ ๋™์ผํ•˜๋ฉด, times์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์ถ”๊ฐ€๋˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค! ์ฒ˜์Œ์—๋Š” ์‚ผํ•ญ์—ฐ์‚ฐ์ž๊ฐ€ ์•„๋‹Œ &&์—ฐ์‚ฐ์ž๋งŒ ์ผ๋Š”๋ฐ, false์ธ ๊ฒฝ์šฐ ๋กœ์ง์ด ์—†๋‹ค๊ณ  ์˜ค๋ฅ˜๋– ์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์‚ผํ•ญ์—ฐ์‚ฐ์ž๋กœ ํ‘œ๊ธฐํ–ˆ์–ด์š”!
function handleSaveTimes() {
    handleCloseModal();
    const newTimeData = startTimeValue.split(" ")[0] + "~" + endTimeValue.split(" ")[0];
    const originTimeDatas = classData
      .map(({ student, times }) => student === studentName && times)
      .filter((time) => time !== false)[0];

    setClassData(
      classData.map((data) =>
        data.student === studentName
          ? {
              ...data,
              times: [...originTimeDatas, { dates: moment(value).format("YYYY-MM-DD"), time: newTimeData }],
            }
          : data,
      ),
    );
  }
  • ios-time-picker์—๋Š” ํ•œ๊ธ€๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ธฐ๋Šฅ์ด ์—†๋Š” ๊ฒƒ ๊ฐ™์•„์š”..... ๊ทธ๋ž˜์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ๋กœ ์ง์ ‘ ๋ณ€ํ™˜ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹คใ…œใ…œ๋ถˆํŽธ...
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2023-07-04 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 7 15 37
  function checkTimeValue(time: string) {
    const hour = time.split(" ")[1];
    const realTime = time.split(" ")[0];

    return hour === "AM" ? "์˜ค์ „ " + realTime : "์˜คํ›„ " + realTime;
  }

index.html

  • ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ AM, PM์„ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ์–ด์„œ ์ด๋ ‡๊ฒŒ ๋„์ „ํ–ˆ๋Š”๋ฐ ์•ˆ ๋จน๋„ค์š”ใ… 
  <script>
     window.onload = function () {
       document.querySelector(".react-ios-time-picker-cell-inner-hour-format-selected").innerHTML = "์˜ค์ „";
       const sections = document.querySelectorAll(".react-ios-time-picker-cell-inner-hour-format");

       console.log(sections);
       console.log(sections.length);
       for (let i = 0; i < sections.length; i++) {
         if (i === 0) {
           let item = sections.item(i);

           item.innerHTML = "์˜ค์ „";
         }
       }
     };
   </script>

๐Ÿ˜ก Trouble Shooting

  • react-calendar ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ์ปดํฌ๋„ŒํŠธ ์•ˆ์— ์„ ์–ธ์ด ๋˜๋Š”๋ฐ, react-ios-time-picker๋Š” ์ปดํฌ๋„ŒํŠธ ๋ฐ”๊นฅ์— ์„ ์–ธ์ด ๋˜์–ด์„œ, react-ios-time-picker๋ฅผ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•  ๋•Œ์—๋Š” index.cssํŒŒ์ผ์„ ๋งŒ๋“ค์—ˆ์–ด์š”ใ…œใ…œ ์ด๊ฒŒ ๋ฌด์Šจ ๋ง์ด๋ƒํ•˜๋ฉด!! react-ios-time-picker๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ๋˜๋Š” ui๋“ค์€ <div id="root"> ๋ฐ”๊นฅ์— ์ƒ์„ฑ์ด ๋œ๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค,,,๊ธฐ๋ณธ์ ์œผ๋กœ <div id="root"> ์•ˆ์ชฝ์— ๋ชจ๋“  ๋กœ์ง์ด ์ƒ์„ฑ๋˜๋Š” ๋ฆฌ์•กํŠธ์˜ ๋ฐฉ์‹์„ ๊ฑฐ์Šค๋ฅด๋Š” ๋Š๋‚Œ์ด์—ˆ์–ด์š”...
  • ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›๊ธฐ ์œ„ํ•ด์„œ๋Š” a๋ผ๋Š” ๋‚ ์งœ์— ์ง๊ฒฐ๋˜๋Š” b๋ผ๋Š” ์‹œ๊ฐ„์ด ํ•„์š”ํ•˜๋”๋ผ๊ณ ์š”... ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ, 2023-7-4์ด๋ผ๋Š” ๋‚ ์งœ์— ์ง๊ฒฐ๋˜๋Š” 12:00~13:00๋ผ๋Š” ์‹œ๊ฐ„์ด ํ•„์š”ํ–ˆ์–ด์š”! ๊ทธ๋ž˜์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐ์ดํ„ฐ ํƒ€์ž…์„ ๋ณ€๊ฒฝํ•˜์˜€์Šต๋‹ˆ๋‹ค...
  • ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, ํ•™์ƒ ๊ฐœ๊ฐœ์ธ์—๊ฒŒ ์ƒ‰์ƒ์ฝ”๋“œ๊ฐ€ ํ•„์š”ํ•œ๋ฐ, ํ•™์ƒ๋งˆ๋‹ค ์ƒ‰๊น”์ด ๋‹ฌ๋ผ์•ผํ•˜๋‹ˆ๊นŒ, ์ด๊ฒƒ๋„ ์„œ๋ฒ„์—์„œ ๋ณด๋‚ด์ฃผ๋ฉด ์ข‹๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ์ถ”๊ฐ€ํ–ˆ์–ด์š”!
import { calendarDatatTypes } from "../../type/jisoo/calendarDataTypes";

export const CAELENDAR_DATA: calendarDatatTypes[] = [
  { id: 1, student: "์€๋นˆ", times: [{ dates: "2023-07-20", time: "09:00~10:00" }], color: "#FFC81E" },
  { id: 2, student: "ํ˜œ์ธ", times: [{ dates: "2023-07-21", time: "10:00~11:00" }], color: "#EB0000" },
  { id: 3, student: "์„ฑ๊ฒฝ", times: [{ dates: "2023-07-06", time: "09:00~10:00" }], color: "#FFB6C1" },
  {
    id: 4,
    student: "ํฌ์ •",
    times: [
      { dates: "2023-07-06", time: "19:00~20:00" },
      { dates: "2023-07-16", time: "18:00~19:00" },
    ],
    color: "#7B68EE",
  },
  {
    id: 5,
    student: "์ง€์ˆ˜",
    times: [
      { dates: "2023-07-06", time: "13:00~14:00" },
      { dates: "2023-07-13", time: "13:00~14:00" },
      { dates: "2023-07-20", time: "13:00~14:00" },
      { dates: "2023-07-27", time: "13:00~14:00" },
    ],
    color: "#5F9EA0",
  },
];

๐Ÿ‘€ ์Šคํฌ๋ฆฐ์ƒท / GIF / ๋งํฌ

2023-07-04.7.05.04.mov

๐Ÿ“š Reference

react-ios-time-picker

@seojisoosoo seojisoosoo self-assigned this Jul 3, 2023
@seojisoosoo seojisoosoo added feat-function ๊ธฐ๋Šฅ๊ตฌํ˜„ํ–ˆ์–ด์š” feat-UI UI ๋งŒ๋“ค์—ˆ์–ด์š” ์ง€์ˆ˜ ์ง€์ˆ˜ ๋‹ด๋‹น labels Jul 3, 2023
@seojisoosoo seojisoosoo marked this pull request as ready for review July 3, 2023 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat-function ๊ธฐ๋Šฅ๊ตฌํ˜„ํ–ˆ์–ด์š” feat-UI UI ๋งŒ๋“ค์—ˆ์–ด์š” ์ง€์ˆ˜ ์ง€์ˆ˜ ๋‹ด๋‹น
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ Jisoo ] - ์บ˜๋ฆฐ๋” ๊ตฌํ˜„
1 participant