Skip to content

Commit a5a032b

Browse files
authored
chore(button): added inline progress variant to progress demos (#8172)
1 parent d37ff72 commit a5a032b

File tree

3 files changed

+67
-9
lines changed

3 files changed

+67
-9
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ describe('Button', () => {
103103
expect(asFragment()).toMatchSnapshot();
104104
});
105105

106+
test('isLoading inline link', () => {
107+
const { asFragment } = render(
108+
<Button variant="link" isInline isLoading aria-label="Loading" spinnerAriaValueText="Loading">
109+
Loading Button
110+
</Button>
111+
);
112+
expect(asFragment()).toMatchSnapshot();
113+
});
114+
115+
test('isLoading icon only', () => {
116+
const { asFragment } = render(
117+
<Button variant="plain" isLoading aria-label="Upload" spinnerAriaValueText="Loading" icon={<div>ICON</div>} />
118+
);
119+
expect(asFragment()).toMatchSnapshot();
120+
});
121+
106122
test('allows passing in a string as the component', () => {
107123
const component = 'a';
108124
render(<Button component={component}>anchor button</Button>);
@@ -130,11 +146,4 @@ describe('Button', () => {
130146
render(<Button tabIndex={0}>TabIndex 0 Button</Button>);
131147
expect(screen.getByRole('button')).toHaveAttribute('tabindex', '0');
132148
});
133-
134-
test('isLoading icon only', () => {
135-
const { asFragment } = render(
136-
<Button variant="plain" isLoading aria-label="Upload" spinnerAriaValueText="Loading" icon={<div>ICON</div>} />
137-
);
138-
expect(asFragment()).toMatchSnapshot();
139-
});
140149
});

packages/react-core/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,42 @@ exports[`Button isLoading icon only 1`] = `
240240
</DocumentFragment>
241241
`;
242242

243+
exports[`Button isLoading inline link 1`] = `
244+
<DocumentFragment>
245+
<button
246+
aria-disabled="false"
247+
aria-label="Loading"
248+
class="pf-c-button pf-m-link pf-m-inline pf-m-progress pf-m-in-progress"
249+
data-ouia-component-id="OUIA-Generated-Button-link-5"
250+
data-ouia-component-type="PF4/Button"
251+
data-ouia-safe="true"
252+
type="button"
253+
>
254+
<span
255+
class="pf-c-button__progress"
256+
>
257+
<span
258+
aria-label="Contents"
259+
aria-valuetext="Loading"
260+
class="pf-c-spinner pf-m-md"
261+
role="progressbar"
262+
>
263+
<span
264+
class="pf-c-spinner__clipper"
265+
/>
266+
<span
267+
class="pf-c-spinner__lead-ball"
268+
/>
269+
<span
270+
class="pf-c-spinner__tail-ball"
271+
/>
272+
</span>
273+
</span>
274+
Loading Button
275+
</button>
276+
</DocumentFragment>
277+
`;
278+
243279
exports[`Button isSmall 1`] = `
244280
<DocumentFragment>
245281
<button

packages/react-core/src/components/Button/examples/ButtonProgress.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface LoadingPropsType {
1212
export const ButtonProgress: React.FunctionComponent = () => {
1313
const [isPrimaryLoading, setIsPrimaryLoading] = React.useState<boolean>(true);
1414
const [isSecondaryLoading, setIsSecondaryLoading] = React.useState<boolean>(true);
15+
const [isInlineLoading, setIsInlineLoading] = React.useState<boolean>(true);
1516
const [isUploading, setIsUploading] = React.useState<boolean>(false);
1617

1718
const primaryLoadingProps = {} as LoadingPropsType;
@@ -24,6 +25,11 @@ export const ButtonProgress: React.FunctionComponent = () => {
2425
secondaryLoadingProps.spinnerAriaLabel = 'Content being loaded';
2526
secondaryLoadingProps.isLoading = isSecondaryLoading;
2627

28+
const inlineLoadingProps = {} as LoadingPropsType;
29+
inlineLoadingProps.spinnerAriaValueText = 'Loading';
30+
inlineLoadingProps.spinnerAriaLabel = 'Content being loaded';
31+
inlineLoadingProps.isLoading = isInlineLoading;
32+
2733
const uploadingProps = {} as LoadingPropsType;
2834
uploadingProps.spinnerAriaValueText = 'Loading';
2935
uploadingProps.spinnerAriaLabel = 'Uploading data';
@@ -37,18 +43,25 @@ export const ButtonProgress: React.FunctionComponent = () => {
3743
onClick={() => setIsPrimaryLoading(!isPrimaryLoading)}
3844
{...primaryLoadingProps}
3945
>
40-
{isPrimaryLoading ? 'Pause loading logs' : 'Resume loading logs'}
46+
{isPrimaryLoading ? 'Click to stop loading' : 'Click to start loading'}
4147
</Button>{' '}
4248
<Button variant="secondary" onClick={() => setIsSecondaryLoading(!isSecondaryLoading)} {...secondaryLoadingProps}>
4349
{isSecondaryLoading ? 'Click to stop loading' : 'Click to start loading'}
4450
</Button>{' '}
51+
<br />
52+
<br />
4553
<Button
4654
variant="plain"
4755
{...(!isUploading && { 'aria-label': 'Upload' })}
4856
onClick={() => setIsUploading(!isUploading)}
4957
icon={<UploadIcon />}
5058
{...uploadingProps}
51-
/>
59+
/>{' '}
60+
<br />
61+
<br />
62+
<Button variant="link" isInline onClick={() => setIsInlineLoading(!isInlineLoading)} {...inlineLoadingProps}>
63+
{isInlineLoading ? 'Pause loading logs' : 'Resume loading logs'}
64+
</Button>{' '}
5265
</React.Fragment>
5366
);
5467
};

0 commit comments

Comments
 (0)