Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add tour point step translation (#206)
Browse files Browse the repository at this point in the history
Co-authored-by: Danil Chepelev <[email protected]>
  • Loading branch information
chepelevdi and chepelevdi authored Nov 22, 2022
1 parent 3d535ba commit 6a6c42a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/TourPoint/TourPoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function TourPoint({
confirmation = 'Got it',
dismission = 'Dismiss',
content,
getStepsTranslation,
onClose,
src,
step,
Expand Down Expand Up @@ -108,7 +109,12 @@ export function TourPoint({
<Footer>
{steps && (
<Steps onClick={stepBack}>
Step {step} of {steps}
{getStepsTranslation
? getStepsTranslation({
currentStep: step,
totalSteps: steps,
})
: `Step ${step} of ${steps}`}
</Steps>
)}
{Dismiss}
Expand Down
7 changes: 7 additions & 0 deletions src/components/TourPoint/TourPoint.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export interface Props {
step: number;
style?: CSSProperties;
title?: HTMLElement['title'];
getStepsTranslation?: ({
currentStep,
totalSteps,
}: {
currentStep: number;
totalSteps: number;
}) => string;
}

type StepEvent = { direction: 'back' | 'next' | 'dismiss' };
Expand Down
10 changes: 10 additions & 0 deletions src/components/TourPoint/examples/InsidePopOver.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import { Paragraph } from '../../../typography';

export function InsidePopOver() {
const [active, activeSet] = useState(false);
const getStepsTranslation = ({
currentStep,
totalSteps,
}: {
currentStep: number;
totalSteps: number;
}) => {
return `step ${currentStep} of ${totalSteps}`;
};

return (
<div
Expand All @@ -31,6 +40,7 @@ export function InsidePopOver() {
attach="top"
src="http://placekitten.com/320/213"
step={1}
getStepsTranslation={getStepsTranslation}
title="A Fresh New Look"
content="All the leaves are brown and the sky is grey, I've been for a walk on a winters day."
>
Expand Down

0 comments on commit 6a6c42a

Please sign in to comment.