Skip to content

Commit a90a71b

Browse files
committed
[open-formulieren/open-forms#4917] Updated buttons styling
1 parent 575138f commit a90a71b

26 files changed

+256
-379
lines changed

package-lock.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"@typescript-eslint/parser": "^8.26.0",
129129
"@utrecht/component-library-react": "1.0.0-alpha.353",
130130
"@utrecht/components": "^7.4.0",
131+
"@utrecht/button-group-react": "1.0.0",
131132
"@utrecht/design-tokens": "^2.5.0",
132133
"@vitejs/plugin-react": "^4.3.4",
133134
"@vitest/coverage-istanbul": "^3.0.7",

src/components/AbortButton/AbortButton.jsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import {LinkButton as UtrechtButtonLink} from '@utrecht/component-library-react';
12
import PropTypes from 'prop-types';
23
import {FormattedMessage, useIntl} from 'react-intl';
34

4-
import {OFButton} from 'components/Button';
5+
import FAIcon from 'components/FAIcon';
56
import {useAnalyticsToolsConfig} from 'components/analytics/AnalyticsToolConfigProvider';
67
import {buildGovMetricUrl} from 'components/analytics/utils';
78
import useFormContext from 'hooks/useFormContext';
@@ -50,9 +51,16 @@ const AbortButton = ({isAuthenticated, onDestroySession}) => {
5051
);
5152

5253
return (
53-
<OFButton appearance="primary-action-button" hint="danger" name="abort" onClick={callback}>
54-
{message}
55-
</OFButton>
54+
<>
55+
<UtrechtButtonLink
56+
name="abort"
57+
onClick={callback}
58+
className={'utrecht-link-button--openforms'}
59+
>
60+
<FAIcon icon="xmark" />
61+
{message}
62+
</UtrechtButtonLink>
63+
</>
5664
);
5765
};
5866

src/components/ButtonsGroup/index.jsx

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import {ButtonGroup} from '@utrecht/button-group-react';
2+
import {LinkButton as UtrechtButtonLink} from '@utrecht/component-library-react';
3+
import PropTypes from 'prop-types';
4+
5+
import AbortButton from 'components/AbortButton';
6+
import {OFButton} from 'components/Button';
7+
import FAIcon from 'components/FAIcon';
8+
import {Literal} from 'components/Literal';
9+
import Loader from 'components/Loader';
10+
import PreviousLink from 'components/PreviousLink';
11+
import {SUBMISSION_ALLOWED} from 'components/constants';
12+
13+
const ButtonsGroup = ({
14+
canSubmitStep,
15+
canSubmitForm,
16+
canSuspendForm,
17+
isLastStep,
18+
isCheckingLogic,
19+
isAuthenticated,
20+
hideAbortButton,
21+
onNavigatePrevPage,
22+
onFormSave,
23+
previousPage,
24+
onDestroySession,
25+
}) => {
26+
const showSubmitButton = !(canSubmitForm === SUBMISSION_ALLOWED.noWithoutOverview && isLastStep);
27+
28+
return (
29+
<ButtonGroup className="utrecht-button-group--distanced" direction="column">
30+
{showSubmitButton && (
31+
<OFButton
32+
type="submit"
33+
appearance="primary-action-button"
34+
name="next"
35+
disabled={!canSubmitStep}
36+
className="openforms-button-with-icon"
37+
>
38+
{isCheckingLogic ? (
39+
<Loader modifiers={['centered', 'only-child', 'small', 'gray']} />
40+
) : (
41+
<>
42+
<Literal name="nextText" />
43+
<FAIcon icon="arrow-right-long" />
44+
</>
45+
)}
46+
</OFButton>
47+
)}
48+
49+
{previousPage && (
50+
<PreviousLink to={previousPage} onClick={onNavigatePrevPage} position="end" />
51+
)}
52+
53+
{/* TODO: refactor: `const canSuspendForm = onFormSave === undefined` - this does not
54+
need to be its own prop */}
55+
{canSuspendForm && (
56+
<UtrechtButtonLink
57+
name="save"
58+
onClick={onFormSave}
59+
className="utrecht-link-button--openforms"
60+
>
61+
<FAIcon icon="arrow-right-long" />
62+
<Literal name="saveText" />
63+
</UtrechtButtonLink>
64+
)}
65+
66+
{!hideAbortButton && (
67+
<AbortButton isAuthenticated={isAuthenticated} onDestroySession={onDestroySession} />
68+
)}
69+
</ButtonGroup>
70+
);
71+
};
72+
73+
ButtonsGroup.propTypes = {
74+
canSubmitStep: PropTypes.bool.isRequired,
75+
canSubmitForm: PropTypes.string.isRequired,
76+
canSuspendForm: PropTypes.bool.isRequired,
77+
isLastStep: PropTypes.bool.isRequired,
78+
isCheckingLogic: PropTypes.bool.isRequired,
79+
isAuthenticated: PropTypes.bool.isRequired,
80+
hideAbortButton: PropTypes.bool,
81+
onNavigatePrevPage: PropTypes.func,
82+
onFormSave: PropTypes.func.isRequired,
83+
previousPage: PropTypes.string,
84+
onDestroySession: PropTypes.func.isRequired,
85+
};
86+
87+
export default ButtonsGroup;

