Skip to content

Commit

Permalink
add docs and changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
MarceloPrado committed Apr 18, 2024
1 parent a97867a commit dd68c15
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-papayas-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marceloterreiro/flash-calendar": patch
---

- Add an optional `calendarColorScheme` prop that enables overriding the color scheme used by Flash Calendar.
34 changes: 33 additions & 1 deletion apps/docs/docs/fundamentals/tips-and-tricks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export function ImperativeScrolling() {

## Setting Border Radius to `Calendar.Item.Day`

To apply a border radius to the `Calendar.Item.Day` component, it's necessary to specify the radius for all four corners. Here's an example of how to achieve this:
To apply a border radius to the `Calendar.Item.Day` component, it's necessary to
specify the radius for all four corners. Here's an example of how to achieve
this:

```tsx
itemDay: {
Expand All @@ -123,3 +125,33 @@ itemDay: {
}),
}
```

## Avoiding dark mode

If your app doesn't support dynamic themes, you can override Flash Calendar's
color scheme by passing a `calendarColorScheme` prop:

```tsx
export const LightModeOnly = () => {
const { calendarActiveDateRanges, onCalendarDayPress } = useDateRange({
startId: "2024-02-04",
endId: "2024-02-09",
});

return (
<Calendar
calendarActiveDateRanges={calendarActiveDateRanges}
calendarColorScheme="light"
calendarMonthId={toDateId(startOfThisMonth)}
onCalendarDayPress={onCalendarDayPress}
/>
);
};
```

When set, Flash Calendar's theming system will use this scheme instead of the
user system's theme.

**Note**: you should avoid using this prop. Instead, your app should
support dynamic themes that react to the user's system preferences. The prop is
provided as an escape hatch for apps that doesn't support dynamic themes yet.
16 changes: 16 additions & 0 deletions packages/flash-calendar/src/components/Calendar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,19 @@ export const ControlledColorScheme: StoryObj<typeof Calendar> = {
calendarColorScheme: "dark",
},
};

export const LightModeOnly = () => {
const { calendarActiveDateRanges, onCalendarDayPress } = useDateRange({
startId: "2024-02-04",
endId: "2024-02-09",
});

return (
<Calendar
calendarActiveDateRanges={calendarActiveDateRanges}
calendarColorScheme="light"
calendarMonthId={toDateId(startOfThisMonth)}
onCalendarDayPress={onCalendarDayPress}
/>
);
};

0 comments on commit dd68c15

Please sign in to comment.