Skip to content

Releases: grubersjoe/react-activity-calendar

Support for server side rendering (SSR)

21 Oct 22:05
Compare
Choose a tag to compare

Server side rendering is supported now. See this test repository for working examples for Astro, Next.js, Remix and Vite:
https://github.com/grubersjoe/react-activity-calendar-tests

Addtionally, this package also exports <ActivityCalendar /> as named export now. In some environment it seems crucial to use the named export instead of the default one. The default export will be removed in the next major version.

// Please do this
import { ActivityCalendar } from 'react-activity-calendar';

// Instead of this in future
import ActivityCalendar from 'react-activity-calendar';

chroma.js no longer required for color calculations

21 Oct 21:34
Compare
Choose a tag to compare

As of v2.6 the chroma.js dependency could be dropped completely. Instead of relying on JavaScript for the color calculations, CSS is now used. chroma.js was mainly chosen because it allows the calculation of harmonic color gradients in well-suited color spaces like Lab. However, these color spaces are now also available in CSS using color-mix and allow interpolating colors in the same manner.

Consequently, the bundle size of this package could be reduced by roughly 33% from 129 kB to 87 kB (minified, not gzipped) while keeping the functionality and API the same:

https://bundlephobia.com/package/[email protected]

Setting weekday label visibility individually

30 Aug 20:32
Compare
Choose a tag to compare

The showWeekdayLabels prop not only takes a boolean but also a a list of ISO 8601 weekday for finer control which weekdays to show now: Story.

<ActivityCalendar data={data} showWeekdayLabels={['mon', 'fri']} />

Added renderLegendBlock prop

30 Aug 20:27
Compare
Choose a tag to compare

Added the renderColorLegend render prop to allow customizing how the color legend elements are rendered. For example, useful to add tooltips (compare the renderBlock prop): Story.

Thanks @AliceLeyou for the contribution!

<ActivityCalendar
  data={data}
  renderColorLegend={(block, level) => (
    <MuiTooltip title={`Level: ${level}`}>{block}</MuiTooltip>
  )}
/>

Added ref prop

30 Aug 20:24
Compare
Choose a tag to compare

Added a ref prop to allow access to the calendar DOM node.

const Component = () => {
  const calendarRef = useRef<HTMLElement>(null);

  return <ActivityCalendar data={data} ref={calendarRef} />;
}

Arbitrary number of activity levels

25 Nov 07:27
Compare
Choose a tag to compare

Added the maxLevel prop to support any number of activity levels: example. See issue #37 for context.

image

Thanks @eschreiner for the good idea 👍.

Improved styling on narrow screens

06 Nov 22:12
Compare
Choose a tag to compare

Instead of scaling the calendar down on narrow screens the container will overflow horizontally now. This follows what GitHub is doing on mobile devices. See issue #35 for details

v2

07 Apr 23:26
Compare
Choose a tag to compare
v2

image

New

  • Added dark mode support ✨
  • Added colorScheme prop 🌈
  • Added renderBlock prop to control how blocks are rendered 🧱
    This allows you to use all kinds of various tooltip components.
  • The loading animation respects the prefers-reduced-motion: reduce setting now

Breaking changes

  • Removed the color prop
    Use the theme prop instead to set the calendar colors for the light and dark system color scheme. By default, the calendar will use the currently set system color scheme, but you can enforce a specific color scheme with the colorScheme prop. Define each color scale explicitly with n colors, where n is the number of activity levels, or pass exactly two colors (lowest and highest intensity) to calculate a single-hue scale. Colors can be specified in any valid CSS format: theming example.
  • Removed exported utility function calculateTheme()
    Use the theme prop instead.
  • Removed the children prop
    Use the renderBlock prop instead.
  • Removed the dateFormat prop
    No longer necessary with renderBlock. If needed, you can format dates with any function.
  • Removed the labels.tooltip message
    No longer necessary with renderBlock. You can fully control what is rendered now.
  • Changed the default message for labels.totalCount
    {{count}} activities in {{year}} instead of {{count} contributions in {{year}}

Bugfixes

  • Fixed vertical alignment of SVG <text> nodes in Firefox

Custom tooltip labels

26 May 15:39
Compare
Choose a tag to compare

Thanks to @MarcioMeier a custom label can be set for the tooltip message now. The placeholders {{count}} and {{date}} are supported.

const labels = {
  tooltip: '<i>{{count}} views</i> on {{date}}'
};

<ActivityCalendar data={...} labels={labels} />

Support for event handlers

14 Nov 14:43
Compare
Choose a tag to compare

You can register event handlers for the SVG <rect/> elements that are used to render the calendar days now. This way you can control the behaviour on click, hover, etc.

See https://grubersjoe.github.io/react-activity-calendar/?path=/story/activity-calendar--event-handlers.