-
Notifications
You must be signed in to change notification settings - Fork 31
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
Changes from 9 commits
b26c0d4
e78017b
b021f5a
5e7a840
e79514d
30fea06
f5d77e7
ce2bfc4
9501f42
9e0a9b8
5a7a35a
657fdbf
6acb2ed
b1d1599
170b7d0
007d69c
b9adaf1
5efd578
a21e0e9
cfb8692
6fdf2ce
525a164
7cd6a6a
adf8d5b
608d331
cd276fb
9ad0f82
e9ff5f6
7b83b93
2545f7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import type { CalloutBlockElementV2 } from '../../src/types/content'; | ||
|
||
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, | ||
}, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is so we can use the new shareCallout svg from source There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you bump this to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
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'; | ||
abeddow91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { ArticleDesign, ArticleDisplay, ArticlePillar } from '@guardian/libs'; | ||
import { calloutCampaign } from '../../../../fixtures/manual/calloutCampaign'; | ||
import { Form } from './Form'; | ||
|
||
const mockFormat = { | ||
abeddow91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
display: ArticleDisplay.Standard, | ||
design: ArticleDesign.Standard, | ||
theme: ArticlePillar.Opinion, | ||
}; | ||
|
||
export default { | ||
component: Form, | ||
title: 'Components/Callout/Form', | ||
}; | ||
|
||
export const Default = () => { | ||
return ( | ||
<div | ||
abeddow91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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' }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice - good coverage