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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactoring "createTime"
uvarov-frontend committed Nov 27, 2023
commit c34a9e2f03540d6aa17a9cd012995738c2f1ccb6
21 changes: 21 additions & 0 deletions package/src/scripts/helpers/createComponents.ts
Original file line number Diff line number Diff line change
@@ -51,3 +51,24 @@ export const WeekNumbers = (self: VanillaCalendar) => (self.settings.visibility.
export const ControlTime = (self: VanillaCalendar) => (self.settings.selection.time ? (`
<div class="${self.CSSClasses.time}"></div>
`) : '');

export const InputTime = (name:string, CSSClass: string, value: string, range: boolean) => (`
<label class="${CSSClass}">
<input type="text"
name="${name}"
maxlength="2"
value="${value}"
${range ? 'disabled' : ''}>
</label>
`);

export const RangeTime = (name: string, CSSClass: string, min: number, max: number, step: number, value: string) => (`
<label class="${CSSClass}">
<input type="range"
name="${name}"
min="${min}"
max="${max}"
step="${step}"
value="${value}">
</label>
`);
58 changes: 18 additions & 40 deletions package/src/scripts/methods/createTime.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,31 @@
import VanillaCalendar from '@scripts/vanilla-calendar';
import { InputTime, RangeTime } from '@scripts/helpers/createComponents';
import transformTime24 from '@scripts/helpers/transformTime24';
import controlTime from '@scripts/methods/controlTime';

const createTime = (self: VanillaCalendar) => {
const timeEl = self.HTMLElement.querySelector(`.${self.CSSClasses.time}`);
if (!timeEl) return;

const keepingTime = self.settings.selection.time === true ? 12 : self.settings.selection.time;
const range = self.settings.selection.controlTime === 'range';
const [minHour, maxHour] = [0, 23];
const [minMinutes, maxMinutes] = [0, 59];

timeEl.innerHTML = `
<div class="${self.CSSClasses.timeContent}">
<label class="${self.CSSClasses.timeHours}">
<input type="text"
name="hours"
maxlength="2"
value="${self.selectedHours}"
${range ? 'disabled' : ''}>
</label>
<label class="${self.CSSClasses.timeMinutes}">
<input type="text"
name="minutes"
maxlength="2"
value="${self.selectedMinutes}"
${range ? 'disabled' : ''}>
</label>
${keepingTime === 12 ? `
<button type="button"
class="${self.CSSClasses.timeKeeping}"
${range ? 'disabled' : ''}>${self.selectedKeeping}</button>
` : ''}
</div>
<div class="${self.CSSClasses.timeRanges}">
<label class="${self.CSSClasses.timeRange}">
<input type="range"
name="hours"
min="0"
max="23"
step="${self.settings.selection.stepHours}"
value="${self.selectedKeeping ? transformTime24(self.selectedHours, self.selectedKeeping) : self.selectedHours}">
</label>
<label class="${self.CSSClasses.timeRange}">
<input type="range"
name="minutes"
min="0"
max="59"
step="${self.settings.selection.stepMinutes}"
value="${self.selectedMinutes}">
</label>
</div>`;
timeEl.innerHTML = (`
<div class="${self.CSSClasses.timeContent}">
${InputTime('hours', self.CSSClasses.timeHours, self.selectedHours, range)}
${InputTime('minutes', self.CSSClasses.timeMinutes, self.selectedMinutes, range)}
${keepingTime === 12 ? `
<button type="button" class="${self.CSSClasses.timeKeeping}"
${range ? 'disabled' : ''}>${self.selectedKeeping}</button>` : ''}
</div>
<div class="${self.CSSClasses.timeRanges}">
${RangeTime('hours', self.CSSClasses.timeRange, minHour, maxHour, self.settings.selection.stepHours, self.selectedKeeping
? transformTime24(self.selectedHours, self.selectedKeeping) : self.selectedHours)}
${RangeTime('minutes', self.CSSClasses.timeRange, minMinutes, maxMinutes, self.settings.selection.stepMinutes, self.selectedMinutes)}
</div>
`);

controlTime(self, keepingTime);
};