diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/index.tsx b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/index.tsx new file mode 100644 index 0000000000000..dd8b799868a1c --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/index.tsx @@ -0,0 +1,145 @@ +import { Text, Button, ThemeProvider, Col, Container } from '@automattic/jetpack-components'; +import { Modal } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; +import clsx from 'clsx'; +import { useCallback, useState, type FC } from 'react'; +import styles from './style.module.scss'; + +interface ProductInterstitialModalProps { + title: string; + hideCloseButton?: boolean; + triggerButton?: React.ReactNode; + className?: string; + children?: React.ReactNode; + secondaryColumn?: React.ReactNode; + additionalColumn?: React.ReactNode; + onOpen?: () => void; + onClose?: () => void; + onClick?: () => void; + secondaryButtonExternalLink?: boolean; + secondaryButtonHref?: string; + buttonDisabled?: boolean; + buttonExternalLink?: boolean; + buttonHref?: string; + buttonContent?: string; +} + +const ProductInterstitialModal: FC< ProductInterstitialModalProps > = props => { + const { + title, + className, + children, + triggerButton, + onOpen, + onClose, + onClick, + buttonDisabled, + buttonExternalLink, + buttonHref, + buttonContent, + secondaryButtonExternalLink, + secondaryButtonHref, + secondaryColumn, + additionalColumn = false, + } = props; + + const [ isOpen, setOpen ] = useState( false ); + const openModal = useCallback( () => { + onOpen?.(); + setOpen( true ); + }, [ onOpen ] ); + const closeModal = useCallback( () => { + onClose?.(); + setOpen( false ); + }, [ onClose ] ); + + if ( ! title || ! children || ! triggerButton ) { + return null; + } + + return ( + <> + + { + // TODO: use any component as a trigger + } + + { isOpen && ( + + + { + // left column - always takes 33% of the width or the full with for small breakpoint + } + +
+
+ + { title } + +
+ { children } +
+
+ + +
+ + { + // middle column for three columns layout and the right column for two columns layout + // small breakpoint: takes full width + // medium breakpoint: ~63% of the width without the additional column or 50% of the second row with the additional column + // large breakpoint: 66% of the width without the additional column or 33% with the additional column + } + + { secondaryColumn } + + { + // additional column for three columns layout + // small breakpoint (max 4 cols): takes full width + // medium breakpoint (max 8 cols): 50% of the second row width + // large breakpoint (max 12 cols): 33% of the width + additionalColumn && ( + + { additionalColumn } + + ) + } +
+
+ ) } +
+ + ); +}; + +export default ProductInterstitialModal; diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/boost.png b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/boost.png new file mode 100644 index 0000000000000..4e7cb0cec7511 Binary files /dev/null and b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/boost.png differ diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/index.stories.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/index.stories.jsx new file mode 100644 index 0000000000000..0020ce4aaf105 --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/stories/index.stories.jsx @@ -0,0 +1,60 @@ +import { Text, ProductPrice } from '@automattic/jetpack-components'; +import React from 'react'; +import { HashRouter, Routes, Route } from 'react-router-dom'; +import ProductInterstitialModal from '..'; +import boostImage from './boost.png'; + +export default { + title: 'Packages/My Jetpack/Product Interstitial Modal', + component: ProductInterstitialModal, +}; + +const DefaultArgs = { + title: 'Product Interstitial Modal', + children: ( +
+ + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras rutrum neque odio, vel + viverra lectus vulputate et. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Cras rutrum neque odio, vel viverra lectus vulputate et. Lorem ipsum dolor sit amet, + consectetur adipiscing elit. Cras rutrum neque odio, vel viverra lectus vulputate et. + + +
+ ), + triggerButton: 'Open Modal', + hideCloseButton: false, + buttonContent: 'Upgrade now', + secondaryColumn: Boost, + buttonExternalLink: 'https://jetpack.com', +}; + +const Template = args => ( + + + } /> + + +); + +export const Default = Template.bind( {} ); + +export const WithAdditionalColumn = Template.bind( {} ); +WithAdditionalColumn.args = { + ...DefaultArgs, + secondaryColumn:
CTA Content
, + additionalColumn:
Additional Column
, +}; + +Default.parameters = {}; +Default.args = DefaultArgs; diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/style.module.scss b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/style.module.scss new file mode 100644 index 0000000000000..11c74fa30787c --- /dev/null +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial-modal/style.module.scss @@ -0,0 +1,52 @@ +.component-product-interstitial-modal { + :global(.components-modal__header) + div { + height: 100%; + } +} + + +.wrapper { + height: 100%; +} + +.primary { + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.primary-content { + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.primary-footer { + display: flex; + flex-direction: row; + justify-content: space-between; +} + +.secondary { + max-width: 100%; + height: auto; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + + img { + max-width: 100%; + height: auto; + max-height: 100%; + object-fit: contain; + display: flex; + align-items: center; + overflow: hidden; + } +} + +.additional { + display: flex; + flex-direction: column; +} diff --git a/projects/packages/my-jetpack/changelog/add-my-jetpack-modal-interstitial b/projects/packages/my-jetpack/changelog/add-my-jetpack-modal-interstitial new file mode 100644 index 0000000000000..60d58656c8b82 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/add-my-jetpack-modal-interstitial @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Adding new modal based interstitial component.