설치 및 사용
Vanilla Calendar Pro는 어떤 프로젝트에도 쉽게 통합할 수 있습니다. 의존성과 빌드를 어떻게 관리하는지에 따라 여러 설치 방법이 있습니다.
패키지 매니저로 설치
가장 일반적인 방법은 패키지 매니저를 사용하는 것입니다. 이 방법은 Node.js와 최신 빌드 도구를 사용하는 프로젝트에 적합합니다.
- 패키지를 설치합니다:
npm install vanilla-calendar-pro
# or
yarn add vanilla-calendar-pro
# or
pnpm add vanilla-calendar-pro- 문서의 body에 임의의 CSS 셀렉터를 가진 HTML 요소를 만듭니다:
<html>
<head>
</head>
<body>
<div id="calendar"></div>
</body>
</html>#calendar를 사용하지만, 원하는 어떤 셀렉터도 만들고 사용할 수 있습니다.- 스크립트를 가져오고, 캘린더 인스턴스를 만든 뒤 JavaScript 또는 TypeScript 파일에서 초기화합니다.
import { Calendar } from 'vanilla-calendar-pro';
const calendar = new Calendar('#calendar', {
// Your settings
});
calendar.init();- 같은 파일에서 스타일을 가져옵니다.
index.css에는 캘린더의 레이아웃 그리드와 라이트/다크 테마가 포함되어 있습니다.
import 'vanilla-calendar-pro/styles/index.css';또는 다음처럼 레이아웃과 테마 스타일을 별도로 포함할 수도 있습니다:
import 'vanilla-calendar-pro/styles/layout.css'; // Only the skeleton
import 'vanilla-calendar-pro/styles/themes/light.css'; // Light theme
import 'vanilla-calendar-pro/styles/themes/dark.css'; // Dark theme
// or any other custom theme...- 별도의 커스텀 설정 없이 간단히 초기화하는 전체 예제:
로컬 또는 CDN
빌드 도구나 패키지 매니저를 쓰지 않고 빠르게 Vanilla Calendar Pro를 통합하려면 CDN을 사용하거나 최신 버전의 아카이브를 다운로드하여 로컬에 포함할 수 있습니다.
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/vanilla-calendar-pro/styles/index.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vanilla-calendar-pro/index.js" defer></script>
</head>
<body style="display: flex; align-items: start"
extensions
motion은 애니메이션과 제스처를 제공합니다. time은 12/24시간 선택기를 제공합니다. annotations는 날짜 팝업, 스타일 modifier와 범위 툴팁을 제공합니다. weeks는 주간 보기, 접기, 주 번호와 요일/주 번호 클릭 콜백을 제공합니다. months는 여러 달을 함께 표시하고 탐색합니다. ESM 번들러는 import하고 등록하지 않은 확장을 제거할 수 있습니다.
import { Calendar, motion, time, annotations } from 'vanilla-calendar-pro';
import 'vanilla-calendar-pro/styles/index.css';
const calendar = new Calendar('#calendar', {
extensions: [motion, time, annotations],
animation: true,
selectionTimeMode
입력 필드 캘린더, 날짜 및 범위 선택, 월/연도 선택은 코어에 유지됩니다. 기본 요일 제목에는 확장이 필요하지 않습니다. 일반 <script> / CommonJS 전체 빌드는 다섯 확장을 자동 등록합니다. CSS import는 바뀌지 않습니다.
모듈별 CSS
기존 styles/index.css, styles/layout.css, styles/themes/*.css는 모든 기능의 스타일을 계속 제공하며 호환성을 유지합니다. CSS 크기를 줄이려면 필요한 부분만 가져오세요. JavaScript 확장을 등록해도 CSS가 자동으로 로드되지는 않습니다.
선택적 CSS 가져오기는 스타일 참조에 설명되어 있습니다. 기존 전체 스타일시트도 지원되며, 예제는 필요한 부분만 가져옵니다.