Skip to content

Commit

Permalink
Merge pull request #220 from uvarov-frontend/bugfix/change_theme
Browse files Browse the repository at this point in the history
Bugfix/change_theme
  • Loading branch information
uvarov-frontend authored Feb 19, 2024
2 parents 43ab048 + 9f9ebe0 commit d02cde6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
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.

2 changes: 1 addition & 1 deletion package/build/vanilla-calendar.layout.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/build/vanilla-calendar.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/build/vanilla-calendar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/build/vanilla-calendar.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanilla-calendar-pro",
"version": "2.9.4",
"version": "2.9.5",
"description": "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.",
"homepage": "https://vanilla-calendar.pro",
"keywords": [
Expand Down
9 changes: 7 additions & 2 deletions package/src/scripts/methods/changeTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ const trackChangesThemeInSystemSettings = (self: VanillaCalendar, supportDarkThe

if (self.settings.visibility.theme !== 'system' || haveListener.check()) return;

const changeDataAttrTheme = (event: MediaQueryList | MediaQueryListEvent) => {
const calendarEls = document.querySelectorAll(`.${self.CSSClasses.calendar}`);
calendarEls?.forEach((calendarEl) => setTheme(calendarEl as HTMLElement, event.matches ? 'dark' : 'light'));
};

if (supportDarkTheme.addEventListener) {
supportDarkTheme.addEventListener('change', setDataAttrTheme);
supportDarkTheme.addEventListener('change', changeDataAttrTheme);
} else {
supportDarkTheme.addListener(setDataAttrTheme);
supportDarkTheme.addListener(changeDataAttrTheme);
}
haveListener.set();
};
Expand Down

0 comments on commit d02cde6

Please sign in to comment.