[ToyProject-Todomate] ํˆฌ๋‘๋ฉ”์ดํŠธ ํด๋ก  ํ”„๋กœ์ ํŠธ 19

2021. 12. 28. 23:12ใ†WEB Dev/ToyProject

728x90


๐Ÿ”ท CloneTodo โ˜‘ - Todomate Clone Project  |  Team CloneMate

 

CloneTodo : ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์‚ฌ๋ž‘ํ•˜๋Š” ํˆฌ๋‘๋ฉ”์ดํŠธ๋ฅผ ํด๋ก ํ•˜์—ฌ ์›น ์„œ๋น„์Šค๋ฅผ ๋ฐฐํฌํ•ด๋ณด๋Š” ํ”„๋กœ์ ํŠธ

 


์˜ค๋Š˜์˜ ํ•  ์ผ์€ Explore์˜ ๋‹ฌ๋ ฅ๋ถ€๋ถ„์„ ๋งŒ๋“œ๋Š” ์ผ์ด๋‹ค.

 

๋‹ฌ๋ ฅ์˜ ๊ฒฝ์šฐ NHN TOAST์—์„œ ์ œ๊ณตํ•˜๋Š” Calendar UI ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ํ•˜์˜€๋‹ค.

๊ทธ๋ž˜์„œ TOAST์˜ ๊ณต์‹๋ฌธ์„œ์—์„œ ์ ์šฉ๋ฐฉ๋ฒ•์„ ๋”ฐ๋ผํ•ด๋ณธ๋‹ค.

 

 

1. ์„ค์น˜

 

npm ์ด๋‚˜ bower, CDN์„ ํ†ตํ•ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ฆฌ์•กํŠธ ํ”„๋กœ์ ํŠธ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ„ํŽธํ•œ CDN ๋ณด๋‹ค๋Š” npm์„ ํ†ตํ•ด ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜์ž.

 

npm install --save @toast-ui/react-calendar

 

 

2. Calendar ํŒจํ‚ค์ง€์™€ CSS๋ฅผ import ํ•ด์˜จ๋‹ค.

 

import Calendar from '@toast-ui/react-calendar';
import 'tui-calendar/dist/tui-calendar.css';

 

3. ์ ์šฉํ•˜๊ธฐ

 

๊ณต์‹๋ฌธ์„œ๋Š” ํ•จ์ˆ˜ํ˜•์ด ์•„๋‹Œ ํด๋ž˜์Šคํ˜• ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋‹ค.

์ž˜ ๋ชจ๋ฅด๊ฒ ์œผ๋‹ˆ ์ผ๋‹จ ๋‹ค ๋•Œ๋ ค๋†“๊ณ  ๋ณธ๋‹ค.

 

import React from 'react';
import Box from '@mui/material/Box';
import Calendar from '@toast-ui/react-calendar';
import 'tui-calendar/dist/tui-calendar.css';

const calendarOptions = {
  // sort of option properties.
};

class CalendarBox extends React.Component {
  calendarRef = React.createRef();

  handleClickNextButton = () => {
    const calendarInstance = this.calendarRef.current.getInstance();

    calendarInstance.next();
  };

  handleClickButton = () => {
    this.calendarRef.current.getRootElement().classList.add('calendar-root');
  };

  handleClickDayname = (ev) => {
    // view : week, day
    console.group('onClickDayname');
    console.log(ev.date);
    console.groupEnd();
  };

  render() {
    return (
      <>
        <Calendar
          ref={this.calendarRef}
          {...calendarOptions}
          onClickDayname={this.handleClickDayname}
        />
        <button onClick={this.handleClickNextButton}>Go next!</button>
      </>
    );
  }
}
export default CalendarBox;

 

 

 

 

์ด๋ ‡๊ฒŒ ๋„ฃ์–ด๋†“๊ณ  ๋‚˜๋‹ˆ... ์šฐ๋ฆฌ์˜ ๊ณ„ํš๋ณด๋‹ค ๋” ๋ฌด๊ฒ๊ณ  ํ™”๋ คํ•˜๊ณ  "์–ด๋ ค์šด" ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์•„๋‹Œ๊ฐ€ ์‹ถ๋‹ค.

