From 650ab36b1cd4a48b4867bce9a94523324c4cc9e4 Mon Sep 17 00:00:00 2001 From: Gil Barbara Date: Thu, 12 Sep 2024 11:43:16 -0300 Subject: [PATCH] Update custom-components docs --- docs/custom-components.md | 120 +++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/docs/custom-components.md b/docs/custom-components.md index 0f327f5a3..f0e4a7dda 100644 --- a/docs/custom-components.md +++ b/docs/custom-components.md @@ -22,8 +22,11 @@ If you want to customize the default UI, check the [styling](styling.md) docs. ### Example with styled-components -```jsx -import Joyride, { BeaconRenderProps, TooltipRenderProps } from 'react-joyride'; +```tsx +import { forwardRef } from 'react'; +import Joyride, { BeaconRenderProps } from 'react-joyride'; +import { keyframes } from '@emotion/react'; +import styled from '@emotion/styled'; const pulse = keyframes` 0% { @@ -45,15 +48,20 @@ const Beacon = styled.span` width: 3rem; `; -export () => ( -
- } for TS - ... - /> -
-); +const BeaconComponent = forwardRef((props, ref) => { + return ; +}); + +export function App() { + return ( +
+ +
+ ); +} ``` ## tooltipComponent @@ -80,47 +88,51 @@ export () => ( **tooltipProps** {object}: The root element props \(including `ref`\) -### Example with styled-components - -```jsx -const Tooltip = ({ - continuous, - index, - step, - backProps, - closeProps, - primaryProps, - tooltipProps, -}) => ( - - {step.title && {step.title}} - {step.content} - - {index > 0 && ( - - )} - {continuous && ( - - )} - {!continuous && ( - - )} - - -); - -export () => ( -
- -
-); +### Example with css classes + +```tsx +import Joyride, { TooltipRenderProps } from 'react-joyride'; + +function CustomTooltip(props: TooltipRenderProps) { + const { backProps, closeProps, continuous, index, primaryProps, skipProps, step, tooltipProps } = + props; + + return ( +
+ + {step.title &&

{step.title}

} +
{step.content}
+
+ +
+ {index > 0 && ( + + )} + {continuous && ( + + )} +
+
+
+ ); +} + +export function App() { + return ( +
+ +
+ ); +} ```