Skip to content

Commit 11c82ea

Browse files
Use an Info toast notification when tour is not started
1 parent a763064 commit 11c82ea

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

packages/react-core/src/demos/Animations/AnimationsStartTourModal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { FunctionComponent } from 'react';
22
import { Button, Content, Modal, ModalBody, ModalFooter, ModalHeader, ModalVariant } from '../../index';
33

44
interface Props {
5-
onClose: (startTour?: boolean) => void;
5+
onClose: (notNow?: boolean) => void;
6+
onStart: () => void;
67
}
78

8-
export const AnimationsStartTourModal: FunctionComponent<Props> = ({ onClose }) => (
9+
export const AnimationsStartTourModal: FunctionComponent<Props> = ({ onClose, onStart }) => (
910
<Modal
1011
variant={ModalVariant.small}
1112
isOpen
@@ -24,10 +25,10 @@ export const AnimationsStartTourModal: FunctionComponent<Props> = ({ onClose })
2425
</Content>
2526
</ModalBody>
2627
<ModalFooter>
27-
<Button key="start" variant="primary" onClick={() => onClose(true)}>
28+
<Button key="start" variant="primary" onClick={() => onStart()}>
2829
Start tour
2930
</Button>
30-
<Button key="skip" variant="link" onClick={() => onClose()}>
31+
<Button key="skip" variant="link" onClick={() => onClose(true)}>
3132
Not now
3233
</Button>
3334
</ModalFooter>

packages/react-core/src/demos/Animations/examples/Animations.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ const AnimationsPage: FunctionComponent = () => {
301301
];
302302

303303
// A function to create a kebab toggle for a specific row index
304-
const kebabToggle = (index) => (toggleRef: React.Ref<any>) => (
304+
const kebabToggle = (index: number) => (toggleRef: React.Ref<any>) => (
305305
<MenuToggle
306306
ref={toggleRef}
307307
variant="plain"
@@ -542,18 +542,6 @@ const AnimationsPage: FunctionComponent = () => {
542542
[]
543543
);
544544

545-
const startNotifications = () => {
546-
setTimeout(() => {
547-
addNotification();
548-
}, 1000);
549-
setTimeout(() => {
550-
addNotification();
551-
}, 5000);
552-
setTimeout(() => {
553-
addNotification();
554-
}, 9000);
555-
};
556-
557545
const onNavSelect = (
558546
_event: FormEvent<HTMLInputElement>,
559547
selectedItem: {
@@ -563,7 +551,6 @@ const AnimationsPage: FunctionComponent = () => {
563551
}
564552
) => {
565553
setActiveItem(selectedItem.itemId);
566-
setActiveGroup(selectedItem.groupId as string | null);
567554
};
568555

569556
const focusDrawer = (_event: any) => {
@@ -577,9 +564,23 @@ const AnimationsPage: FunctionComponent = () => {
577564
firstTabbableItem?.focus();
578565
};
579566

580-
const closeStartTourModal = (startTour = false) => {
567+
const closeStartTourModal = (notNow = false) => {
581568
setShowStartTourModal(false);
582-
startTour ? onStart() : startNotifications();
569+
if (notNow) {
570+
setNotifications((prev) => [
571+
{
572+
id: `new-notification-${prev.length + 1}`,
573+
title: 'Explore animations',
574+
message: 'When you’re ready to take a tour of PatternFly’s exciting, new animations, refresh this page.',
575+
variant: AlertVariant.info,
576+
timeout: 8000,
577+
timeoutAnimation: 8000,
578+
isNew: true,
579+
isRead: false
580+
},
581+
...prev
582+
]);
583+
}
583584
};
584585

585586
return (
@@ -741,7 +742,15 @@ const AnimationsPage: FunctionComponent = () => {
741742
)}
742743
</PageSection>
743744
)}
744-
{showStartTourModal ? <AnimationsStartTourModal onClose={closeStartTourModal} /> : null}
745+
{showStartTourModal ? (
746+
<AnimationsStartTourModal
747+
onClose={closeStartTourModal}
748+
onStart={() => {
749+
setShowStartTourModal(false);
750+
onStart();
751+
}}
752+
/>
753+
) : null}
745754
{showEndTourModal ? <AnimationsEndTourModal /> : null}
746755
</Page>
747756
);

0 commit comments

Comments
 (0)