์ฐจ๋ผ๋ฆฌ ๊ทธ๋ƒฅ ๋‹ฌ๋ ฅ๋ชจ์–‘๋งŒ ๋‚˜ํƒ€๋‚˜๋Š”๊ฒŒ ๋” ๋‚ซ์ง€ ์•Š์„๊นŒ ใ… ใ… 

 

 

 

 


 

 

๊ทธ๋ž˜์„œ MUI์˜ Date Picker ์ค‘์— Landscape Orientation์„ ์ ์šฉํ•ด๋ณธ๋‹ค.

 

 

 

 

1. MUI์˜ ๋‹ฌ๋ ฅ, ์‹œ๊ฐ„ ๋“ฑ์„ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•œ ํŒจํ‚ค์ง€ ์„ค์น˜

 

npm์„ ์ด์šฉํ•ด ์•„๋ž˜ ์‹œ๊ฐ„, ๋‚ ์งœ ๊ด€๋ จ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์ค€๋‹ค.

๋ญ˜.. ์„ค์น˜ํ•ด๋„ ์ƒ๊ด€์€ ์—†๋Š” ๊ฒƒ ๊ฐ™๋‹ค.

 

// date-fns
npm install @date-io/date-fns
// or for Day.js
npm install -s @date-io/dayjs
// or for Luxon
npm install -s @date-io/luxon
// or for Moment.js
npm install @date-io/moment

 

 

2.  dateAdapter ํŒจํ‚ค์ง€๋ฅผ import ํ•ด์˜จ๋‹ค.

 

 

// date-fns
import DateAdapter from '@mui/lab/AdapterDateFns';
// or for Day.js
import DateAdapter from '@mui/lab/AdapterDayjs';
// or for Luxon
import DateAdapter from '@mui/lab/AdapterLuxon';
// or for Moment.js
import DateAdapter from '@mui/lab/AdapterMoment';

 

์—ฌ๊ธฐ๊นŒ์ง€ ํ•˜๊ณ  ํ•˜๋‹จ์˜ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋Š”๋ฐ 

Can't resolve '@mui/lab/AdapterDateFns' in ํŒŒ์ผ๊ฒฝ๋กœ ์˜ค๋ฅ˜๊ฐ€ ๋–ด๋‹ค.

 

์Šคํƒ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ์— ์ฐพ์•„๋ณด๋‹ˆ ์ด๊ฒƒ๋„ ๋ฒ„์ „ ๋ฌธ์ œ์ธ๊ฑฐ ๊ฐ™์€๋ฐ (์ œ๋ฐœ! ํ˜ธํ™˜ ์ข€!)

 

 

 

Module not found: Can't resolve '@mui/lab/AdapterDateFns'

I was using the Material UI Timepicker but after updating to MUI 5 it is not working anymore. I updated everything to @next and @material-ui/core (version 5.0.0-beta.5) and @material-ui/lab (versio...

stackoverflow.com

 

์•„๋ž˜ @mui/lab์„ ์„ค์น˜ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

 

npm i @mui/lab

 

 

์œ„์˜ @mui/lab ๊ฐ€์ง€๊ณ  ์•ˆ๋˜๋ฉด

 

npm i @mui/material
npm i date-fns

 

๋„ ์„ค์น˜ํ•ด์ฃผ์ž.

 

 

๊ฒฐ๋ก 

 

 

 

3. ๋‚˜๋จธ์ง€ ์ปดํฌ๋„ŒํŠธ ๋“ค์„ import ํ•ด์˜จ๋‹ค.

 

import isWeekend from 'date-fns/isWeekend';
import TextField from '@mui/material/TextField';
import AdapterDateFns from '@mui/lab/AdapterDateFns';
import LocalizationProvider from '@mui/lab/LocalizationProvider';
import StaticDatePicker from '@mui/lab/StaticDatePicker';

 

 

4. ๊ทธ๋ฆฌ๊ณ  ์˜ˆ์‹œ์ฝ”๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์˜จ๋‹ค.

 

 

<LocalizationProvider dateAdapter={AdapterDateFns}>
            <StaticDatePicker
              orientation="landscape"
              openTo="day"
              value={value}
              shouldDisableDate={isWeekend}
              onChange={(newValue) => {
                setValue(newValue);
              }}
              renderInput={(params) => <TextField {...params} />}
            />
</LocalizationProvider>

 

 

 

ํ›จ์”ฌ ์˜ˆ์˜๋‹ค..!

 

 

728x90