-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
6 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
2 changes: 2 additions & 0 deletions
2
apps/wpcom-block-editor/src/wpcom/features/live-preview/index.scss
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,2 @@ | ||
@import "./upgrade-modal"; | ||
@import "./upgrade-notice"; |
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
36 changes: 36 additions & 0 deletions
36
apps/wpcom-block-editor/src/wpcom/features/live-preview/upgrade-modal.scss
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,36 @@ | ||
@import "@automattic/typography/styles/variables"; | ||
// stylelint-disable-next-line scss/at-import-no-partial-leading-underscore | ||
@import "calypso/assets/stylesheets/shared/mixins/_breakpoints"; | ||
// stylelint-disable-next-line scss/at-import-no-partial-leading-underscore | ||
@import "calypso/assets/stylesheets/shared/_loading"; | ||
|
||
// Overriding ..wp-core-ui styles | ||
.wpcom-live-preview-upgrade-modal { | ||
&.card { | ||
border: none; | ||
} | ||
.theme-upgrade-modal p { | ||
font-size: $font-body; | ||
} | ||
.theme-upgrade-modal .theme-upgrade-modal__actions.bundle { | ||
.button { | ||
color: var(--color-neutral-70); | ||
border-color: var(--color-neutral-10); | ||
background-color: transparent; | ||
font-size: $font-body-small; | ||
line-height: 22px; | ||
&.is-primary { | ||
color: var(--color-text-inverted); | ||
border-color: var(--color-primary); | ||
background-color: var(--color-primary); | ||
} | ||
} | ||
} | ||
.theme-upgrade-modal__included h2 { | ||
margin-top: 0; | ||
line-height: 1.5; | ||
} | ||
.theme-upgrade-modal__close { | ||
padding: 8px 14px; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
apps/wpcom-block-editor/src/wpcom/features/live-preview/upgrade-modal.tsx
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,53 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { FC, useEffect, useState } from 'react'; | ||
import { ThemeUpgradeModal } from 'calypso/components/theme-upgrade-modal'; | ||
import './upgrade-modal.scss'; | ||
|
||
export const LivePreviewUpgradeModal: FC< { themeId: string; upgradePlan: () => void } > = ( { | ||
themeId, | ||
upgradePlan, | ||
} ) => { | ||
const [ isThemeUpgradeModalOpen, setIsThemeUpgradeModalOpen ] = useState( false ); | ||
|
||
/** | ||
* FIXME: This is only testing purpose to show the modal. | ||
* SaveButton customization should be changed to use https://github.com/WordPress/gutenberg/pull/56807. | ||
*/ | ||
useEffect( () => { | ||
const button = document.querySelector( '.edit-site-save-hub__button' ); | ||
button?.addEventListener( 'click', ( e ) => { | ||
e.preventDefault(); | ||
setIsThemeUpgradeModalOpen( true ); | ||
} ); | ||
}, [] ); | ||
|
||
/** | ||
* Load SVG file for `Gridicon` in `@automattic/components`. | ||
*/ | ||
useEffect( () => { | ||
fetch( 'https://widgets.wp.com/wpcom-block-editor/images/gridicons-47c7fb356fcb2d963681.svg' ) | ||
.then( ( response ) => response.text() ) | ||
.then( ( svgData ) => { | ||
const div = document.createElement( 'div' ); | ||
div.innerHTML = svgData; | ||
div.style.display = 'none'; | ||
document.body.insertBefore( div, document.body.childNodes[ 0 ] ); | ||
} ) | ||
.catch( () => { | ||
/** Do nothing */ | ||
} ); | ||
}, [] ); | ||
|
||
const queryClient = new QueryClient(); | ||
return ( | ||
<QueryClientProvider client={ queryClient }> | ||
<ThemeUpgradeModal | ||
additionalClassNames="wpcom-live-preview-upgrade-modal" | ||
slug={ themeId } | ||
isOpen={ isThemeUpgradeModalOpen } | ||
closeModal={ () => setIsThemeUpgradeModalOpen( false ) } | ||
checkout={ upgradePlan } | ||
/> | ||
</QueryClientProvider> | ||
); | ||
}; |
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