Skip to content

Commit

Permalink
✨ [#462] Add wrapper for disabled-clickable button
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Oct 23, 2023
1 parent 67973f8 commit 7ac7b53
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import PropTypes from 'prop-types';
import React from 'react';

const DisabledClickableButtonWrapper = ({disabled, onDisabledClick, children}) => {
if (!disabled) return <>{children}</>;

return (
<div onClick={onDisabledClick} className="openforms-disabled-clickable-button">
<div className="openforms-disabled-clickable-button__clickable-wrap">{children}</div>
</div>
);
};

DisabledClickableButtonWrapper.propTypes = {
disabled: PropTypes.bool.isRequired,
onDisabledClick: PropTypes.func.isRequired,
children: PropTypes.node.isRequired,
};

export default DisabledClickableButtonWrapper;
19 changes: 13 additions & 6 deletions src/components/SummaryConfirmation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {Toolbar, ToolbarList} from 'components/Toolbar';
import {SUBMISSION_ALLOWED} from 'components/constants';
import useFormContext from 'hooks/useFormContext';

import DisabledClickableButtonWrapper from './DisabledClickableButtonWrapper';

const isSubmitEnabled = (statementsInfo = [], statementsValues) => {
return statementsInfo.every(info => {
if (!info.validate.required) return true;
Expand Down Expand Up @@ -46,15 +48,20 @@ const SummaryConfirmation = ({submissionAllowed, onPrevPage}) => {
</ToolbarList>
<ToolbarList>
{canSubmit ? (
<UtrechtButton
type="submit"
appearance="primary-action-button"
name="confirm"
<DisabledClickableButtonWrapper
disabled={submitDisabled}
onDisabledClick={() => setShowStatementWarnings(true)}
>
<Literal name="confirmText" />
</UtrechtButton>
<UtrechtButton
type="submit"
appearance="primary-action-button"
name="confirm"
disabled={submitDisabled}
aria-disabled={submitDisabled}
>
<Literal name="confirmText" />
</UtrechtButton>
</DisabledClickableButtonWrapper>
) : null}
</ToolbarList>
</Toolbar>
Expand Down
15 changes: 15 additions & 0 deletions src/scss/components/_disabled-clickable-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import '../mixins/prefix';

.#{prefix(disabled-clickable-button)} {
position: relative;

&__clickable-wrap::before {
cursor: var(--utrecht-action-disabled-cursor, not-allowed);
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
1 change: 1 addition & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
@import './scss/components/floating-widget';
@import './scss/components/date-picker';
@import './scss/components/input-container';
@import './scss/components/disabled-clickable-button';

0 comments on commit 7ac7b53

Please sign in to comment.