Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions extensions/shared/styles/gutenberg-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* https://github.com/WordPress/gutenberg/blob/df6a17c8eb07e1355527b01e99ee22cf4c2338d7/assets/stylesheets/_variables.scss
*/

$default-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
$default-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
'Helvetica Neue', sans-serif;
$default-font-size: 13px;
$default-line-height: 1.4;
$editor-font: "Noto Serif", serif;
$editor-font: 'Noto Serif', serif;
$editor-html-font: Menlo, Consolas, monaco, monospace;
$editor-font-size: 16px;
$text-editor-font-size: 14px;
Expand All @@ -20,3 +21,9 @@ $break-xlarge: 1080px;
//$break-large: 960px; // admin sidebar auto folds
//$break-medium: 782px; // editor sidebar auto folds
$break-small: 600px;

// Block UI
$border-width: 1px;

// Blocks
$block-padding: 14px; // Space between block footprint and focus boundaries. These are drawn outside the block footprint, and do not affect the size.
55 changes: 31 additions & 24 deletions extensions/shared/upgrade-nudge/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { Button } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { Warning } from '@wordpress/editor';
import Gridicon from 'gridicons';

/**
Expand All @@ -17,33 +18,39 @@ import './store';
import './style.scss';

const UpgradeNudge = ( { planName, planPathSlug, postId, postType } ) => (
<div className="jetpack-upgrade-nudge">
<Gridicon className="jetpack-upgrade-nudge__icon" icon="star" size={ 18 } />
<Warning
actions={ [
<Button
href={ addQueryArgs(
`https://wordpress.com/checkout/${ getSiteFragment() }/${ planPathSlug }`,
{
redirect_to: `/${ postType }/${ getSiteFragment() }/${ postId }`,
}
) }
target="_top"
isDefault
>
{ __( 'Upgrade', 'jetpack' ) }
</Button>,
] }
className="jetpack-upgrade-nudge"
>
<div className="jetpack-upgrade-nudge__info">
<span className="jetpack-upgrade-nudge__title">
{ sprintf( __( 'Upgrade to %(planName)s', 'jetpack' ), {
planName,
} ) }
</span>
<span className="jetpack-upgrade-nudge__message">
{ __( 'To make this block visible on your site', 'jetpack' ) }
</span>
<Gridicon className="jetpack-upgrade-nudge__icon" icon="star" size={ 18 } />
<div>
<span className="jetpack-upgrade-nudge__title">
{ sprintf( __( 'This block is available under the %(planName)s Plan.', 'jetpack' ), {
planName,
} ) }
</span>
<span className="jetpack-upgrade-nudge__message">
{ __( 'It will be hidden from site visitors until you upgrade.', 'jetpack' ) }
</span>
</div>
</div>
<Button
className="jetpack-upgrade-nudge__button"
href={ addQueryArgs(
`https://wordpress.com/checkout/${ getSiteFragment() }/${ planPathSlug }`,
{
redirect_to: `/${ postType }/${ getSiteFragment() }/${ postId }`,
}
) }
target="_top"
isDefault
>
{ __( 'Upgrade', 'jetpack' ) }
</Button>
</div>
</Warning>
);

export default withSelect( ( select, { plan: planSlug } ) => {
const plan = select( 'wordpress-com/plans' ).getPlan( planSlug );

Expand Down
63 changes: 34 additions & 29 deletions extensions/shared/upgrade-nudge/style.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
.jetpack-upgrade-nudge {
border-left: 3px solid var( --color-plan-premium );
box-shadow: 0 0 0 1px var( --color-border-subtle );
display: flex;
margin: 0 -1px 1em 0;
padding: 12px 16px;
text-align: left;
width: 100%;
}
&.block-editor-warning {
margin-bottom: 0;
}

.jetpack-upgrade-nudge__icon {
background: var( --color-plan-premium );
border-radius: 50%;
box-sizing: content-box;
margin-right: 16px;
color: var( --color-white );
padding: 6px;
align-self: center;
flex: 0 0 auto;
fill: var( --color-white );
}
// Override `.editor-styles-wrapper p` style overrides on WordPress.com
.editor-warning__message {
margin: 1em 0;
}

.jetpack-upgrade-nudge__title {
font-size: 14px;
}
.editor-warning__actions {
line-height: 1;
}

.jetpack-upgrade-nudge__message {
color: var( --color-text-subtle );
font-size: 12px;
display: block;
}
.jetpack-upgrade-nudge__icon {
align-self: center;
background: var( --color-plan-premium );
border-radius: 50%;
box-sizing: content-box;
color: var( --color-white );
fill: var( --color-white );
flex-shrink: 0;
margin-right: 16px;
padding: 6px;
}

.jetpack-upgrade-nudge__info {
display: flex;
flex-direction: row;
}

.jetpack-upgrade-nudge__title {
font-size: 14px;
}

.jetpack-upgrade-nudge__button {
margin-left: auto;
.jetpack-upgrade-nudge__message {
color: var( --color-text-subtle );
display: block;
}
}
12 changes: 7 additions & 5 deletions extensions/shared/wrap-paid-block/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/

import classNames from 'classnames';
import { createHigherOrderComponent } from '@wordpress/compose';

/**
Expand All @@ -15,11 +15,13 @@ export default ( { requiredPlan } ) =>
createHigherOrderComponent(
WrappedComponent => props => (
// Wraps the input component in a container, without mutating it. Good!
<div className="jetpack-paid-block__wrapper">
<div
className={ classNames( 'jetpack-paid-block__wrapper', {
'is-selected': props.isSelected,
} ) }
>
<UpgradeNudge plan={ requiredPlan } />
<div className="jetpack-paid-block__disabled">
<WrappedComponent { ...props } />
</div>
<WrappedComponent { ...props } />
</div>
),
'wrapPaidBlock'
Expand Down
16 changes: 10 additions & 6 deletions extensions/shared/wrap-paid-block/style.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.jetpack-paid-block__wrapper {
border: 1px solid var( --color-border-subtle );
}
@import '../styles/gutenberg-colors.scss';
@import '../styles/gutenberg-variables.scss';

.jetpack-paid-block__disabled {
opacity: 0.5;
padding: 10px;
// The block gets a border from Gutenberg if it is selected,
// so we only add ours if it isn't.
.jetpack-paid-block__wrapper:not( .is-selected ) {
border: $border-width solid $light-gray-500; // To reflect the `Warning` component from `@wordpress/editor`
margin-left: -#{$block-padding};
margin-right: -#{$block-padding};
padding-left: calc( #{$block-padding} - #{$border-width} );
padding-right: calc( #{$block-padding} - #{$border-width} );
}