-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix postMessage in embedded Contact form (#2673)
* Fix postMessage in embedded Contact form [CORE-532] * Separate embedded form Add thank you * Screaming snake case * Fix layout issues * Link to subjects page instead of errata
- Loading branch information
1 parent
be1ae78
commit 097a0de
Showing
8 changed files
with
209 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import Form from './form'; | ||
import './embedded.scss'; | ||
|
||
// File is js because it is dynamically imported (and minimal) | ||
export default function EmbeddedForm() { | ||
const [submitted, setSubmitted] = React.useState(false); | ||
|
||
if (submitted) { | ||
return <ThankYou />; | ||
} | ||
|
||
return ( | ||
<main id="maincontent" className="embedded-contact"> | ||
<h1>Report an issue</h1> | ||
<div> | ||
Need to suggest a content correction instead? Find the book | ||
on our{' '} | ||
<a href="/subjects" target="_blank"> | ||
subjects page | ||
</a>. | ||
{' '}You can submit errata from the details page for the book. | ||
</div> | ||
<Form setSubmitted={setSubmitted} /> | ||
</main> | ||
); | ||
} | ||
|
||
function ThankYou() { | ||
const signalDone = React.useCallback( | ||
() => window.parent.postMessage('CONTACT_FORM_SUBMITTED', '*'), | ||
[] | ||
); | ||
|
||
return ( | ||
<main id="maincontent" className="embedded-contact"> | ||
<h1>Thanks for contacting us.</h1> | ||
<div>Someone from our team will follow up with you soon.</div> | ||
<button type="button" className="btn primary" onClick={signalDone}> | ||
Done | ||
</button> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@import 'pattern-library/core/pattern-library/headers'; | ||
|
||
.embedded-contact { | ||
max-width: calc(100vw - 6rem); | ||
width: $text-content-max; | ||
margin: 3rem auto; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2rem; | ||
|
||
h1 { | ||
@include set-font(h3); | ||
margin: 0; | ||
} | ||
|
||
form { | ||
@include wider-than($tablet-max) { | ||
padding-left: 4rem; | ||
} | ||
} | ||
|
||
button:not(.clear-file) { | ||
@include button(); | ||
|
||
&.primary { | ||
@extend %primary; | ||
align-self: flex-start; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@import 'pattern-library/core/pattern-library/headers'; | ||
@import '../errata-form/form/FileUploader'; | ||
|
||
form { | ||
textarea { | ||
height: auto; | ||
resize: none; | ||
} | ||
|
||
> .form-content > label { | ||
display: block; | ||
height: $form-element-height; | ||
margin-bottom: $form-element-height; | ||
|
||
&.auto-height { | ||
height: auto; | ||
} | ||
|
||
} | ||
|
||
.file-button { | ||
@include file-button(); | ||
margin-bottom: $normal-margin; | ||
} | ||
|
||
.label-text { | ||
@include set-font(h4); | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.btn, | ||
.btn[type="submit"] { | ||
@include button(); | ||
width: 12rem; | ||
padding: 0; | ||
|
||
} | ||
|
||
[type="submit"] { | ||
@extend %primary; | ||
|
||
float: none; | ||
margin: 0; | ||
padding: 0 5rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@mixin file-button() { | ||
align-items: center; | ||
display: grid; | ||
grid-gap: 1rem; | ||
grid-template-columns: repeat(3, auto) 1fr; | ||
|
||
&.empty { | ||
order: 1; | ||
|
||
+ .file-button.empty { | ||
display: none; | ||
} | ||
} | ||
|
||
.clear-file { | ||
appearance: none; | ||
background-color: inherit; | ||
color: inherit; | ||
justify-self: left; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters