Skip to content

Commit 4968f3c

Browse files
feat(Wizard): added plain styling (#12289)
* feat(Wizard): added plain styling * Replaced hardcoded classes with style object * Used style object in tests * Added beta flag * Bumped core for new class name * Added console warning * Removed console warning * Updated noglass prop description
1 parent d12d240 commit 4968f3c

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

packages/react-core/src/components/Wizard/Wizard.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
5959
* are called.
6060
*/
6161
shouldFocusContent?: boolean;
62+
/** Adds plain styling to the wizard. */
63+
isPlain?: boolean;
64+
/** @beta Prevents the wizard from automatically applying plain styling when glass theme is enabled. */
65+
isNoPlainOnGlass?: boolean;
6266
}
6367

6468
export const Wizard = ({
@@ -77,6 +81,8 @@ export const Wizard = ({
7781
onSave,
7882
onClose,
7983
shouldFocusContent = true,
84+
isPlain = false,
85+
isNoPlainOnGlass = false,
8086
...wrapperProps
8187
}: WizardProps) => {
8288
const [activeStepIndex, setActiveStepIndex] = useState(startIndex);
@@ -181,7 +187,12 @@ export const Wizard = ({
181187
mainWrapperRef={wrapperRef}
182188
>
183189
<div
184-
className={css(styles.wizard, className)}
190+
className={css(
191+
styles.wizard,
192+
isPlain && styles.modifiers.plain,
193+
isNoPlainOnGlass && styles.modifiers.noPlainOnGlass,
194+
className
195+
)}
185196
style={{
186197
...(height ? { [wizardHeightToken.name]: typeof height === 'number' ? `${height}px` : height } : {}),
187198
...(width ? { width } : {})

packages/react-core/src/components/Wizard/__tests__/Wizard.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { render, screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33

44
import { Wizard, WizardFooterProps, WizardStep, WizardNavProps, WizardStepChangeScope } from '../';
5+
import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
56

67
test('renders step when child is of type WizardStep', () => {
78
render(
@@ -666,3 +667,23 @@ test('clicking parent step navigates to first visible sub-step when first sub-st
666667
WizardStepChangeScope.Nav
667668
);
668669
});
670+
671+
test(`Renders with ${styles.modifiers.plain} class when isPlain is true`, () => {
672+
render(
673+
<Wizard isPlain data-testid="wizard-plain">
674+
<WizardStep id="test-step" name="Test step" />
675+
</Wizard>
676+
);
677+
678+
expect(screen.getByTestId('wizard-plain')).toHaveClass(styles.modifiers.plain);
679+
});
680+
681+
test(`Renders with ${styles.modifiers.noPlainOnGlass} class when isNoPlainOnGlass is true`, () => {
682+
render(
683+
<Wizard isNoPlainOnGlass data-testid="wizard-no-plain">
684+
<WizardStep id="test-step" name="Test step" />
685+
</Wizard>
686+
);
687+
688+
expect(screen.getByTestId('wizard-no-plain')).toHaveClass(styles.modifiers.noPlainOnGlass);
689+
});

packages/react-core/src/components/Wizard/examples/Wizard.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ import layout from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
6363

6464
```
6565

66+
### Plain
67+
68+
```ts file="./WizardPlain.tsx"
69+
70+
```
71+
6672
### Focus content on next/back
6773

6874
To focus the main content element of the `Wizard`, pass in the `shouldFocusContent` property. It is recommended that this is passed in so that users can navigate through a `WizardStep` content in order.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Wizard, WizardStep } from '@patternfly/react-core';
2+
3+
export const WizardPlain: React.FunctionComponent = () => (
4+
<Wizard height={400} title="Plain wizard" isPlain>
5+
<WizardStep name="Step 1" id="plain-first-step">
6+
<p>Step 1 content</p>
7+
</WizardStep>
8+
<WizardStep name="Step 2" id="plain-second-step">
9+
<p>Step 2 content</p>
10+
</WizardStep>
11+
<WizardStep name="Review" id="plain-review-step" footer={{ nextButtonText: 'Finish' }}>
12+
<p>Review step content</p>
13+
</WizardStep>
14+
</Wizard>
15+
);

0 commit comments

Comments
 (0)