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

Refactoring/global #148

Merged
merged 53 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
556b249
refactoring "generateDate" method
uvarov-frontend Nov 9, 2023
d4bc124
fix FormatDateString
uvarov-frontend Nov 9, 2023
13b44c8
refactoring "getComponent"
uvarov-frontend Nov 9, 2023
4cef0ec
refactoring createComponents
uvarov-frontend Nov 9, 2023
5660d92
refactoring "parseDates"
uvarov-frontend Nov 9, 2023
6659908
rename "parseComponent"
uvarov-frontend Nov 9, 2023
63af9a7
refactoring transformTime methods
uvarov-frontend Nov 9, 2023
b37c8c7
refactoring "changeMonth"
uvarov-frontend Nov 10, 2023
14e5f99
refactoring "clickCalendar", create handleClickDay
uvarov-frontend Nov 10, 2023
2a62be4
fix readme
uvarov-frontend Nov 12, 2023
49ffd2c
refactoring "handleDayRangedSelection"
uvarov-frontend Nov 12, 2023
42cfb39
add alias and update devDependencies
uvarov-frontend Nov 14, 2023
6b04b32
refactoring handles
uvarov-frontend Nov 14, 2023
861a022
refactoring "handleDayRangedSelection"
uvarov-frontend Nov 16, 2023
18801b4
fix eslint "indent" role
uvarov-frontend Nov 16, 2023
a957553
fix parseDates and types.ts
uvarov-frontend Nov 16, 2023
0f8ea22
replace controlArrows with updateArrowVisibility
uvarov-frontend Nov 17, 2023
8095c8c
remove px-1 from .vanilla-calendar-header
uvarov-frontend Nov 17, 2023
bb9c2f6
refactoring "createDOM"
uvarov-frontend Nov 17, 2023
c768648
refactoring createDays
uvarov-frontend Nov 18, 2023
8ec67d9
TODO: Add check self.settings.selection.year
uvarov-frontend Nov 18, 2023
4628ffc
fix sort dates and add setDisableWeekday function
uvarov-frontend Nov 19, 2023
a5c899e
fix visibility arrows and rename method
uvarov-frontend Nov 19, 2023
7274ee7
replace self.locale.weekday.length with 7
uvarov-frontend Nov 20, 2023
4253e44
refactoring "createMonths"
uvarov-frontend Nov 20, 2023
d434bf6
add createElements.ts
uvarov-frontend Nov 20, 2023
578d490
refactoring "createMonths", "createYears"
uvarov-frontend Nov 20, 2023
d420a7d
refactoring "createPopup"
uvarov-frontend Nov 21, 2023
fc68597
refactoring "createWeek"
uvarov-frontend Nov 21, 2023
9d980d7
remove createElements
uvarov-frontend Nov 21, 2023
5cc8582
refactoring "getWeekNumber"
uvarov-frontend Nov 21, 2023
75dc08b
refactoring "createWeekNumbers"
uvarov-frontend Nov 21, 2023
be32f6e
refactoring "destroyCalendar"
uvarov-frontend Nov 21, 2023
e6513a9
refactoring directories and aliases
uvarov-frontend Nov 21, 2023
8a9460a
directory refactoring
uvarov-frontend Nov 21, 2023
bc40944
fix import aliases
uvarov-frontend Nov 21, 2023
540550b
refactoring "setTheme"
uvarov-frontend Nov 25, 2023
d1ab403
rename files
uvarov-frontend Nov 25, 2023
ad40e0a
refactoring "showMonth" and "showYear"
uvarov-frontend Nov 25, 2023
9781d78
add "visibilityTitle"
uvarov-frontend Nov 25, 2023
7ffdbe8
refactoring "setVariables" and start fix global ts
uvarov-frontend Nov 26, 2023
ec8dddd
refactoring types
uvarov-frontend Nov 26, 2023
628ac9d
fix demo pages
uvarov-frontend Nov 26, 2023
c34a9e2
refactoring "createTime"
uvarov-frontend Nov 27, 2023
47d983e
rename "controlTime"
uvarov-frontend Nov 27, 2023
3db5955
refactoring "changeTime"
uvarov-frontend Nov 27, 2023
f6aa8f4
fix "createTime"
uvarov-frontend Nov 27, 2023
4a8037b
fix selectedMonth and selectedYear, closes #149
uvarov-frontend Nov 27, 2023
d95589b
fix alias and d.ts
uvarov-frontend Nov 27, 2023
a9d4cd0
fix interface IOptions
uvarov-frontend Nov 27, 2023
4c8a134
fix index.d.ts
uvarov-frontend Nov 27, 2023
c3294a5
fix demo
uvarov-frontend Nov 27, 2023
760bd8a
add .npmignore and fix .vanilla-calendar_multiple
uvarov-frontend Nov 27, 2023
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
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"class-methods-use-this": "off",
"max-len": ["error", { "code": 180 }],
"prefer-destructuring": ["error", { "object": true, "array": false }],
"indent": ["error", "tab", { "SwitchCase": 1 }],
"@typescript-eslint/indent": ["error", "tab", { "SwitchCase": 1 }]
"indent": "off",
"@typescript-eslint/indent": ["error", "tab", { "SwitchCase": 1 }],
"@typescript-eslint/lines-between-class-members": "off"
},
"overrides": [
{
Expand Down
9 changes: 8 additions & 1 deletion config/js.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ export default defineConfig({
lib: {
name: 'VanillaCalendar',
fileName(format, entryName) { return `${entryName}.min${format === 'es' ? '.mjs' : '.js'}`; },
entry: resolve(__dirname, '../package/src/scripts/vanilla-calendar.ts'),
entry: resolve(__dirname, '../package/src/vanilla-calendar.ts'),
},
},
resolve: {
alias: {
'@': resolve(__dirname, '../'),
'@src': resolve(__dirname, '../package/src'),
'@scripts': resolve(__dirname, '../package/src/scripts'),
},
},
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion demo/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
}

.input {
@apply bg-white py-2 px-3 rounded text-sm text-slate-900 w-64 border-gray-200 outline-none h-9 text-left
@apply bg-white py-2 px-3 rounded text-sm text-slate-900 w-64 border-gray-200 outline-none h-9 text-left inline-block
}
15 changes: 7 additions & 8 deletions demo/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import '@/package/src/styles/vanilla-calendar.css';
import '@/package/src/styles/themes/light.css';
import '@/package/src/styles/themes/dark.css';
import '@src/styles/vanilla-calendar.css';
import '@src/styles/themes/light.css';
import '@src/styles/themes/dark.css';
// import VanillaCalendar from '@/package/build/vanilla-calendar.min';
import VanillaCalendar from '@/package/src/scripts/vanilla-calendar';
import IVanillaCalendar, { Options } from '@/package/src';
import VanillaCalendar from '@src/vanilla-calendar';
import { IOptions } from '@src/types';

const config: Options = {
const config: IOptions = {
settings: {
selected: {
month: 3,
Expand All @@ -16,7 +16,6 @@ const config: Options = {
};

document.addEventListener('DOMContentLoaded', () => {
// @ts-ignore: VanillaCalendar config
const calendar: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar', config);
const calendar = new VanillaCalendar('#calendar', config);
calendar.init();
});
8 changes: 4 additions & 4 deletions demo/pages/input/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<body class="font-sans bg-white bg-light-mode text-slate-900 min-h-screen container mx-auto text-center flex flex-col items-center py-12 dark:bg-slate-900 dark:bg-dark-mode dark:text-white">
<h1 class="block mb-7 text-6xl font-extrabold">Vanilla Calendar</h1>
<p class="text-lg mb-12 dark:text-slate-400">A pure JavaScript date and time picker using TypeScript so it supports any JS framework and library.</p>
<label class="wrapper-calendar">
<span>Datepicker tag 'input'</span>
<label>
<div>Datepicker tag 'input'</div>
<input id="calendar-input" class="input" name="calendar" type="text" readonly />
</label>
<div class="wrapper-calendar">
<span>Datepicker tag 'div'</span>
<div>
<div>Datepicker tag 'div'</div>
<div id="calendar-div" class="input"></div>
</div>
</body>
Expand Down
21 changes: 10 additions & 11 deletions demo/pages/input/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import '@/package/src/styles/vanilla-calendar.css';
import '@/package/src/styles/themes/light.css';
import '@/package/src/styles/themes/dark.css';
import '@src/styles/vanilla-calendar.css';
import '@src/styles/themes/light.css';
import '@src/styles/themes/dark.css';
// import VanillaCalendar from '@/package/build/vanilla-calendar.min';
import VanillaCalendar from '@/package/src/scripts/vanilla-calendar';
import IVanillaCalendar, { Options } from '@/package/src';
import VanillaCalendar from '@src/vanilla-calendar';
import { IOptions } from '@src/types';

const configInput: Options = {
const configInput: IOptions = {
input: true,
actions: {
changeToInput(e, calendar, dates) {
Expand All @@ -21,7 +21,7 @@ const configInput: Options = {
},
};

const configDiv: Options = {
const configDiv: IOptions = {
input: true,
actions: {
changeToInput(e, calendar, dates) {
Expand All @@ -37,10 +37,9 @@ const configDiv: Options = {
};

document.addEventListener('DOMContentLoaded', () => {
// @ts-ignore: VanillaCalendar config
const calendarInput: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar-input', configInput);
const calendarInput = new VanillaCalendar('#calendar-input', configInput);
calendarInput.init();
// @ts-ignore: VanillaCalendar config
const calendarDiv: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar-div', configDiv);

const calendarDiv = new VanillaCalendar('#calendar-div', configDiv);
calendarDiv.init();
});
15 changes: 7 additions & 8 deletions demo/pages/multiple/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import '@/package/src/styles/vanilla-calendar.css';
import '@/package/src/styles/themes/light.css';
import '@/package/src/styles/themes/dark.css';
import '@src/styles/vanilla-calendar.css';
import '@src/styles/themes/light.css';
import '@src/styles/themes/dark.css';
// import VanillaCalendar from '@/package/build/vanilla-calendar.min';
import VanillaCalendar from '@/package/src/scripts/vanilla-calendar';
import IVanillaCalendar, { Options } from '@/package/src';
import VanillaCalendar from '@src/vanilla-calendar';
import { IOptions } from '@src/types';

const config: Options = {
const config: IOptions = {
type: 'multiple',
settings: {
selection: {
Expand All @@ -20,7 +20,6 @@ const config: Options = {
};

document.addEventListener('DOMContentLoaded', () => {
// @ts-ignore: VanillaCalendar config
const calendar: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar', config);
const calendar = new VanillaCalendar('#calendar', config);
calendar.init();
});
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@
"@types/node": "^18.14.4",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"autoprefixer": "^10.4.13",
"autoprefixer": "^10.4.16",
"cypress": "^12.11.0",
"eslint": "^8.35.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-cypress": "^2.13.2",
"eslint-plugin-import": "^2.27.5",
"postcss": "^8.4.21",
"postcss": "^8.4.31",
"start-server-and-test": "^2.0.0",
"tailwindcss": "^3.2.7",
"terser": "^5.16.5",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"vite": "^4.5.0",
"vite-plugin-banner": "^0.7.0",
"vite-plugin-eslint": "^1.8.1"
},
Expand Down
4 changes: 4 additions & 0 deletions package/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/vanilla-calendar.ts
src/scripts
src/styles
public
30 changes: 15 additions & 15 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Vanilla Calendar - A Lightweight, Feature-Rich JavaScript Date and Time Picker
# VanillaCalendar - A Lightweight, Feature-Rich JavaScript Date and Time Picker

[![vanilla-calendar preview](https://vanilla-calendar.com/vanilla-calendar-preview.png)](https://vanilla-calendar.com/)

[![package-badge]][package]

Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.
VanillaCalendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.

## Key Features

- **Lightweight**: The final minified .js file is only approximately **44.4 KB**, and with gzip compression, it's just around **10.8 KB**.
- **No Dependencies**: Vanilla Calendar is entirely self-contained, ensuring you don't need to include additional libraries.
- **No Dependencies**: VanillaCalendar is entirely self-contained, ensuring you don't need to include additional libraries.
- **Simple Localization**: Supports simple localization for any language.
- **Customizable**: Can be easily configured using CSS and HTML markup.
- **Multiple Instances**: Allows for an unlimited number of calendar instances on a single page.
Expand All @@ -20,7 +20,7 @@ Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript

## Browser Support

Vanilla Calendar is compatible with a wide range of browsers:
VanillaCalendar is compatible with a wide range of browsers:

![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png)
--- | --- | --- | --- | --- |
Expand All @@ -30,13 +30,13 @@ Vanilla Calendar is compatible with a wide range of browsers:

This plugin is completely free, and your support is important. Please feel free to report any issues or share your new ideas; it's really important!

If you like Vanilla Calendar, please consider giving it a 🌟 star on GitHub.
If you like VanillaCalendar, please consider giving it a 🌟 star on GitHub.

## Getting Started

### Installation

You can install Vanilla Calendar using npm or yarn:
You can install VanillaCalendar using npm or yarn:

```sh
npm install @uvarov.frontend/vanilla-calendar
Expand All @@ -48,7 +48,7 @@ If you prefer not to use a package manager, you can also include it via [CDN](ht

### Usage

Here's a simple example of how to use Vanilla Calendar in your HTML:
Here's a simple example of how to use VanillaCalendar in your HTML:

```html
<html>
Expand All @@ -65,18 +65,18 @@ Here's a simple example of how to use Vanilla Calendar in your HTML:
To add the necessary styles and scripts, you can use the following code:

```js
// Import Vanilla Calendar
import Vanilla Calendar from '@uvarov.frontend/vanilla-calendar';
// JS Script
import VanillaCalendar from '@uvarov.frontend/vanilla-calendar';

// Import the basic styles
// Basic styles
import '@uvarov.frontend/vanilla-calendar/build/vanilla-calendar.min.css';

// Import additional styles
// Additional styles
import '@uvarov.frontend/vanilla-calendar/build/themes/light.min.css';
import '@uvarov.frontend/vanilla-calendar/build/themes/dark.min.css';

// Initialize the calendar
const calendar = new Vanilla Calendar('#calendar');
const calendar = new VanillaCalendar('#calendar');
calendar.init();
// or
// const calendarWithInput = new VanillaCalendar('#calendar-input', { input: true });
Expand Down Expand Up @@ -110,7 +110,7 @@ If you're not using a package manager and prefer manual installation or CDN usag

## CSS Themes

Vanilla Calendar includes two CSS themes: the **light theme** and the **dark theme**.
VanillaCalendar includes two CSS themes: the **light theme** and the **dark theme**.

- The **vanilla-calendar.min.css** file contains the essential structural styles for the calendar.
- The **light.min.css** theme provides a light color scheme.
Expand All @@ -120,7 +120,7 @@ The calendar will automatically display the theme based on the user's system pre

## DOM Templates

Vanilla Calendar features customizable DOM templates that allow you to modify the structure of the calendar to fit your needs. The templates are identified by tags containing the **#** character, and they should include a trailing slash at the end.
VanillaCalendar features customizable DOM templates that allow you to modify the structure of the calendar to fit your needs. The templates are identified by tags containing the **#** character, and they should include a trailing slash at the end.

Here's an example of the default template:

Expand Down Expand Up @@ -151,7 +151,7 @@ new VanillaCalendar('#calendar', {

## React Component

For detailed instructions on using Vanilla Calendar in a React component with TypeScript, please visit the [website](https://vanilla-calendar.com/docs/learn/additional-features/react-component) for comprehensive documentation and examples.
For detailed instructions on using VanillaCalendar in a React component with TypeScript, please visit the [website](https://vanilla-calendar.com/docs/learn/additional-features/react-component) for comprehensive documentation and examples.

## API Reference

Expand Down
2 changes: 1 addition & 1 deletion package/build/themes/dark.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/build/themes/light.min.css

Large diffs are not rendered by default.

Loading