Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 2e4a17f

Browse files
authored
Merge pull request #92 from thepensionsregulator/bug-arrow-button-disabled-status
buttons can be disabled and with custom loading message
2 parents a7049e5 + faf09a3 commit 2e4a17f

4 files changed

Lines changed: 52 additions & 14 deletions

File tree

packages/core/src/components/buttons/buttons.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
.link:disabled {
141141
color: $colors-neutral-6;
142142
text-decoration: none;
143-
cursor: default;
143+
cursor: not-allowed;
144144
}
145145

146146
.link-underline {

packages/layout/src/components/buttons/buttons.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ import { ArrowLink, ArrowButton } from '@tpr/layout';
7070
<ArrowLink
7171
iconSide="right"
7272
pointsTo="down"
73+
cfg={{ mr: 3 }}
74+
onClick={() => console.log('clicked')}
75+
/>
76+
<ArrowLink
77+
iconSide="right"
78+
pointsTo="down"
79+
disabled
7380
onClick={() => console.log('clicked')}
7481
/>
7582
</Playground>
@@ -135,5 +142,22 @@ import { ArrowLink, ArrowButton } from '@tpr/layout';
135142
title="Submit"
136143
pointsTo="down"
137144
onClick={() => console.log('clicked')}
145+
cfg={{ mr: 3 }}
146+
/>
147+
<ArrowButton
148+
iconSide="right"
149+
title="Submit"
150+
pointsTo="right"
151+
onClick={() => console.log('clicked')}
152+
cfg={{ mr: 3 }}
153+
disabled
154+
/>
155+
<ArrowButton
156+
iconSide="right"
157+
title="Submit"
158+
pointsTo="right"
159+
onClick={() => console.log('clicked')}
160+
disabled
161+
disabledText="Loading..."
138162
/>
139163
</Playground>

packages/layout/src/components/buttons/buttons.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { ChangeEvent } from 'react';
2-
import { Flex, Button, ButtonProps, ColorProps } from '@tpr/core';
2+
import { Flex, Button, ButtonProps, ColorProps, P } from '@tpr/core';
33
import { ArrowIcon } from './icons';
44
import styles from './buttons.module.scss';
55

66
export interface ArrowButtonProps extends ButtonProps {
77
title: string;
8-
loadingMessage?: string;
8+
disabledText?: string;
99
type?: 'button' | 'submit';
1010
onClick?: (evt: ChangeEvent<HTMLInputElement>) => void;
1111
pointsTo?: 'left' | 'up' | 'right' | 'down';
@@ -18,7 +18,7 @@ export const ArrowButton: React.FC<ArrowButtonProps> = ({
1818
type = 'button',
1919
onClick,
2020
disabled,
21-
loadingMessage = 'Saving...',
21+
disabledText,
2222
title,
2323
cfg,
2424
pointsTo = 'left',
@@ -37,8 +37,8 @@ export const ArrowButton: React.FC<ArrowButtonProps> = ({
3737
testId={testId}
3838
className={styles.removepadding}
3939
>
40-
{disabled ? (
41-
loadingMessage
40+
{disabled && disabledText ? (
41+
<P cfg={{ px: 4 }}>{disabledText}</P>
4242
) : (
4343
<Flex
4444
cfg={{

packages/layout/src/components/buttons/links.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,44 @@ import React, { ChangeEvent } from 'react';
22
import { Link, LinkProps, Flex } from '@tpr/core';
33
import { ArrowIcon } from './icons';
44

5-
type ArrowLinkProps = {
5+
export interface ArrowLinkProps extends LinkProps {
66
onClick: (evt: ChangeEvent<HTMLInputElement>) => void;
77
title?: string;
88
pointsTo?: 'left' | 'up' | 'right' | 'down';
99
iconSide?: 'left' | 'right';
10-
underline?: boolean;
11-
testId?: string;
12-
cfg?: LinkProps['cfg'];
13-
};
10+
}
1411
export const ArrowLink: React.FC<ArrowLinkProps> = ({
1512
onClick,
1613
testId,
1714
underline = true,
1815
title = 'Back',
1916
pointsTo = 'left',
2017
iconSide = 'left',
18+
disabled,
2119
cfg,
2220
}) => {
2321
return (
24-
<Link cfg={cfg} onClick={onClick} underline={underline} testId={testId}>
22+
<Link
23+
cfg={cfg}
24+
onClick={onClick}
25+
underline={underline}
26+
testId={testId}
27+
disabled={disabled}
28+
>
2529
<Flex cfg={{ alignItems: 'center' }}>
26-
{iconSide === 'left' && <ArrowIcon pointsTo={pointsTo} />}
30+
{iconSide === 'left' && (
31+
<ArrowIcon
32+
fill={disabled ? 'neutral.6' : 'primary.3'}
33+
pointsTo={pointsTo}
34+
/>
35+
)}
2736
<>{title}</>
28-
{iconSide === 'right' && <ArrowIcon pointsTo={pointsTo} />}
37+
{iconSide === 'right' && (
38+
<ArrowIcon
39+
fill={disabled ? 'neutral.6' : 'primary.3'}
40+
pointsTo={pointsTo}
41+
/>
42+
)}
2943
</Flex>
3044
</Link>
3145
);

0 commit comments

Comments
 (0)