diff --git a/.changeset/shiny-pigs-talk.md b/.changeset/shiny-pigs-talk.md deleted file mode 100644 index 892677f..0000000 --- a/.changeset/shiny-pigs-talk.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -"@marceloterreiro/flash-calendar": major ---- - -# Flash Calendar 1.0.0 🚢 🎉 - -This release officially marks the package as ready for production use (`1.0.0`). -While it's been stable since the first release, bumping to `1.0.0` was something -I had in mind for a while. - -- New: Add `.scrollToMonth` and `.scrollToDate`, increasing the options available for imperative scrolling. - -## Breaking changes - -This release introduces one slightly change in behavior if you're app uses -imperative scrolling. Previously, `.scrollToDate` would scroll to the month -containing the date instead of the exact date. Now, `.scrollToDate` will scroll -to the exact date as the name suggests. - -If you intentionally want to scroll to the month instead, a new `.scrollToMonth` -method was added (same signature). - -I don't expect this to cause any issues for existing apps, but worth mentioned -nonetheless. diff --git a/apps/example/src/components/GithubIssues/CalendarListGithubIssues.stories.tsx b/apps/example/src/components/GithubIssues/CalendarListGithubIssues.stories.tsx index 1ec460f..3582a98 100644 --- a/apps/example/src/components/GithubIssues/CalendarListGithubIssues.stories.tsx +++ b/apps/example/src/components/GithubIssues/CalendarListGithubIssues.stories.tsx @@ -1,7 +1,12 @@ +import type { + CalendarOnDayPress, + CalendarTheme, +} from "@marceloterreiro/flash-calendar"; import { Calendar, toDateId } from "@marceloterreiro/flash-calendar"; import type { Meta } from "@storybook/react"; -import React, { useState } from "react"; -import { Text, View } from "react-native"; +import React, { useCallback, useMemo, useState } from "react"; +import { Alert, Text, View } from "react-native"; +import { useTheme } from "@/hooks/useTheme"; const CalendarMeta: Meta = { title: "Calendar.List/Github Issues", @@ -59,3 +64,63 @@ export const Issue16 = () => { ); }; + +const disabledRange = { + start: "2024-06-01", + end: "2024-06-15", +}; + +function isDisabled(dateId: string) { + return dateId >= disabledRange.start && dateId <= disabledRange.end; +} + +// See more: https://github.com/MarceloPrado/flash-calendar/issues/38 +export const Issue38 = () => { + const [selectedDate, setSelectedDate] = useState(today); + const { colors } = useTheme(); + + const customTheme = useMemo(() => { + const theme: CalendarTheme = { + itemDay: { + idle: ({ id }) => { + if (isDisabled(id)) { + return { + container: {}, + content: { + color: colors.content.disabled, + }, + }; + } + return {}; + }, + }, + }; + + return theme; + }, [colors.content.disabled]); + + const handleCalendarDayPress: CalendarOnDayPress = useCallback((dateId) => { + if (isDisabled(dateId)) { + Alert.alert("This date is disabled"); + return; + } + setSelectedDate(dateId); + }, []); + + const calendarActiveDateRanges = useMemo(() => { + if (!selectedDate) return []; + return [{ startId: selectedDate, endId: selectedDate }]; + }, [selectedDate]); + + return ( + + Selected date: {selectedDate} + + + ); +}; diff --git a/packages/flash-calendar/CHANGELOG.md b/packages/flash-calendar/CHANGELOG.md index cc17ff5..4e576e8 100644 --- a/packages/flash-calendar/CHANGELOG.md +++ b/packages/flash-calendar/CHANGELOG.md @@ -1,5 +1,30 @@ # @marceloterreiro/flash-calendar +## 1.0.0 + +### Major Changes + +- 9bf22ed: # Flash Calendar 1.0.0 🚢 🎉 + + This release officially marks the package as ready for production use (`1.0.0`). + While it's been stable since the first release, bumping to `1.0.0` was something + I had in mind for a while. + + - New: Add `.scrollToMonth` and `.scrollToDate`, increasing the options available for imperative scrolling. + + ## Breaking changes + + This release introduces one slightly change in behavior if you're app uses + imperative scrolling. Previously, `.scrollToDate` would scroll to the month + containing the date instead of the exact date. Now, `.scrollToDate` will scroll + to the exact date as the name suggests. + + If you intentionally want to scroll to the month instead, a new `.scrollToMonth` + method was added (same signature). + + I don't expect this to cause any issues for existing apps, but worth mentioned + nonetheless. + ## 0.0.9 ### Patch Changes diff --git a/packages/flash-calendar/package.json b/packages/flash-calendar/package.json index 5d50899..09acdaa 100644 --- a/packages/flash-calendar/package.json +++ b/packages/flash-calendar/package.json @@ -1,6 +1,6 @@ { "name": "@marceloterreiro/flash-calendar", - "version": "0.0.9", + "version": "1.0.0", "private": false, "description": "A better calendar for React Native.", "repository": {