src/components/ButtonsToolbar/test.spec.jsx src/components/ButtonsGroup/test.spec.jsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {MemoryRouter} from 'react-router';
66
import {LiteralsProvider} from 'components/Literal';
77
import {SUBMISSION_ALLOWED} from 'components/constants';
88

9-
import ButtonsToolbar from './index';
9+
import ButtonsGroup from './index';
1010

1111
const LITERALS = {
1212
nextText: {value: '', resolved: 'Next step'},
@@ -27,7 +27,7 @@ it('Last step of submittable form, button is present', () => {
2727

2828
render(
2929
<Wrap>
30-
<ButtonsToolbar
30+
<ButtonsGroup
3131
canSubmitStep={true}
3232
canSubmitForm={SUBMISSION_ALLOWED.yes}
3333
canSuspendForm={true}
@@ -53,7 +53,7 @@ it('Last step of non-submittable form with overview, button is present', () => {
5353

5454
render(
5555
<Wrap>
56-
<ButtonsToolbar
56+
<ButtonsGroup
5757
canSubmitStep={true}
5858
canSubmitForm={SUBMISSION_ALLOWED.noWithOverview}
5959
canSuspendForm={true}
@@ -79,7 +79,7 @@ it('Last step of non-submittable form without overview, button is NOT present',
7979

8080
render(
8181
<Wrap>
82-
<ButtonsToolbar
82+
<ButtonsGroup
8383
canSubmitStep={true}
8484
canSubmitForm={SUBMISSION_ALLOWED.noWithoutOverview}
8585
canSuspendForm={true}
@@ -105,7 +105,7 @@ it('Non-last step of non-submittable form without overview, button IS present',
105105

106106
render(
107107
<Wrap>
108-
<ButtonsToolbar
108+
<ButtonsGroup
109109
canSubmitStep={true}
110110
canSubmitForm={SUBMISSION_ALLOWED.noWithoutOverview}
111111
canSuspendForm={true}
@@ -131,7 +131,7 @@ it('Suspending form allowed, button is present', () => {
131131

132132
render(
133133
<Wrap>
134-
<ButtonsToolbar
134+
<ButtonsGroup
135135
canSubmitStep={true}
136136
canSubmitForm={SUBMISSION_ALLOWED.yes}
137137
canSuspendForm={true}
@@ -154,7 +154,7 @@ it('Suspending form not allowed, button is NOT present', () => {
154154

155155
render(
156156
<Wrap>
157-
<ButtonsToolbar
157+
<ButtonsGroup
158158
canSubmitStep={true}
159159
canSubmitForm={SUBMISSION_ALLOWED.yes}
160160
canSuspendForm={false}

src/components/ButtonsToolbar/index.jsx

-88
This file was deleted.

src/components/EditGrid/EditGrid.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ButtonGroup} from '@utrecht/component-library-react';
1+
import {ButtonGroup} from '@utrecht/button-group-react';
22
import PropTypes from 'prop-types';
33
import {FormattedMessage} from 'react-intl';
44

src/components/EditGrid/EditGridButtonGroup.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ButtonGroup} from '@utrecht/component-library-react';
1+
import {ButtonGroup} from '@utrecht/button-group-react';
22
import PropTypes from 'prop-types';
33

44
const EditGridButtonGroup = ({children}) => (

src/components/EmailVerification/EmailVerificationForm.jsx

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {TextField} from '@open-formulieren/formio-renderer';
2+
import {ButtonGroup} from '@utrecht/button-group-react';
23
import {Link as UtrechtLink} from '@utrecht/component-library-react';
34
import {Formik} from 'formik';
45
import PropTypes from 'prop-types';
@@ -12,7 +13,6 @@ import {post} from 'api';
1213
import Body from 'components/Body';
1314
import {DisplayError} from 'components/Errors/ErrorBoundary';
1415
import ErrorMessage from 'components/Errors/ErrorMessage';
15-
import {Toolbar, ToolbarList} from 'components/Toolbar';
1616
import {ValidationError} from 'errors';
1717

1818
import EnterCodeButton from './EnterCodeButton';
@@ -154,19 +154,17 @@ const EmailVerificationForm = ({submissionUrl, componentKey, emailAddress, onVer
154154
</>
155155
)}
156156

157-
<Toolbar modifiers={['bottom', 'reverse']}>
158-
<ToolbarList>
159-
{mode === 'sendCode' && (
160-
<SendCodeButton
161-
submissionUrl={submissionUrl}
162-
componentKey={componentKey}
163-
emailAddress={emailAddress}
164-
onError={error => setError(error)}
165-
/>
166-
)}
167-
{mode === 'enterCode' && <EnterCodeButton />}
168-
</ToolbarList>
169-
</Toolbar>
157+
<ButtonGroup direction="column" className="utrecht-button-group--distanced">
158+
{mode === 'sendCode' && (
159+
<SendCodeButton
160+
submissionUrl={submissionUrl}
161+
componentKey={componentKey}
162+
emailAddress={emailAddress}
163+
onError={error => setError(error)}
164+
/>
165+
)}
166+
{mode === 'enterCode' && <EnterCodeButton />}
167+
</ButtonGroup>
170168
</Body>
171169
)
172170
}

0 commit comments

Comments
 (0)