Skip to content

Commit 1d13c2d

Browse files
committed
feat(Wizard): added plain styling
1 parent 641c888 commit 1d13c2d

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

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

Lines changed: 7 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+
/** 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,7 @@ export const Wizard = ({
181187
mainWrapperRef={wrapperRef}
182188
>
183189
<div
184-
className={css(styles.wizard, className)}
190+
className={css(styles.wizard, isPlain && 'pf-m-plain', isNoPlainOnGlass && 'pf-m-no-plain', className)}
185191
style={{
186192
...(height ? { [wizardHeightToken.name]: typeof height === 'number' ? `${height}px` : height } : {}),
187193
...(width ? { width } : {})

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,23 @@ test('clicking parent step navigates to first visible sub-step when first sub-st
666666
WizardStepChangeScope.Nav
667667
);
668668
});
669+
670+
test('Renders with pf-m-plain class when isPlain is true', () => {
671+
render(
672+
<Wizard isPlain data-testid="wizard-plain">
673+
<WizardStep id="test-step" name="Test step" />
674+
</Wizard>
675+
);
676+
677+
expect(screen.getByTestId('wizard-plain')).toHaveClass('pf-m-plain');
678+
});
679+
680+
test('Renders with pf-m-no-plain class when isNoPlainOnGlass is true', () => {
681+
render(
682+
<Wizard isNoPlainOnGlass data-testid="wizard-no-plain">
683+
<WizardStep id="test-step" name="Test step" />
684+
</Wizard>
685+
);
686+
687+
expect(screen.getByTestId('wizard-no-plain')).toHaveClass('pf-m-no-plain');
688+
});

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)