-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21984 from Yoast/415-add-the-consent-modal-to-sit…
…e-kit-setup-flow Add the Site Kit consent modal
- Loading branch information
Showing
3 changed files
with
177 additions
and
27 deletions.
There are no files selected for viewing
78 changes: 67 additions & 11 deletions
78
packages/js/src/shared-admin/components/site-kit-consent-modal.js
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 |
---|---|---|
@@ -1,32 +1,88 @@ | ||
import { Modal } from "@yoast/ui-library"; | ||
import { ArrowSmRightIcon } from "@heroicons/react/solid"; | ||
import { __ } from "@wordpress/i18n"; | ||
import { PropTypes } from "prop-types"; | ||
import { Button, Modal, useSvgAria } from "@yoast/ui-library"; | ||
import PropTypes from "prop-types"; | ||
import { OutboundLink } from "./outbound-link"; | ||
|
||
/** | ||
* The Site Kit consent modal component. | ||
* | ||
* @param {boolean} isOpen Whether the modal is open. | ||
* @param {Function} onClose Callback to close the modal. | ||
* @param {function} onClose Callback to close the modal. | ||
* @param {function} onGrantConsent Callback to grant consent. | ||
* @param {string} learnMoreLink The learn more link. | ||
* @param {string} imageLink The image link. | ||
* | ||
* @returns {JSX.Element} The Site Kit consent modal component. | ||
*/ | ||
export const SiteKitConsentModal = ( { isOpen, onClose } ) => { | ||
export const SiteKitConsentModal = ( { | ||
isOpen, | ||
onClose, | ||
onGrantConsent, | ||
learnMoreLink = "http://yoa.st/sitekit-consent-learn-more", | ||
imageLink = "", | ||
} ) => { | ||
const svgAriaProps = useSvgAria(); | ||
|
||
return ( | ||
<Modal | ||
isOpen={ isOpen } | ||
onClose={ onClose } | ||
> | ||
<Modal.Panel> | ||
<Modal.Title>{ __( "Connect Site Kit by Google", "wordpress-seo" ) }</Modal.Title> | ||
<Modal.Description> | ||
{ __( "Connect your Google account to view traffic and search rankings on your dashboard.", "wordpress-seo" ) } | ||
</Modal.Description> | ||
<Modal.Panel className="yst-max-w-lg yst-p-0 yst-rounded-3xl" hasCloseButton={ false }> | ||
<Modal.CloseButton | ||
className="yst-bg-transparent yst-text-gray-500 focus:yst-ring-offset-0" | ||
onClick={ onClose } | ||
screenReaderText={ __( "Close", "wordpress-seo" ) } | ||
/> | ||
<div className="yst-px-10 yst-pt-10 yst-bg-gradient-to-b yst-from-primary-500/25 yst-to-[80%] yst-text-center"> | ||
<img | ||
className="yst-rounded-md yst-drop-shadow-md yst-bg-slate-100 yst-aspect-video" | ||
alt="" | ||
loading="lazy" | ||
decoding="async" | ||
src={ imageLink } | ||
/> | ||
</div> | ||
<div className="yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center"> | ||
<div className="yst-mt-4 yst-mx-1.5 yst-text-center"> | ||
<h3 className="yst-text-slate-900 yst-text-lg yst-font-medium"> | ||
{ __( "Grant consent to connect with Site Kit by Google", "wordpress-seo" ) } | ||
</h3> | ||
<div className="yst-mt-2 yst-text-slate-600 yst-text-sm"> | ||
{ __( "Give us permission to access your Site Kit data, allowing insights from tools like Google Analytics and Search Console to be displayed directly on your dashboard.", "wordpress-seo" ) } | ||
{ " " } | ||
<OutboundLink | ||
className="yst-no-underline yst-font-medium" | ||
variant="primary" | ||
href={ learnMoreLink } | ||
> | ||
{ __( "Learn more", "wordpress-seo" ) } | ||
<ArrowSmRightIcon | ||
className="yst-inline yst-h-4 yst-w-4 yst-ms-1 rtl:yst-rotate-180" | ||
{ ...svgAriaProps } | ||
/> | ||
</OutboundLink> | ||
</div> | ||
</div> | ||
<div className="yst-w-full yst-flex yst-mt-10"> | ||
<Button className="yst-grow" size="extra-large" variant="primary" onClick={ onGrantConsent || onClose }> | ||
{ __( "Grant consent", "wordpress-seo" ) } | ||
</Button> | ||
</div> | ||
<Button as="a" className="yst-mt-4" variant="tertiary" onClick={ onClose }> | ||
{ __( "Close", "wordpress-seo" ) } | ||
</Button> | ||
</div> | ||
</Modal.Panel> | ||
</Modal> | ||
); | ||
}; | ||
|
||
SiteKitConsentModal.propTypes = { | ||
isOpen: PropTypes.bool, | ||
onClose: PropTypes.func, | ||
isOpen: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
onGrantConsent: PropTypes.func, | ||
learnMoreLink: PropTypes.string, | ||
imageLink: PropTypes.string, | ||
}; |
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