Skip to content

Commit dde1535

Browse files
authored
feat: add button for Add supplementary information or instructions in Repeater and Fieldset components TCKT-415 (#596)
* create 'add supplementary information or instructions' button TCKT-415 * feat: add AddInformationOrInstructionsButton to Repeater component TCKT-415 * feat: add AddInformationOrInstructionsButton to Fieldset component TCKT-415
1 parent bbd065d commit dde1535

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

packages/design/src/FormManager/FormEdit/AddPatternDropdown.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ const sidebarPatterns: DropdownPattern[] = [
139139
['rich-text', defaultFormConfig.patterns['rich-text'], 'Other'],
140140
['attachment', defaultFormConfig.patterns['attachment'], 'Other'],
141141
['package-download', defaultFormConfig.patterns['package-download'], 'Other'],
142-
['accordion-row', defaultFormConfig.patterns['accordion-row'], 'Other'], // TODO: remove this from the sidebar menu once accordion-row is added to fieldset and repeater
143142
] as const;
144143

145144
export const compoundFieldChildPatterns: DropdownPattern[] =
@@ -223,6 +222,24 @@ export const CompoundAddPatternButton = ({
223222
);
224223
};
225224

225+
export const AddInformationOrInstructionsButton = ({
226+
patternSelected,
227+
title,
228+
}: PatternMenuProps) => {
229+
return (
230+
<button
231+
className={classNames('usa-button usa-button--unstyled')}
232+
onClick={() => patternSelected('accordion-row')}
233+
>
234+
<span className="display-inline-block text-ttop tablet:width-auto text-center">
235+
<span className="display-inline-block text-ttop margin-right-1 text-underline">
236+
{title}
237+
</span>
238+
</span>
239+
</button>
240+
);
241+
};
242+
226243
export const CompoundAddNewPatternButton = ({
227244
patternSelected,
228245
title,

packages/design/src/FormManager/FormEdit/components/FieldsetEdit/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FieldsetPattern } from '@gsa-tts/forms-core';
77
import {
88
CompoundAddPatternButton,
99
CompoundAddNewPatternButton,
10+
AddInformationOrInstructionsButton,
1011
} from '../../AddPatternDropdown.js';
1112
import { useFormManagerStore } from '../../../store.js';
1213
import { PatternEditComponent } from '../../types.js';
@@ -107,6 +108,12 @@ const FieldsetPreview: PatternComponent<FieldsetProps> = props => {
107108
className="margin-left-3 margin-right-3 margin-bottom-3 bg-none"
108109
>
109110
<div className={classNames(styles.usaAlertBody, 'usa-alert__body')}>
111+
<AddInformationOrInstructionsButton
112+
title="Add supplementary information or instructions"
113+
patternSelected={patternType =>
114+
addPatternToCompoundField(patternType, props._patternId)
115+
}
116+
/>
110117
<CompoundAddPatternButton
111118
title="Add question to set"
112119
patternSelected={patternType =>

packages/design/src/FormManager/FormEdit/components/RepeaterPatternEdit.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RepeaterPattern } from '@gsa-tts/forms-core';
77
import {
88
CompoundAddPatternButton,
99
CompoundAddNewPatternButton,
10+
AddInformationOrInstructionsButton,
1011
} from '../AddPatternDropdown.js';
1112
import { PatternComponent } from '../../../Form/index.js';
1213
import Repeater from '../../../Form/components/Repeater/index.js';
@@ -108,6 +109,12 @@ const RepeaterPreview: PatternComponent<RepeaterProps> = props => {
108109
className="margin-left-3 margin-right-3 margin-bottom-3 bg-none"
109110
>
110111
<div className={classNames(styles.usaAlertBody, 'usa-alert__body')}>
112+
<AddInformationOrInstructionsButton
113+
title="Add supplementary information or instructions"
114+
patternSelected={patternType =>
115+
addPatternToCompoundField(patternType, props._patternId)
116+
}
117+
/>
111118
<CompoundAddPatternButton
112119
title="Add question to set"
113120
patternSelected={patternType =>

0 commit comments

Comments
 (0)