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

Callouts in DCR - PR 3/5 - Add new form #6833

Merged
merged 30 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b26c0d4
added new form
tkgnm Dec 22, 2022
e78017b
fixed error naming
tkgnm Dec 22, 2022
b021f5a
adding old form back in
tkgnm Dec 22, 2022
5e7a840
adding stories
tkgnm Dec 22, 2022
e79514d
moving files adding tests
tkgnm Dec 22, 2022
30fea06
fixed imports
tkgnm Dec 22, 2022
f5d77e7
fixing imports
tkgnm Dec 22, 2022
ce2bfc4
fixed stories
tkgnm Dec 22, 2022
9501f42
removing unused form
tkgnm Dec 22, 2022
9e0a9b8
removed nit, do not render unsupported fields
tkgnm Dec 23, 2022
5a7a35a
using error summary from source development kitchen
tkgnm Dec 23, 2022
657fdbf
added visual regression testing for news opinion
tkgnm Dec 23, 2022
6acb2ed
Update Form.stories.tsx
tkgnm Dec 23, 2022
b1d1599
added context text
tkgnm Dec 23, 2022
170b7d0
remove fullstop
tkgnm Dec 30, 2022
007d69c
add fullstop
tkgnm Dec 30, 2022
b9adaf1
updating form/formfields
tkgnm Dec 30, 2022
5efd578
Revert "updating form/formfields"
tkgnm Dec 31, 2022
a21e0e9
use new form, focus on first invalid element
tkgnm Dec 31, 2022
cfb8692
remove undefined
tkgnm Dec 31, 2022
6fdf2ce
Merge remote-tracking branch 'origin/add-callout-components-descripti…
tkgnm Dec 31, 2022
525a164
merged pr 2
tkgnm Dec 31, 2022
7cd6a6a
changed location of folder
tkgnm Dec 31, 2022
adf8d5b
fixed error summary box
tkgnm Jan 3, 2023
608d331
Update Form.tsx
tkgnm Jan 3, 2023
cd276fb
added fetchmock to stories
tkgnm Jan 3, 2023
9ad0f82
Merge branch 'main' into add-callout-form-dcr
tkgnm Jan 3, 2023
e9ff5f6
remove unnecessary css
tkgnm Jan 4, 2023
7b83b93
Revert "remove unnecessary css"
tkgnm Jan 5, 2023
2545f7c
Revert "Revert "remove unnecessary css""
tkgnm Jan 5, 2023
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
144 changes: 144 additions & 0 deletions dotcom-rendering/fixtures/manual/calloutCampaignV2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import type { CalloutBlockElementV2 } from '../../src/types/content';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the mock campaign for the story. It uses every type of callout field that we should expect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - good coverage


