Skip to content
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

renderBlock returns nothing #32

Open
bigint opened this issue Jul 17, 2023 · 10 comments
Open

renderBlock returns nothing #32

bigint opened this issue Jul 17, 2023 · 10 comments

Comments

@bigint
Copy link

bigint commented Jul 17, 2023

renderBlock={(block, activity) => <div>{block}</div>}
Screenshot 2023-07-17 at 6 16 39 PM
@grubersjoe
Copy link
Owner

What are you trying to achieve?

The divs are rendered, but since the calendar is SVG based it is not expected that the <rect /> block elements are wrapped arbitrarily. In this case nothing will be visible, because the SVG will become invalid:

image

But you can for example add (valid) children to the blocks:

renderBlock={(block, activity) =>
  cloneElement(block, {
    children: <title>{activity.date}</title>,
  })
}
image

@bigint
Copy link
Author

bigint commented Jul 18, 2023

@grubersjoe I'm trying to add tooltip i tried your approach as well its not working 🙇🏼

renderBlock={(block, activity) =>
  cloneElement(block, {
    children: (
      <Tooltip content={`gm`} placement="top">
        {block}
      </Tooltip>
    )
  })
}

@bigint
Copy link
Author

bigint commented Jul 18, 2023

renderBlock={(block, activity) => (
          <Tooltip content={`gm`} placement="top">
            {block}
          </Tooltip>
        )}

this one also not working 🙇🏼

@bigint
Copy link
Author

bigint commented Jul 18, 2023

@bigint
Copy link
Author

bigint commented Jul 21, 2023

Any ideas how to fix?

@marcelscruz
Copy link

marcelscruz commented Aug 8, 2023

I'm facing a similar issue as @bigint, as I'm wrapping block with Mantine's Tooltip, but hovering on it doesn't trigger the tooltip.

@Cihatata
Copy link

Cihatata commented Sep 5, 2023

Any ideas how to fix?

@grubersjoe
Copy link
Owner

grubersjoe commented Sep 26, 2023

Hey people. I haven't forgotten about this issue but I've realized from your comments that it seems pretty hard to support the whole variety of tooltip libraries since they're all implemented differently. I will try to come up with a better solution, but in general it seems difficult.

Maybe a "headless" approach where styling is up to the component user would be best. It's a bit more work, but very flexible. Floating UI looks promising for example. react-tooltip also uses it since v5 internally.

@PhilipGrefe
Copy link

Has anyone achieved this using the radix-ui tooltip?
It uses Floating UI under the hood IIRC.

@PhilipGrefe
Copy link

Has anyone achieved this using the radix-ui tooltip? It uses Floating UI under the hood IIRC.

FYI it can work like this:

const CustomTooltip = ({ children, count, date }: { children: React.ReactNode; count: number; date: string }) => (
  <Tooltip.Root>
    <Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
    <Tooltip.Portal>
      <Tooltip.Content sideOffset={10} side="top">
        <div>
          your tooltip content
        </div>
        <Tooltip.Arrow />
      </Tooltip.Content>
    </Tooltip.Portal>
  </Tooltip.Root>
)

Usage in ActivityCalendar

<TooltipProvider>
  <ActivityCalendar
    data={data}
    renderBlock={(block, activity) => (
      <CustomTooltip date={activity.date} count={activity.count}>
        {block}
      </CustomTooltip>
    )}
  />
</TooltipProvider>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants