From 39ae764bce77686cf2a0990f1086cbbc0b42ecca Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:38:10 +0530 Subject: [PATCH 01/14] wip --- lib/components/SDatePicker.vue | 258 ++++++++++++++++++ .../SDatePicker.01_Playground.story.vue | 15 + 2 files changed, 273 insertions(+) create mode 100644 lib/components/SDatePicker.vue create mode 100644 stories/components/SDatePicker.01_Playground.story.vue diff --git a/lib/components/SDatePicker.vue b/lib/components/SDatePicker.vue new file mode 100644 index 00000000..a40cfce9 --- /dev/null +++ b/lib/components/SDatePicker.vue @@ -0,0 +1,258 @@ + + + + + diff --git a/stories/components/SDatePicker.01_Playground.story.vue b/stories/components/SDatePicker.01_Playground.story.vue new file mode 100644 index 00000000..7035edd1 --- /dev/null +++ b/stories/components/SDatePicker.01_Playground.story.vue @@ -0,0 +1,15 @@ + + + From a4c3a4b6a1eb39fc541e08f51e8b731e861528c4 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:53:41 +0530 Subject: [PATCH 02/14] generic component --- .eslintrc.cjs | 4 +- lib/components/SDatePicker.vue | 57 ++- lib/components/SDatePickerBase.vue | 484 ++++++++++++++++++ lib/components/SDatePickerNew.vue | 22 + .../SDatePicker.01_Playground.story.vue | 2 +- 5 files changed, 566 insertions(+), 3 deletions(-) create mode 100644 lib/components/SDatePickerBase.vue create mode 100644 lib/components/SDatePickerNew.vue diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 040f848d..c504fbbe 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -8,6 +8,8 @@ module.exports = { ], rules: { - 'vue/no-template-shadow': 'off' + 'vue/no-template-shadow': 'off', + 'unused-imports/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': 'warn' } } diff --git a/lib/components/SDatePicker.vue b/lib/components/SDatePicker.vue index a40cfce9..47fa7923 100644 --- a/lib/components/SDatePicker.vue +++ b/lib/components/SDatePicker.vue @@ -165,6 +165,44 @@ function isFocusable(day: number): boolean { +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+ + + +
+
+
+ +
+
+
diff --git a/lib/components/SDatePickerNew.vue b/lib/components/SDatePickerNew.vue new file mode 100644 index 00000000..9a90f849 --- /dev/null +++ b/lib/components/SDatePickerNew.vue @@ -0,0 +1,22 @@ + + + diff --git a/stories/components/SDatePicker.01_Playground.story.vue b/stories/components/SDatePicker.01_Playground.story.vue index 7035edd1..686e6d81 100644 --- a/stories/components/SDatePicker.01_Playground.story.vue +++ b/stories/components/SDatePicker.01_Playground.story.vue @@ -1,5 +1,5 @@ From c8939b1a96f15e23b1d63df4f67cf98b6755de30 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:27:39 +0530 Subject: [PATCH 03/14] group layers --- lib/components/SDatePickerBase.vue | 192 +++++++++++++++-------------- lib/components/SDatePickerNew.vue | 40 ++++-- lib/support/Now.ts | 29 +++++ 3 files changed, 158 insertions(+), 103 deletions(-) create mode 100644 lib/support/Now.ts diff --git a/lib/components/SDatePickerBase.vue b/lib/components/SDatePickerBase.vue index deef8b54..4c65d31f 100644 --- a/lib/components/SDatePickerBase.vue +++ b/lib/components/SDatePickerBase.vue @@ -1,13 +1,23 @@ diff --git a/lib/support/Now.ts b/lib/support/Now.ts new file mode 100644 index 00000000..561d1169 --- /dev/null +++ b/lib/support/Now.ts @@ -0,0 +1,29 @@ +const now: SDate = { + get day() { + return new Date().getDate() + }, + get month() { + return new Date().getMonth() + 1 + }, + get year() { + return new Date().getFullYear() + } +} + +Object.defineProperty(now, 'valueOf', { + value: () => new Date().valueOf(), + enumerable: false +}) + +Object.defineProperty(now, 'getDay', { + value: () => new Date().getDay(), + enumerable: false +}) + +export { now } + +export interface SDate { + day: number + month: number + year: number +} From 0282222e6e84827e91277bd8f9975efc9d584918 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:29:08 +0530 Subject: [PATCH 04/14] remove old one --- lib/components/SDatePicker.vue | 323 ++---------------- lib/components/SDatePickerNew.vue | 36 -- .../SDatePicker.01_Playground.story.vue | 2 +- 3 files changed, 24 insertions(+), 337 deletions(-) delete mode 100644 lib/components/SDatePickerNew.vue diff --git a/lib/components/SDatePicker.vue b/lib/components/SDatePicker.vue index 47fa7923..e369aa95 100644 --- a/lib/components/SDatePicker.vue +++ b/lib/components/SDatePicker.vue @@ -1,313 +1,36 @@ - - diff --git a/lib/components/SDatePickerNew.vue b/lib/components/SDatePickerNew.vue deleted file mode 100644 index e369aa95..00000000 --- a/lib/components/SDatePickerNew.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/stories/components/SDatePicker.01_Playground.story.vue b/stories/components/SDatePicker.01_Playground.story.vue index 686e6d81..7035edd1 100644 --- a/stories/components/SDatePicker.01_Playground.story.vue +++ b/stories/components/SDatePicker.01_Playground.story.vue @@ -1,5 +1,5 @@ From 128afdad975ce7ce3888f1b6155ca0a836357f0f Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:51:30 +0530 Subject: [PATCH 05/14] remove raf hacks --- lib/components/SDatePickerBase.vue | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/components/SDatePickerBase.vue b/lib/components/SDatePickerBase.vue index 4c65d31f..c8a045c0 100644 --- a/lib/components/SDatePickerBase.vue +++ b/lib/components/SDatePickerBase.vue @@ -31,6 +31,16 @@ const format = { const weekdays = getWeekDays() +const key = computed(() => { + if (props.mode === 'days') { + return `${curr.value.month}-${curr.value.year}` + } + if (props.mode === 'months') { + return `${curr.value.year}` + } + return `${getYearForIndex(1)}-${getYearForIndex(20)}` +}) + const isSelectedVisible = computed(() => { if (props.mode === 'days') { return curr.value.month === selected.value.month && curr.value.year === selected.value.year @@ -239,7 +249,6 @@ function prev(action?: () => void): void { if (isPrevDisabled.value) { return } - el.value?.classList.add('no-transition') if (props.mode === 'days') { curr.value.month-- if (curr.value.month === 0) { @@ -252,14 +261,12 @@ function prev(action?: () => void): void { curr.value.year -= 20 } action?.() - requestAnimationFrame(() => el.value?.classList.remove('no-transition')) } function next(action?: () => void): void { if (isNextDisabled.value) { return } - el.value?.classList.add('no-transition') if (props.mode === 'days') { curr.value.month++ if (curr.value.month === 13) { @@ -272,7 +279,6 @@ function next(action?: () => void): void { curr.value.year += 20 } action?.() - requestAnimationFrame(() => el.value?.classList.remove('no-transition')) } function isToday(/** 1-indexed */ i: number): boolean { @@ -366,10 +372,10 @@ function getFormatter(fmt: Intl.DateTimeFormat, type?: string) {
{{ name }}
-
+
Date: Tue, 24 Sep 2024 00:07:27 +0530 Subject: [PATCH 06/14] adjust styles --- lib/components/SDatePickerBase.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/components/SDatePickerBase.vue b/lib/components/SDatePickerBase.vue index c8a045c0..3e583b28 100644 --- a/lib/components/SDatePickerBase.vue +++ b/lib/components/SDatePickerBase.vue @@ -361,7 +361,12 @@ function getFormatter(fmt: Intl.DateTimeFormat, type?: string) { -