acro5piano / react-native-big-calendar

gcal/outlook like calendar component for React Native
https://react-native-big-calendar.vercel.app
MIT License
446 stars 149 forks source link

Event cell color different for each event (issue #823 follow up) #825

Closed nicolas-chalant closed 1 year ago

nicolas-chalant commented 1 year ago

Hello @acro5piano,

On my previous answer on the #823 issue, I tried to change the style with the prop eventCellStyle, which worked, but it changed all events colors at the same time. My goal is to have different colors based on the type of the event.

I have a function that returns the style based on the type, but eventCellStyle takes only one style, right ? I cannot give it an array (or a prop color on each event) that could take multiple styles in order to have a specific style on an event, or am I missing something ?

I also tried to give a look at EventRenderer, but it seems that your stroybook is no longer found on github https://github.com/acro5piano/react-native-big-calendar/blob/main/stories/index.stories.tsx image

acro5piano commented 1 year ago

Thanks for your issue.

I have a function that returns the style based on the type, but eventCellStyle takes only one style, right ?

I didn't notice this, but yes. I'll the code to enable to have multiple styles soon.

I also tried to give a look at EventRenderer, but it seems that your stroybook is no longer found on github

Fixed!

acro5piano commented 1 year ago

Fixed on v3.4.1, without changing code. It was just type-changed.

@nicolas-chalant Can you try the new version? It might work only on the Web platform. Thanks

nicolas-chalant commented 1 year ago

Thanks for the update, I'm checking it !

nicolas-chalant commented 1 year ago

With the storybook I reached my goal ! Thanks again for your help.

I did not need the style array actually, but I tried it and it seems to work.

For those wondering, I used a customize event with a color prop and add those lines in the calendar :

eventCellStyle={(event) => {
      const backgroundColor = event.color
      return { backgroundColor }
}}

Screenshot_20230209-151932