Apply spacing improvements to the Checkout block (#47565)
This commit is contained in:
parent
d4a4590ed6
commit
bb92392d9f
|
@ -1,4 +1,5 @@
|
||||||
.wc-block-checkout__actions {
|
.wc-block-checkout__actions {
|
||||||
|
|
||||||
&_row {
|
&_row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -37,7 +38,6 @@
|
||||||
|
|
||||||
.is-large {
|
.is-large {
|
||||||
.wc-block-checkout__actions {
|
.wc-block-checkout__actions {
|
||||||
border-top: 1px solid $universal-border-light;
|
padding: 0 0 $gap-largest 0;
|
||||||
padding: $gap-larger 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import { ORDER_FORM_KEYS } from '@woocommerce/block-settings';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import Block from './block';
|
import Block from './block';
|
||||||
import './editor.scss';
|
|
||||||
|
|
||||||
export const Edit = ( {
|
export const Edit = ( {
|
||||||
attributes,
|
attributes,
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
// Adjust padding and margins in the editor to improve selected block outlines.
|
|
||||||
.wp-block-woocommerce-checkout-order-note-block {
|
|
||||||
margin-top: 20px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding-top: 4px;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
|
|
||||||
.wc-block-checkout__add-note {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import { registerBlockType } from '@wordpress/blocks';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { Edit, Save } from './edit';
|
import { Edit, Save } from './edit';
|
||||||
import './style.scss';
|
|
||||||
import attributes from './attributes';
|
import attributes from './attributes';
|
||||||
|
|
||||||
registerBlockType( 'woocommerce/checkout-additional-information-block', {
|
registerBlockType( 'woocommerce/checkout-additional-information-block', {
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
.wc-block-checkout__add-note {
|
|
||||||
margin: $gap-larger 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.is-mobile,
|
|
||||||
.is-small,
|
|
||||||
.is-medium {
|
|
||||||
.wc-block-checkout__add-note {
|
|
||||||
border-bottom: 1px solid $universal-border-light;
|
|
||||||
margin-bottom: em($gap);
|
|
||||||
margin-top: em($gap);
|
|
||||||
padding: em($gap) 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wc-block-checkout__add-note .wc-block-components-textarea {
|
|
||||||
border: 1px solid $universal-border-light;
|
|
||||||
margin-top: $gap;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
background-color: #fff;
|
|
||||||
color: currentColor;
|
|
||||||
outline: 0;
|
|
||||||
box-shadow: 0 0 0 2px currentColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wc-block-components-form
|
|
||||||
.wc-block-checkout__order-notes.wc-block-components-checkout-step {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
|
@ -1,9 +1,13 @@
|
||||||
// Adjust padding and margins in the editor to improve selected block outlines.
|
// Adjust padding and margins in the editor to improve selected block outlines.
|
||||||
.wp-block-woocommerce-checkout-order-note-block {
|
.wp-block-woocommerce-checkout-order-note-block {
|
||||||
margin-top: 20px;
|
margin: $gap-largest 0;
|
||||||
margin-bottom: 20px;
|
padding: 4px 0;
|
||||||
padding-top: 4px;
|
|
||||||
padding-bottom: 4px;
|
.wc-block-checkout__order-notes.wc-block-components-checkout-step {
|
||||||
|
.wc-block-components-form & {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.wc-block-checkout__add-note {
|
.wc-block-checkout__add-note {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
.wc-block-checkout__add-note {
|
.wc-block-checkout__add-note {
|
||||||
margin: $gap-larger 0;
|
margin: 0 0 $gap-largest 0;
|
||||||
}
|
line-height: 1;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
.is-mobile,
|
.wc-block-components-checkbox {
|
||||||
.is-small,
|
line-height: 1;
|
||||||
.is-medium {
|
margin-top: 0;
|
||||||
.wc-block-checkout__add-note {
|
margin-bottom: -3px;
|
||||||
border-bottom: 1px solid $universal-border-light;
|
|
||||||
margin-bottom: em($gap);
|
|
||||||
margin-top: em($gap);
|
|
||||||
padding: em($gap) 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.wc-block-checkout__add-note .wc-block-components-textarea {
|
.wc-block-checkout__add-note .wc-block-components-textarea {
|
||||||
border: 1px solid $universal-border-light;
|
border: 1px solid $universal-border-light;
|
||||||
margin-top: $gap;
|
margin-top: $gap;
|
||||||
|
@ -28,4 +26,12 @@
|
||||||
.wc-block-components-form
|
.wc-block-components-form
|
||||||
.wc-block-checkout__order-notes.wc-block-components-checkout-step {
|
.wc-block-checkout__order-notes.wc-block-components-checkout-step {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
margin-bottom: $gap-largest;
|
||||||
|
|
||||||
|
.is-medium &,
|
||||||
|
.is-small &,
|
||||||
|
.is-mobile & {
|
||||||
|
border-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
.wc-block-components-shipping-rates-control__no-results-notice .components-notice__content {
|
.wc-block-components-shipping-rates-control__no-results-notice .components-notice__content {
|
||||||
color: $black;
|
color: $black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.wc-block-components-shipping-rates-control label.wc-block-components-radio-control__option {
|
||||||
|
.is-small & {
|
||||||
|
padding: 0.875em 0.875em 0.875em em($gap-huge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
"text": {
|
"text": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": false
|
"required": false
|
||||||
|
},
|
||||||
|
"showSeparator": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parent": [ "woocommerce/checkout-fields-block" ],
|
"parent": [ "woocommerce/checkout-fields-block" ],
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
} from '@wordpress/components';
|
} from '@wordpress/components';
|
||||||
import { PRIVACY_URL, TERMS_URL } from '@woocommerce/block-settings';
|
import { PRIVACY_URL, TERMS_URL } from '@woocommerce/block-settings';
|
||||||
import { ADMIN_URL } from '@woocommerce/settings';
|
import { ADMIN_URL } from '@woocommerce/settings';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -24,10 +25,10 @@ import './editor.scss';
|
||||||
import { termsConsentDefaultText, termsCheckboxDefaultText } from './constants';
|
import { termsConsentDefaultText, termsCheckboxDefaultText } from './constants';
|
||||||
|
|
||||||
export const Edit = ( {
|
export const Edit = ( {
|
||||||
attributes: { checkbox, text },
|
attributes: { checkbox, text, showSeparator },
|
||||||
setAttributes,
|
setAttributes,
|
||||||
}: {
|
}: {
|
||||||
attributes: { text: string; checkbox: boolean };
|
attributes: { text: string; checkbox: boolean; showSeparator: boolean };
|
||||||
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
||||||
} ): JSX.Element => {
|
} ): JSX.Element => {
|
||||||
const blockProps = useBlockProps();
|
const blockProps = useBlockProps();
|
||||||
|
@ -126,9 +127,22 @@ export const Edit = ( {
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<ToggleControl
|
||||||
|
label={ __( 'Show separator', 'woocommerce' ) }
|
||||||
|
checked={ showSeparator }
|
||||||
|
onChange={ () =>
|
||||||
|
setAttributes( {
|
||||||
|
showSeparator: ! showSeparator,
|
||||||
|
} )
|
||||||
|
}
|
||||||
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<div className="wc-block-checkout__terms">
|
<div
|
||||||
|
className={ clsx( 'wc-block-checkout__terms', {
|
||||||
|
'wc-block-checkout__terms--with-separator': showSeparator,
|
||||||
|
} ) }
|
||||||
|
>
|
||||||
{ checkbox ? (
|
{ checkbox ? (
|
||||||
<>
|
<>
|
||||||
<CheckboxControl
|
<CheckboxControl
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
|
.edit-post-visual-editor {
|
||||||
|
|
||||||
|
.is-small,
|
||||||
|
.is-medium {
|
||||||
|
.wc-block-checkout__terms {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust padding and margins in the editor to improve selected block outlines.
|
// Adjust padding and margins in the editor to improve selected block outlines.
|
||||||
.wc-block-checkout__terms {
|
.wc-block-checkout__terms {
|
||||||
margin: $gap-larger 0;
|
margin: 0 0 $gap-largest 0;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -20,9 +20,11 @@ const FrontendBlock = ( {
|
||||||
checkbox,
|
checkbox,
|
||||||
instanceId,
|
instanceId,
|
||||||
className,
|
className,
|
||||||
|
showSeparator,
|
||||||
}: {
|
}: {
|
||||||
text: string;
|
text: string;
|
||||||
checkbox: boolean;
|
checkbox: boolean;
|
||||||
|
showSeparator: string | boolean;
|
||||||
instanceId: string;
|
instanceId: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
} ): JSX.Element => {
|
} ): JSX.Element => {
|
||||||
|
@ -76,6 +78,8 @@ const FrontendBlock = ( {
|
||||||
'wc-block-checkout__terms',
|
'wc-block-checkout__terms',
|
||||||
{
|
{
|
||||||
'wc-block-checkout__terms--disabled': isDisabled,
|
'wc-block-checkout__terms--disabled': isDisabled,
|
||||||
|
'wc-block-checkout__terms--with-separator':
|
||||||
|
showSeparator !== 'false' && showSeparator !== false,
|
||||||
},
|
},
|
||||||
className
|
className
|
||||||
) }
|
) }
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
.wc-block-checkout__terms {
|
.wc-block-checkout__terms {
|
||||||
margin: $gap-larger 0;
|
margin: 0 0 $gap-largest;
|
||||||
|
|
||||||
|
.is-mobile &,
|
||||||
|
.is-small & {
|
||||||
|
margin-bottom: $gap-larger;
|
||||||
|
|
||||||
|
&.wc-block-checkout__terms--with-separator {
|
||||||
|
padding-top: $gap-larger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.wc-block-checkout__terms--with-separator {
|
||||||
|
padding-top: $gap-largest;
|
||||||
|
border-top: 1px solid $universal-border-light;
|
||||||
|
|
||||||
|
|
||||||
|
.is-mobile &,
|
||||||
|
.is-small & {
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
top: -5px;
|
top: -5px;
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
.wc-block-components-shipping-rates-control__package {
|
.wc-block-components-shipping-rates-control__package {
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
margin: 0 0 1em;
|
margin: 0 0 1em;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,38 @@
|
||||||
.wc-block-components-form .wc-block-components-checkout-step {
|
.wc-block-components-form .wc-block-components-checkout-step {
|
||||||
position: relative;
|
position: relative;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
background: none;
|
||||||
|
margin: 0 0 $gap-largest 0;
|
||||||
|
|
||||||
.is-mobile &,
|
.is-mobile &,
|
||||||
.is-small & {
|
.is-small & {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
margin-bottom: $gap-larger;
|
||||||
|
|
||||||
|
// The below CSS rules are to show a separator between Checkout steps on mobile.
|
||||||
|
// This media query is required because on themes where the Checkout block is rendered alongside something else,
|
||||||
|
// e.g. Storefront using the "Default Template" (which has a sidebar) the checkout block can get the `.is-small`
|
||||||
|
// class, but the screen itself is larger than 400px.
|
||||||
|
@include breakpoint( "<600px" ) {
|
||||||
|
padding-top: $gap-larger;
|
||||||
|
|
||||||
|
// Remove padding from the first checkout step. First of type is required here as the first-child is the express payment methods block.
|
||||||
|
&:first-of-type {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
bottom: -$gap-larger;
|
||||||
|
left: -100vw;
|
||||||
|
width: 200vw;
|
||||||
|
height: 1px;
|
||||||
|
background: currentColor;
|
||||||
|
opacity: 0.11;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +55,10 @@
|
||||||
|
|
||||||
.wc-block-components-checkout-step__content > * {
|
.wc-block-components-checkout-step__content > * {
|
||||||
margin-bottom: $gap;
|
margin-bottom: $gap;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.wc-block-components-checkout-step--with-step-number .wc-block-components-checkout-step__content > :last-child {
|
.wc-block-components-checkout-step--with-step-number .wc-block-components-checkout-step__content > :last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
@ -38,7 +67,7 @@
|
||||||
margin-top: em($gap-smaller);
|
margin-top: em($gap-smaller);
|
||||||
}
|
}
|
||||||
.wc-block-components-checkout-step__heading {
|
.wc-block-components-checkout-step__heading {
|
||||||
margin: $gap-larger 0 $gap-smaller;
|
margin: 0 0 $gap-smaller;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.wc-block-components-express-payment-continue-rule + .wc-block-components-checkout-step & {
|
.wc-block-components-express-payment-continue-rule + .wc-block-components-checkout-step & {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
Add a control to enable a separator on the Checkout block's "Checkout Terms" block. This will enable a separator above the block that can be turned off in case the block is moved.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: enhancement
|
||||||
|
|
||||||
|
Improve spacing between steps in the Checkout block on mobile and desktop
|
Loading…
Reference in New Issue