-
Notifications
You must be signed in to change notification settings - Fork 9
feat(OnyxCalendar): implement individual disabled dates #4281
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
Open
ChristianBusshoff
wants to merge
12
commits into
main
Choose a base branch
from
feat-4258/Implement-individual-disabled-dates-for-OnyxCalendar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+155
−31
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1514f0a
implemented individual disabled dates
ChristianBusshoff 34a412e
docs(changeset): feat(OnyxCalendar): implemented individual disabled …
ChristianBusshoff 9ff8e81
Merge branch 'main' into feat-4258/Implement-individual-disabled-date…
ChristianBusshoff c4944ea
fix test
ChristianBusshoff 5a2a19b
chore: update Playwright screenshots (#4292)
github-actions[bot] 555a443
Merge branch 'main' into feat-4258/Implement-individual-disabled-date…
ChristianBusshoff 1dfaf96
resolve comments
ChristianBusshoff e2a548b
Update packages/sit-onyx/src/components/OnyxCalendar/types.ts
ChristianBusshoff 3491927
Merge branch 'main' into feat-4258/Implement-individual-disabled-date…
ChristianBusshoff 620925b
remove old screenshots
ChristianBusshoff d641336
remove screenshots
ChristianBusshoff a1ff9e3
chore: update Playwright screenshots (#4325)
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@sit-onyx/headless": minor | ||
| "sit-onyx": minor | ||
| --- | ||
|
|
||
| feat(OnyxCalendar): implemented individual disabled dates |
This file contains hidden or 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 hidden or 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
Binary file removed
BIN
-60.8 KB
...t/snapshots/components/OnyxCalendar/OnyxCalendar-custom-content--edge-linux.png
Binary file not shown.
Binary file removed
BIN
-97.2 KB
...napshots/components/OnyxCalendar/OnyxCalendar-custom-content--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-73.2 KB
...snapshots/components/OnyxCalendar/OnyxCalendar-custom-content--webkit-linux.png
Binary file not shown.
Binary file added
BIN
+113 KB
...s/OnyxCalendar/OnyxCalendar-custom-content-custom-disabled-days--edge-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+179 KB
...nyxCalendar/OnyxCalendar-custom-content-custom-disabled-days--firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+146 KB
...OnyxCalendar/OnyxCalendar-custom-content-custom-disabled-days--webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-56.8 KB
...ywright/snapshots/components/OnyxCalendar/OnyxCalendar-day-slot--edge-linux.png
Binary file not shown.
Binary file removed
BIN
-98.6 KB
...ight/snapshots/components/OnyxCalendar/OnyxCalendar-day-slot--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-70.4 KB
...right/snapshots/components/OnyxCalendar/OnyxCalendar-day-slot--webkit-linux.png
Binary file not shown.
Binary file removed
BIN
-198 KB
...wright/snapshots/components/OnyxCalendar/OnyxCalendar-selection--edge-linux.png
Binary file not shown.
Binary file removed
BIN
-338 KB
...ght/snapshots/components/OnyxCalendar/OnyxCalendar-selection--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-250 KB
...ight/snapshots/components/OnyxCalendar/OnyxCalendar-selection--webkit-linux.png
Binary file not shown.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
packages/sit-onyx/src/components/OnyxCalendar/examples/DisabledDaysExample.vue
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <script setup lang="ts"> | ||
| import { ref, watch } from "vue"; | ||
| import { OnyxUnstableCalendar, type DateRange } from "../../../index.js"; | ||
| import OnyxSwitch from "../../OnyxSwitch/OnyxSwitch.vue"; | ||
|
|
||
| const selected = ref<DateRange>(); | ||
| const dynamicMin = ref<Date | undefined>(); | ||
| const dynamicMax = ref<Date | undefined>(); | ||
| const includeDisabledDays = ref(false); | ||
|
|
||
| /** | ||
| * Checks if a given date is a weekend (Sunday or Saturday). | ||
| * Used to disable weekend days in the calendar. | ||
| */ | ||
| const isDisabled = (date: Date) => date.getDay() === 0 || date.getDay() === 6; | ||
|
|
||
| /** | ||
| * Dynamically sets the calendar's min and max constraints | ||
| * to prevent the user from selecting a range that includes a disabled day (weekend). | ||
| */ | ||
| watch(selected, (newRange) => { | ||
| if (newRange?.start && !newRange.end && !includeDisabledDays.value) { | ||
| const start = new Date(newRange.start); | ||
| const nextDisabledDay = new Date(start); | ||
| nextDisabledDay.setDate(nextDisabledDay.getDate() + 1); | ||
| while (!isDisabled(nextDisabledDay)) { | ||
| nextDisabledDay.setDate(nextDisabledDay.getDate() + 1); | ||
| } | ||
| dynamicMax.value = nextDisabledDay; | ||
| const prevDisabledDay = new Date(start); | ||
| prevDisabledDay.setDate(prevDisabledDay.getDate() - 1); | ||
| while (!isDisabled(prevDisabledDay)) { | ||
| prevDisabledDay.setDate(prevDisabledDay.getDate() - 1); | ||
| } | ||
| dynamicMin.value = prevDisabledDay; | ||
| } else { | ||
| dynamicMin.value = undefined; | ||
| dynamicMax.value = undefined; | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <OnyxSwitch v-model="includeDisabledDays" label="Range is allowed to have disabled days " /> | ||
| <OnyxUnstableCalendar | ||
| v-model="selected" | ||
| :disabled="isDisabled" | ||
| class="calendar" | ||
| selection-mode="range" | ||
| :min="dynamicMin" | ||
| :max="dynamicMax" | ||
| /> | ||
| </template> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .calendar { | ||
| max-width: 45rem; | ||
| } | ||
| </style> |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.