Skip to content

Commit

Permalink
updated component visibility prop nesting on main RGT component
Browse files Browse the repository at this point in the history
  • Loading branch information
Eitan Elbaz committed Jun 27, 2023
1 parent 386b031 commit 6360d09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/ReactGrandTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ const ReactGrandTour: React.FC<Props> = ({
disableCloseOnBackdropClick = false,
stylingOverrides = emptyStyles,
keyboardShortcuts,
componentVisibility = emptyVisibility,
hideCloseButton,
hideCurrentStepLabel,
hideNextStepButton,
hidePreviousStepButton,
hideStepButtons,
}) => {
const [open, setOpen] = useState(defaultOpen);
const [currentIndex, setCurrentIndex] = useState(openAt);
Expand Down Expand Up @@ -172,6 +176,7 @@ const ReactGrandTour: React.FC<Props> = ({
};
}, [onKeyUp]);

console.log(steps[currentIndex]);
return (
<ReactGrandTourContext.Provider
value={{
Expand All @@ -191,7 +196,11 @@ const ReactGrandTour: React.FC<Props> = ({
<style>{styles(stylingOverrides)}</style>{' '}
<div className="__react-grand-tour__overlay" onClick={onBackdropClosed} />
<Step
{...componentVisibility}
hideCloseButton={hideCloseButton}
hideCurrentStepLabel={hideCurrentStepLabel}
hideNextStepButton={hideNextStepButton}
hidePreviousStepButton={hidePreviousStepButton}
hideStepButtons={hideStepButtons}
{...steps[currentIndex]}
content={steps[currentIndex].content}
component={steps[currentIndex].component}
Expand Down
6 changes: 2 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PropsWithChildren, ReactNode } from 'react';

export type ReactGrandTourProps = {
export type ReactGrandTourProps = ComponentVisibility & {
open?: boolean;
onOpen?: () => void;
onClose?: (reason: ReactGrandTourCloseReason) => void;
Expand All @@ -14,8 +14,6 @@ export type ReactGrandTourProps = {
disableCloseOnBackdropClick?: boolean;
stylingOverrides?: ReactGrandTourStylingOverrides;
keyboardShortcuts?: ReactGrandTourShortcuts;

componentVisibility?: ComponentVisibility;
};

export type ComponentVisibility = {
Expand Down Expand Up @@ -113,7 +111,7 @@ export type ReactGrandTourContextType = {
goBack: () => void;
};

export type ReactGrandTourStep = {
export type ReactGrandTourStep = ComponentVisibility & {
content: ReactNode;
/**
* Use the `component` prop if you want to customise the content of the step.
Expand Down

0 comments on commit 6360d09

Please sign in to comment.