Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OF#4917] Update buttons styling (buttons position) #787

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/AbortButton/AbortButton.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {LinkButton as UtrechtButtonLink} from '@utrecht/component-library-react';
import PropTypes from 'prop-types';
import {FormattedMessage, useIntl} from 'react-intl';

import {OFButton} from 'components/Button';
import FAIcon from 'components/FAIcon';
import {useAnalyticsToolsConfig} from 'components/analytics/AnalyticsToolConfigProvider';
import {buildGovMetricUrl} from 'components/analytics/utils';
import useFormContext from 'hooks/useFormContext';
Expand Down Expand Up @@ -50,9 +51,16 @@ const AbortButton = ({isAuthenticated, onDestroySession}) => {
);

return (
<OFButton appearance="primary-action-button" hint="danger" name="abort" onClick={callback}>
{message}
</OFButton>
<>
<UtrechtButtonLink
name="abort"
onClick={callback}
className={'utrecht-link-button--openforms'}
>
<FAIcon icon="xmark" />
{message}
</UtrechtButtonLink>
</>
);
};

Expand Down
89 changes: 89 additions & 0 deletions src/components/ButtonsGroup/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// TODO: this can be removed when we upgrade the Utrecht react library. Now it's not possible to use the
// css rules we need.
import '@utrecht/button-group-css';

Check failure on line 3 in src/components/ButtonsGroup/index.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

Unable to resolve path to module '@utrecht/button-group-css'
import {ButtonGroup, LinkButton as UtrechtButtonLink} from '@utrecht/component-library-react';
import PropTypes from 'prop-types';

import AbortButton from 'components/AbortButton';
import {OFButton} from 'components/Button';
import FAIcon from 'components/FAIcon';
import {Literal} from 'components/Literal';
import Loader from 'components/Loader';
import PreviousLink from 'components/PreviousLink';
import {SUBMISSION_ALLOWED} from 'components/constants';

const ButtonsGroup = ({
canSubmitStep,
canSubmitForm,
canSuspendForm,
isLastStep,
isCheckingLogic,
isAuthenticated,
hideAbortButton,
onNavigatePrevPage,
onFormSave,
previousPage,
onDestroySession,
}) => {
const showSubmitButton = !(canSubmitForm === SUBMISSION_ALLOWED.noWithoutOverview && isLastStep);

return (
<ButtonGroup className="utrecht-button-group--column" role="group">
{showSubmitButton && (
<OFButton
type="submit"
appearance="primary-action-button"
name="next"
disabled={!canSubmitStep}
className="openforms-button-with-icon"
>
{isCheckingLogic ? (
<Loader modifiers={['centered', 'only-child', 'small', 'gray']} />
) : (
<>
<Literal name="nextText" />
<FAIcon icon="arrow-right-long" />
</>
)}
</OFButton>
)}

{previousPage && (
<PreviousLink to={previousPage} onClick={onNavigatePrevPage} position="end" />
)}

{/* TODO: refactor: `const canSuspendForm = onFormSave === undefined` - this does not
need to be its own prop */}
{canSuspendForm && (
<UtrechtButtonLink
name="save"
onClick={onFormSave}
className="utrecht-link-button--openforms"
>
<FAIcon icon="arrow-right-long" />
<Literal name="saveText" />
</UtrechtButtonLink>
)}

{!hideAbortButton && (
<AbortButton isAuthenticated={isAuthenticated} onDestroySession={onDestroySession} />
)}
</ButtonGroup>
);
};

ButtonsGroup.propTypes = {
canSubmitStep: PropTypes.bool.isRequired,
canSubmitForm: PropTypes.string.isRequired,
canSuspendForm: PropTypes.bool.isRequired,
isLastStep: PropTypes.bool.isRequired,
isCheckingLogic: PropTypes.bool.isRequired,
isAuthenticated: PropTypes.bool.isRequired,
hideAbortButton: PropTypes.bool,
onNavigatePrevPage: PropTypes.func,
onFormSave: PropTypes.func.isRequired,
previousPage: PropTypes.string,
onDestroySession: PropTypes.func.isRequired,
};

export default ButtonsGroup;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {MemoryRouter} from 'react-router';
import {LiteralsProvider} from 'components/Literal';
import {SUBMISSION_ALLOWED} from 'components/constants';

import ButtonsToolbar from './index';
import ButtonsGroup from './index';

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

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

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

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

