-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update setDateModifier.ts, handleHoverDatesEvent.ts, toggleHoverEffec…
…t.ts and layout.css
- Loading branch information
1 parent
5ea7001
commit 7b3c8b4
Showing
4 changed files
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
package/src/scripts/handles/handleSelectDateRange/toggleHoverEffect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import state from '@scripts/handles/handleSelectDateRange/state'; | ||
import getDateString from '@scripts/utils/getDateString'; | ||
|
||
export const addHoverEffect = (date: Date, firstDateEl: HTMLElement | null, lastDateEl: HTMLElement | null) => { | ||
export const addHoverEffect = (date: Date, firstDateEls: NodeListOf<HTMLElement>, lastDateEls: NodeListOf<HTMLElement>) => { | ||
if (!state.self?.context?.selectedDates[0]) return; | ||
|
||
const formattedDate = getDateString(date); | ||
if (state.self.context.disableDates?.includes(formattedDate)) return; | ||
|
||
state.self.context.mainElement.querySelectorAll<HTMLElement>(`[data-vc-date="${formattedDate}"]`).forEach((d) => (d.dataset.vcDateHover = '')); | ||
if (firstDateEl) firstDateEl.dataset.vcDateHoverFirst = ''; | ||
if (lastDateEl) lastDateEl.dataset.vcDateHoverLast = ''; | ||
firstDateEls.forEach((d) => (d.dataset.vcDateHover = 'first')); | ||
lastDateEls.forEach((d) => { | ||
if (d.dataset.vcDateHover === 'first') { | ||
d.dataset.vcDateHover = 'first-and-last'; | ||
} else { | ||
d.dataset.vcDateHover = 'last'; | ||
} | ||
}); | ||
}; | ||
|
||
export const removeHoverEffect = () => { | ||
if (!state.self?.context?.mainElement) return; | ||
const dateEls = state.self.context.mainElement.querySelectorAll<HTMLElement>('[data-vc-date-hover], [data-vc-date-hover-first], [data-vc-date-hover-last]'); | ||
dateEls.forEach((d) => { | ||
d.removeAttribute('data-vc-date-hover'); | ||
d.removeAttribute('data-vc-date-hover-first'); | ||
d.removeAttribute('data-vc-date-hover-last'); | ||
}); | ||
const dateEls = state.self.context.mainElement.querySelectorAll<HTMLElement>('[data-vc-date-hover]'); | ||
dateEls.forEach((d) => d.removeAttribute('data-vc-date-hover')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters