Skip to content

Commit 336064b

Browse files
Add additional Guided tour steps
1 parent 196c0c3 commit 336064b

6 files changed

Lines changed: 189 additions & 113 deletions

File tree

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

Lines changed: 27 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import {
1212
FormSelectOption,
1313
HelperText,
1414
HelperTextItem,
15-
List,
16-
ListItem,
1715
TextInput,
1816
Popover,
1917
ActionGroup
2018
} from '../..';
19+
import { useGuidedTour } from './GuidedTourContext';
2120

2221
interface Props {
2322
onClose: () => void;
@@ -33,6 +32,7 @@ export const AnimationsCreateDatabaseForm: FunctionComponent<Props> = ({ onClose
3332
// Submit state variables
3433
const [isSuccess, setIsSuccess] = useState(false);
3534
const [actionCompleted, setActionCompleted] = useState(false);
35+
const { renderTourStepElement } = useGuidedTour();
3636

3737
const labelHelpRef = useRef(null);
3838

@@ -44,7 +44,6 @@ export const AnimationsCreateDatabaseForm: FunctionComponent<Props> = ({ onClose
4444
const [isPasswordValid, setIsPasswordValid] = useState('default');
4545
const [isEmailValid, setIsEmailValid] = useState('default');
4646
const [isTimeZoneValid, setIsTimeZoneValid] = useState('default');
47-
const [errorMessages, setErrorMessages] = useState([]);
4847

4948
const handleNameChange = (_event: React.FormEvent<HTMLInputElement>, name: string) => {
5049
setName(name);
@@ -103,68 +102,31 @@ export const AnimationsCreateDatabaseForm: FunctionComponent<Props> = ({ onClose
103102

104103
setActionCompleted(true);
105104
setIsSuccess(allFieldsValid);
106-
if (allFieldsValid) {
107-
setErrorMessages([]);
108-
setTimeout(() => {
109-
setActionCompleted(false);
110-
setIsSuccess(false);
111-
}, 5000);
112-
} else {
113-
const errors: string[] = [];
114-
if (!isNameCurrentValid) {
115-
errors.push('Database instance name');
116-
}
117-
if (!isPasswordCurrentValid) {
118-
errors.push('Admin password');
119-
}
120-
if (!isEmailCurrentValid) {
121-
errors.push('Admin email');
122-
}
123-
if (!isTimeZoneCurrentValid) {
124-
errors.push('Time zone');
125-
}
126-
setErrorMessages(errors);
127-
setTimeout(() => {
128-
setActionCompleted(false);
129-
setIsSuccess(false);
130-
}, 5000);
131-
}
132105
};
133106

134-
return (
107+
const onReset = () => {
108+
setIsNameValid('default');
109+
setIsPasswordValid('default');
110+
setIsEmailValid('default');
111+
setIsTimeZoneValid('default');
112+
};
113+
114+
return renderTourStepElement(
115+
'validationErrors',
135116
<Form isWidthLimited>
136-
{actionCompleted &&
137-
(isSuccess ? (
138-
<FormAlert>
139-
<AlertGroup hasAnimations isLiveRegion>
140-
<Alert
141-
variant="success"
142-
title="Successfully created database"
143-
isInline
144-
timeout={4000}
145-
timeoutAnimation={4000}
146-
/>
147-
</AlertGroup>
148-
</FormAlert>
149-
) : (
150-
<FormAlert>
151-
<AlertGroup hasAnimations isLiveRegion>
152-
<Alert
153-
variant="danger"
154-
title="Failed to create database. Please ensure all fields are filled out correctly."
155-
isInline
156-
timeout={3000}
157-
timeoutAnimation={3000}
158-
>
159-
<List isPlain>
160-
{errorMessages.map((error) => (
161-
<ListItem key={error}>{error}</ListItem>
162-
))}
163-
</List>
164-
</Alert>
165-
</AlertGroup>
166-
</FormAlert>
167-
))}
117+
{actionCompleted && isSuccess ? (
118+
<FormAlert>
119+
<AlertGroup hasAnimations isLiveRegion>
120+
<Alert
121+
variant="success"
122+
title="Successfully created database"
123+
isInline
124+
timeout={4000}
125+
timeoutAnimation={4000}
126+
/>
127+
</AlertGroup>
128+
</FormAlert>
129+
) : null}
168130
<FormGroup
169131
label="Database instance name"
170132
labelHelp={
@@ -288,6 +250,9 @@ export const AnimationsCreateDatabaseForm: FunctionComponent<Props> = ({ onClose
288250
<Button variant="link" onClick={onClose}>
289251
Cancel
290252
</Button>
253+
<Button className="pf-u-ml-2xl" variant="link" onClick={onReset}>
254+
Reset
255+
</Button>
291256
</ActionGroup>
292257
</Form>
293258
);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ interface Props {
2626
isDrawerExpanded: boolean;
2727
setIsDrawerExpanded: (newVal: boolean) => void;
2828
onStartGuidedTour: () => void;
29+
onEndGuidedTour: () => void;
2930
}
3031

3132
export const AnimationsHeaderToolbar: FunctionComponent<Props> = ({
3233
notifications,
3334
isDrawerExpanded,
3435
setIsDrawerExpanded,
35-
onStartGuidedTour
36+
onStartGuidedTour,
37+
onEndGuidedTour
3638
}) => {
3739
const [isActionsMenuOpen, setIsActionsMenuOpen] = useState<boolean>(false);
3840
const [isKebabDropdownOpen, setIsKebabDropdownOpen] = useState(false);
@@ -116,8 +118,8 @@ export const AnimationsHeaderToolbar: FunctionComponent<Props> = ({
116118
)}
117119
>
118120
<DropdownList>
119-
<DropdownItem onClick={() => onStartGuidedTour()} isDisabled={!!tourStep}>
120-
Guided tour
121+
<DropdownItem onClick={() => (tourStep ? onEndGuidedTour() : onStartGuidedTour())}>
122+
{tourStep ? 'End guided tour' : 'Guided tour'}
121123
</DropdownItem>
122124
</DropdownList>
123125
</Dropdown>

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

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

44
interface Props {
55
onClose: (startTour?: boolean) => void;
@@ -13,33 +13,19 @@ export const AnimationsTourModal: FunctionComponent<Props> = ({ onClose }) => (
1313
aria-labelledby="guided-tour-title"
1414
aria-describedby="guided-tour-description"
1515
>
16-
<ModalHeader title="Welcome to the PatternFly Animations demo" labelId="guided-tour-title" />
16+
<ModalHeader title="Explore PatternFly’s new animations" labelId="guided-tour-title" />
1717
<ModalBody id="guided-tour-description">
1818
<Content component="p">
19-
To see how components like alerts, navigation, and forms can now use motion to provide clear feedback and
20-
improve usability, you can explore this demo and interact with various UI elements. We will continue to update
21-
this demo as additional animation support is added.
22-
</Content>
23-
<Content component="p">
24-
Get started with a tour to highlight the current state of{' '}
25-
<Button
26-
variant="link"
27-
isInline
28-
href="https://github.com/orgs/patternfly/projects/7/views/66"
29-
rel="noopener noreferrer"
30-
target="_blank"
31-
>
32-
our ongoing effort to animate PatternFly components
33-
</Button>
34-
.
19+
Welcome! Many of our components now use motion to engage users, provide clear feedback, and improve usability.
20+
Let's explore some of these new animations and see how they work in a real UI
3521
</Content>
3622
</ModalBody>
3723
<ModalFooter>
38-
<Button key="skip" variant="secondary" onClick={() => onClose()}>
39-
Skip tour
40-
</Button>
4124
<Button key="start" variant="primary" onClick={() => onClose(true)}>
42-
Get started
25+
Start tour
26+
</Button>
27+
<Button key="skip" variant="link" onClick={() => onClose()}>
28+
Not now
4329
</Button>
4430
</ModalFooter>
4531
</Modal>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export const GuidedTourProvider: React.FC<{ steps: GuidedTourStep[]; children: R
7676
<Popover
7777
isVisible
7878
showClose
79+
maxWidth="28rem"
7980
hideOnOutsideClick={false}
81+
position={tourStep.position}
8082
headerContent={
8183
<>
8284
{tourStep.header}

0 commit comments

Comments
 (0)