render(
<Wrap>
<ButtonsToolbar
<ButtonsGroup
canSubmitStep={true}
canSubmitForm={SUBMISSION_ALLOWED.noWithoutOverview}
canSuspendForm={true}
Expand All @@ -131,7 +131,7 @@ it('Suspending form allowed, button is present', () => {

render(
<Wrap>
<ButtonsToolbar
<ButtonsGroup
canSubmitStep={true}
canSubmitForm={SUBMISSION_ALLOWED.yes}
canSuspendForm={true}
Expand All @@ -154,7 +154,7 @@ it('Suspending form not allowed, button is NOT present', () => {

render(
<Wrap>
<ButtonsToolbar
<ButtonsGroup
canSubmitStep={true}
canSubmitForm={SUBMISSION_ALLOWED.yes}
canSuspendForm={false}
Expand Down
88 changes: 0 additions & 88 deletions src/components/ButtonsToolbar/index.jsx

This file was deleted.

26 changes: 12 additions & 14 deletions src/components/EmailVerification/EmailVerificationForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {TextField} from '@open-formulieren/formio-renderer';
import {Link as UtrechtLink} from '@utrecht/component-library-react';

Check warning on line 2 in src/components/EmailVerification/EmailVerificationForm.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

'/home/runner/work/open-forms-sdk/open-forms-sdk/node_modules/@utrecht/component-library-react/dist/index.esm.js' imported multiple times
import {ButtonGroup, Link as UtrechtLink} from '@utrecht/component-library-react';

Check warning on line 3 in src/components/EmailVerification/EmailVerificationForm.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

'/home/runner/work/open-forms-sdk/open-forms-sdk/node_modules/@utrecht/component-library-react/dist/index.esm.js' imported multiple times

Check failure on line 3 in src/components/EmailVerification/EmailVerificationForm.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

Parsing error:

Check failure on line 3 in src/components/EmailVerification/EmailVerificationForm.jsx

View workflow job for this annotation

GitHub Actions / Lint code (ESLint)

'UtrechtLink' is already defined
import {Formik} from 'formik';
import PropTypes from 'prop-types';
import {useContext, useState} from 'react';
Expand All @@ -12,7 +13,6 @@
import Body from 'components/Body';
import {DisplayError} from 'components/Errors/ErrorBoundary';
import ErrorMessage from 'components/Errors/ErrorMessage';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import {ValidationError} from 'errors';

import EnterCodeButton from './EnterCodeButton';
Expand Down Expand Up @@ -154,19 +154,17 @@
</>
)}

<Toolbar modifiers={['bottom', 'reverse']}>
<ToolbarList>
{mode === 'sendCode' && (
<SendCodeButton
submissionUrl={submissionUrl}
componentKey={componentKey}
emailAddress={emailAddress}
onError={error => setError(error)}
/>
)}
{mode === 'enterCode' && <EnterCodeButton />}
</ToolbarList>
</Toolbar>
<ButtonGroup className="utrecht-button-group--column" role="group">
{mode === 'sendCode' && (
<SendCodeButton
submissionUrl={submissionUrl}
componentKey={componentKey}
emailAddress={emailAddress}
onError={error => setError(error)}
/>
)}
{mode === 'enterCode' && <EnterCodeButton />}
</ButtonGroup>
</Body>
)
}
Expand Down
12 changes: 5 additions & 7 deletions src/components/ExistingSubmissionOptions.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {ButtonGroup} from '@utrecht/component-library-react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import {useNavigate} from 'react-router';

import AbortButton from 'components/AbortButton';
import {OFButton} from 'components/Button';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import Types from 'types';

const ExistingSubmissionOptions = ({form, onDestroySession, isAuthenticated}) => {
Expand All @@ -13,19 +13,17 @@ const ExistingSubmissionOptions = ({form, onDestroySession, isAuthenticated}) =>
const firstStepRoute = `/stap/${form.steps[0].slug}`;

return (
<Toolbar modifiers={['column']}>
<ToolbarList>
<>
<ButtonGroup className="utrecht-button-group--column" role="group">
<OFButton appearance="primary-action-button" onClick={() => navigate(firstStepRoute)}>
<FormattedMessage
defaultMessage="Continue existing submission"
description="Continue existing submission button label"
/>
</OFButton>
</ToolbarList>
<ToolbarList>
<AbortButton onDestroySession={onDestroySession} isAuthenticated={isAuthenticated} />
</ToolbarList>
</Toolbar>
</ButtonGroup>
</>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/FormStep/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {useImmerReducer} from 'use-immer';

import {ConfigContext, FormioTranslations} from 'Context';
import {get} from 'api';
import ButtonsToolbar from 'components/ButtonsToolbar';
import ButtonsGroup from 'components/ButtonsGroup';
import Card, {CardTitle} from 'components/Card';
import {EmailVerificationModal} from 'components/EmailVerification';
import FormStepDebug from 'components/FormStepDebug';
Expand Down Expand Up @@ -823,7 +823,7 @@ const FormStep = () => {
}}
/>
{config.debug ? <FormStepDebug data={getCurrentFormData()} /> : null}
<ButtonsToolbar
<ButtonsGroup
canSubmitStep={canSubmit}
canSubmitForm={submission.submissionAllowed}
canSuspendForm={form.suspensionAllowed}
Expand Down
Loading
Loading