Skip to content

Commit

Permalink
feat: pass global styles to tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictwlee committed May 1, 2020
1 parent 57a531e commit c6c9b34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { forwardRef, ReactNode, Ref } from 'react';
import { useSpring, animated as Animated } from 'react-spring';
import usePopper from './usePopper';
import useAnimLifecycle from './useAnimLifecycle';
import { GlobalStyles } from 'types';

const popperOptions = {
modifiers: [
Expand All @@ -22,10 +23,11 @@ type TooltipProps = {
pos: number;
animated?: boolean;
index?: number;
styles?: GlobalStyles['tooltip'];
};

export const Tooltip = forwardRef<Ref<any>, TooltipProps>((props, ref) => {
const { anchorEl, show, children, curPos, pos, animated } = props;
const { anchorEl, show, children, curPos, pos, animated, styles } = props;

const { selfRef, destroy } = usePopper({
anchorEl,
Expand All @@ -49,6 +51,7 @@ export const Tooltip = forwardRef<Ref<any>, TooltipProps>((props, ref) => {
},
onStart: handleAnimStart,
onRest: handleAnimRest,
config: styles && styles.spring,
});

if (!show && (!animated || animLifecycle === 'idle')) {
Expand Down
1 change: 1 addition & 0 deletions src/Tourguide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const Tourguide = (props: TourguideProps) => {
curPos={curPos}
animated
index={index}
styles={styles && styles.tooltip}
>
{Array.isArray(Component) ? (
Component[index]
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type StyleConfig = {

export type GlobalStyles = {
spotlight?: StyleConfig;
tooltip?: StyleConfig;
};

export type PositionStyles = {
Expand Down

0 comments on commit c6c9b34

Please sign in to comment.