export const calloutCampaign: CalloutBlockElementV2 = {
_type: 'model.dotcomrendering.pageElements.CalloutBlockElementV2',
elementId: 'mockId',
id: '14d1b1bc-8983-43fb-8f2e-8ca08a711944',
calloutsUrl:
'https://callouts.code.dev-guardianapis.com/formstack-campaign/submit',
tagName: 'callout-early-coronavirus-events',
activeFrom: 1588118400000,
activeUntil: 1671887011,
displayOnSensitive: false,
formId: 3860296,
title: 'Are you affected by the issues in this article?',
isNonCollapsible: true,
description:
'<p>We’d like to hear how people are being affected, whether they’re applying for a mortgage or refixing an existing one. Are you on a variable rate mortgage, or a fixed rate that is about to expire? How will it impact you financially? </p> <p> We’re also interested in how people, particularly first-time buyers, have been affected by disappearing mortgage deals. </p> ',
formFields: [
{
name: 'your_name',
description: 'How should we refer to you?',
hideLabel: false,
label: 'Your name',
id: 'name',
type: 'text',
required: true,
},
{
name: 'where_do_you_live',
description: 'Town or area is fine.',
hideLabel: false,
label: 'Where do you live?',
id: 'live',
type: 'text',
required: true,
},
{
name: 'tell_us_a_bit_about_yourself',
description: 'For example, your age and what you do',
hideLabel: false,
label: 'Tell us a bit about yourself',
id: 'about',
type: 'text',
required: true,
},
{
name: 'share_your_experiences',
description: 'Give as much or as little detail as you would like',
hideLabel: false,
label: 'Share your experiences here',
id: 'experience',
type: 'textarea',
required: true,
},
{
name: 'what_events_did_you_attend',
description: 'Select as many as you like',
hideLabel: false,
label: 'What events did you attend? ',
id: 'events',
type: 'checkbox',
required: false,
options: [
{
label: '1st Dec',
value: '1st Dec',
},
{
label: '3rd Dec',
value: '3rd Dec',
},
{
label: '5th Dec',
value: '5th Dec',
},
],
},
{
name: 'upload_image_video',
description:
'File uploads not work on some mobile devices, or files may be too large.',
hideLabel: false,
label: 'Add a file',
id: 'upload',
type: 'file',
required: false,
},
{
name: 'can_we_publish_your_response',
options: [
{
label: 'Yes, entirely',
value: 'Yes, entirely',
},
{
label: 'Yes, but please keep me anonymous',
value: 'Yes, but please keep me anonymous',
},
{
label: 'Yes, but please contact me first',
value: 'Yes, but please contact me first',
},
{
label: 'No, this is information only',
value: 'No, this is information only',
},
],
hideLabel: false,
label: 'Can we publish your response?',
id: 'permissions',
type: 'select',
required: true,
},
{
name: 'your_phone_number',
description:
'Your contact details will only be seen by the Guardian',
hideLabel: false,
label: 'Your phone number',
id: 'phone',
type: 'text',
required: true,
},
{
name: 'your_email_address',
description:
'Your contact details will only be seen by the Guardian',
hideLabel: false,
label: 'Your e-mail address',
id: 'email',
type: 'text',
required: true,
},
{
name: 'additional_information',
description: 'Is there anything else you would like to add',
hideLabel: false,
label: 'Additional information',
id: 'additional',
type: 'textarea',
required: false,
},
],
};
2 changes: 1 addition & 1 deletion dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@guardian/shimport": "^1.0.2",
"@guardian/source-foundations": "^7.0.1",
"@guardian/source-react-components": "^9.0.0",
"@guardian/source-react-components-development-kitchen": "6.0.2",
"@guardian/source-react-components-development-kitchen": "8.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so we can use the new shareCallout svg from source

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you bump this to 8.2.0 you'll get the updated styling for the FileInput field as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant! Thanks - will do this next PR, as I'll have to for the tabs anyway

"@guardian/support-dotcom-components": "^1.0.7",
"@guardian/tsconfig": "^0.1.4",
"@percy/cli": "^1.4.0",
Expand Down
59 changes: 14 additions & 45 deletions dotcom-rendering/src/web/components/Callout/Form.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,29 @@
import { css } from '@emotion/react';
import {
calloutCampaign,
calloutCampaignOnlyTwoRadio,
} from '../../../../fixtures/manual/calloutCampaign';
import { ArticleDesign, ArticleDisplay, ArticlePillar } from '@guardian/libs';
import { calloutCampaign } from '../../../../fixtures/manual/calloutCampaign';
import { Form } from './Form';

const mockFormat = {
display: ArticleDisplay.Standard,
design: ArticleDesign.Standard,
theme: ArticlePillar.Opinion,
};

export default {
component: Form,
title: 'Components/Callout/Form',
};

export const Default = () => {
return (
<div
css={css`
width: 630px;
padding: 15px;
`}
>
<Form formFields={calloutCampaign.formFields} onSubmit={() => {}} />
</div>
);
};
Default.story = { name: 'default' };

export const WithOnlyTwoRadio = () => {
return (
<div
css={css`
width: 630px;
padding: 15px;
`}
>
<Form
formFields={calloutCampaignOnlyTwoRadio.formFields}
onSubmit={() => {}}
/>
</div>
);
};
WithOnlyTwoRadio.story = { name: 'with only two radio' };

export const WithError = () => {
return (
<div
css={css`
width: 630px;
padding: 15px;
`}
>
<>
<Form
format={mockFormat}
formFields={calloutCampaign.formFields}
onSubmit={() => {}}
error="I am a form error"
/>
</div>
;
</>
);
};
WithError.story = { name: 'with errors' };

Default.story = { name: 'default' };
Loading