[MVP QA #1] Visual: spacings (#38325)

* Update the margin-left on the buttons in the top bar from 16px to 8px

* On mobile, the left and right body margins should be 32 px

* The inner padding in the tab in the top bar should be 12px, not 16px

* In the edit product link modal, let's set this modal’s width to 650 px and remove the line separating the header from the contents

* All modals should now have 8 px window radius

* In the feedback form, can we fix the buttons at the bottom

* The help icon in checkboxes small, detached from the item label, and vertically misaligned. Left margin of 4 px, no vertical adjustment; somehow it has a -2px set for the top margin)

* Fix block-editor-block-contextual-toolbar top position

* When the product is in a draft state, the button in the top bar should say Add, not Save. It should change into Update once it's published on the store

* Fix layout margin top

* Add ection support for blockGap and set title and description to optional

* Remove non needed control field margin bottom

* Fix schedule sale block spacing

* Remove non needed control field help text margin bottom

* Remove the sub section outer spacing

* Move pricing fields into a sub section block

* Fix collapsible-contet margin top

* Remove invalid inner block layout spacing

* Wrap sku, stock toogle and quantity within a sub section

* Group inventory advance section inner blocks into a sub section

* Fix linter error

* Add changelog files

* Fix php lint error

* Change unit names to fit GB definitions
see: b2c16f3c68/packages/base-styles/_variables.scss\#L31-L41
This commit is contained in:
Maikel David Pérez Gómez 2023-06-01 13:56:31 -04:00 committed by GitHub
parent f815d4f936
commit abcedbefe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 358 additions and 236 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix collapsible content heading alignment

View File

@ -57,14 +57,12 @@ export const CollapsibleContent: React.FC< CollapsedProps > = ( {
displayState !== 'hidden' ? collapsibleContentId : undefined
}
>
<div>
<span>{ toggleText }</span>
<span>{ toggleText }</span>
<Icon
icon={ collapsed ? chevronDown : chevronUp }
size={ 16 }
/>
</div>
<Icon
icon={ collapsed ? chevronDown : chevronUp }
size={ 16 }
/>
</button>
<DisplayState state={ displayState }>

View File

@ -1,18 +1,14 @@
.woocommerce-collapsible-content {
.woocommerce-collapsible-content__toggle {
all: unset;
font-size: 13px;
color: #007CBA;
color: #007cba;
cursor: pointer;
display: flex;
align-items: center;
> div {
display: flex;
align-items: center;
}
svg {
fill: #007CBA;
fill: #007cba;
margin-left: 2px;
}
}

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix modal border radius and content scrolling

View File

@ -107,8 +107,18 @@
}
}
.components-modal__content {
padding-bottom: 100px;
}
.woocommerce-customer-effort-score__buttons {
text-align: right;
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #fff;
padding: calc( 2 * $gap );
.components-button {
margin-left: 1em;

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Add sub section and section spacing

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { createElement, createInterpolateElement } from '@wordpress/element';
import { createElement } from '@wordpress/element';
import type { BlockAttributes } from '@wordpress/blocks';
import { CheckboxControl, Tooltip } from '@wordpress/components';
import { useBlockProps } from '@wordpress/block-editor';
@ -25,38 +25,30 @@ export function Edit( { attributes }: { attributes: BlockAttributes } ) {
return (
<div { ...blockProps }>
<h4> { title } </h4>
<CheckboxControl
label={
tooltip
? createInterpolateElement( `<label /> <tooltip />`, {
label: <span>{ label }</span>,
tooltip: (
<Tooltip
text={ <span>{ tooltip }</span> }
position="top center"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Incorrect types.
className={
'woocommerce-product-form__checkbox-tooltip'
}
delay={ 0 }
>
<span className="woocommerce-product-form__checkbox-tooltip-icon">
<Icon
icon={ help }
size={ 22 }
fill="#949494"
/>
</span>
</Tooltip>
),
} )
: label
}
checked={ value }
onChange={ ( selected ) => setValue( selected ) }
/>
<h4>{ title }</h4>
<div className="woocommerce-product-form__checkbox-wrapper">
<CheckboxControl
label={ label }
checked={ value }
onChange={ ( selected ) => setValue( selected ) }
/>
{ tooltip && (
<Tooltip
text={ <span>{ tooltip }</span> }
position="top center"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Incorrect types.
className={
'woocommerce-product-form__checkbox-tooltip'
}
delay={ 0 }
>
<span className="woocommerce-product-form__checkbox-tooltip-icon">
<Icon icon={ help } size={ 21.94 } fill="#949494" />
</span>
</Tooltip>
) }
</div>
</div>
);
}

View File

@ -1,20 +1,21 @@
.woocommerce-product-form__checkbox {
.components-base-control__field,
.components-checkbox-control__label,
&-wrapper,
&-tooltip-icon {
display: flex;
align-items: center;
}
.components-base-control__field {
display: flex;
align-items: center;
margin-bottom: 0;
}
}
.components-checkbox-control__label {
display: flex;
}
&-tooltip-icon {
margin: -2px 0 0 $gap-small;
display: flex;
align-items: center;
}
.woocommerce-product-form__checkbox-wrapper {
gap: $gap-smallest;
}
.woocommerce-product-form__checkbox-tooltip {
@ -24,4 +25,3 @@
white-space: normal !important;
}
}

View File

@ -145,7 +145,7 @@ export function Edit( {
/>
{ showScheduleSale && (
<div className="wp-block-columns">
<div className="wp-block-columns wp-block-woocommerce-product-schedule-sale-fields__content">
<div className="wp-block-column">
<DateTimePickerControl
ref={

View File

@ -1,21 +1,5 @@
.wp-block-woocommerce-product-schedule-sale-fields {
margin-bottom: $gap-large;
.components-toggle-control {
margin-bottom: $gap;
padding-bottom: $gap-smaller;
}
.components-toggle-control__label {
display: flex;
align-items: center;
}
}
.wp-block-woocommerce-product-section {
> .block-editor-inner-blocks > .block-editor-block-list__layout {
> .wp-block.wp-block-woocommerce-product-schedule-sale-fields:not( :first-child ) {
margin-top: $gap;
}
&__content {
margin-top: $gap-large;
}
}

View File

@ -14,6 +14,11 @@
"description": {
"type": "string",
"__experimentalRole": "content"
},
"blockGap": {
"type": "string",
"enum": [ "unit-30", "unit-40" ],
"default": "unit-30"
}
},
"supports": {

View File

@ -1,34 +1,57 @@
/**
* External dependencies
*/
import classNames from 'classnames';
import { createElement } from '@wordpress/element';
import type { BlockEditProps } from '@wordpress/blocks';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import {
useBlockProps,
// @ts-expect-error no exported member.
useInnerBlocksProps,
} from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import { SectionBlockAttributes } from './types';
import { sanitizeHTML } from '../../utils/sanitize-html';
import { SectionBlockAttributes } from './types';
export function Edit( {
attributes,
}: BlockEditProps< SectionBlockAttributes > ) {
const { description, title, blockGap } = attributes;
const blockProps = useBlockProps();
const { description, title } = attributes;
const innerBlockProps = useInnerBlocksProps(
{
className: classNames(
'wp-block-woocommerce-product-section__content',
`wp-block-woocommerce-product-section__content--block-gap-${ blockGap }`
),
},
{ templateLock: 'all' }
);
const SectionTagName = title ? 'fieldset' : 'div';
const HeadingTagName = SectionTagName === 'fieldset' ? 'legend' : 'div';
return (
<div { ...blockProps }>
<h2 className="wp-block-woocommerce-product-section__title">
<span>{ title }</span>
</h2>
{ description && (
<p
className="wp-block-woocommerce-product-section__description"
dangerouslySetInnerHTML={ sanitizeHTML( description ) }
/>
<SectionTagName { ...blockProps }>
{ title && (
<HeadingTagName className="wp-block-woocommerce-product-section__heading">
<h2 className="wp-block-woocommerce-product-section__heading-title">
{ title }
</h2>
{ description && (
<p
className="wp-block-woocommerce-product-section__heading-description"
dangerouslySetInnerHTML={ sanitizeHTML(
description
) }
/>
) }
</HeadingTagName>
) }
<InnerBlocks templateLock="all" />
</div>
<div { ...innerBlockProps } />
</SectionTagName>
);
}

View File

@ -1,29 +1,61 @@
.wp-block-woocommerce-product-section {
margin-bottom: 48px;
padding-top: 48px;
margin: calc(3 * $gap) 0 0;
padding: 0 0 calc(3 * $gap);
border-bottom: 1px solid #ddd;
&:first-child {
padding-top: 64px;
margin-top: calc(4 * $gap);
}
.wp-block-woocommerce-product-section__title {
margin-top: 0;
margin-bottom: 0;
font-size: 20px;
font-weight: 500;
color: $gray-900;
display: inline-flex;
align-items: center;
}
&:last-child {
border-bottom: none;
}
&__description {
margin-top: $gap-small;
font-size: 13px;
color: $gray-700;
line-height: 1.5;
}
}
&__heading {
padding: 0;
margin: 0 0 calc(2 * $gap) 0;
width: 100%;
.wp-block-woocommerce-product-section + .wp-block-woocommerce-product-section {
border-top: 1px solid #ddd;
.wp-block-woocommerce-product-section__heading-title {
margin: 0;
font-size: 20px;
font-weight: 500;
color: $gray-900;
display: inline-flex;
align-items: center;
.block-editor-block-icon {
margin-right: 14px;
> div {
display: flex;
align-items: center;
justify-content: center;
}
}
}
.wp-block-woocommerce-product-section__heading-description {
margin: $gap-small 0 0;
font-size: 13px;
color: $gray-700;
line-height: 1.5;
}
}
&__content {
&--block-gap-unit-30 > * + * {
margin-top: $grid-unit-30;
}
&--block-gap-unit-40 > * + * {
margin-top: $grid-unit-40;
}
.wp-block-woocommerce-product-section {
margin-top: 0;
padding-bottom: 0;
border-bottom: none;
}
}
}

View File

@ -4,6 +4,7 @@
import { BlockAttributes } from '@wordpress/blocks';
export interface SectionBlockAttributes extends BlockAttributes {
title: string;
description: string;
title?: string;
description?: string;
blockGap: 'lg' | '2xlg';
}

View File

@ -11,7 +11,7 @@
label,
div,
input {
font-family: var( --wp--preset--font-family--system-font );
font-family: var(--wp--preset--font-family--system-font);
}
label {
@ -36,15 +36,52 @@
}
}
.editor-styles-wrapper {
max-width: 650px;
margin-left: auto;
margin-right: auto;
padding-bottom: 128px;
.components-base-control {
.components-base-control__field {
margin-bottom: 0;
}
.components-base-control__help {
margin-bottom: 0;
}
}
.components-toggle-control {
margin-bottom: 0;
.components-form-toggle {
display: flex;
align-items: center;
}
.components-toggle-control__label {
display: flex;
align-items: center;
}
}
.woocommerce-collapsible-content .woocommerce-collapsible-content__content {
margin-top: calc(2 * $gap);
}
.editor-styles-wrapper {
h4 {
font-size: 16px;
}
.block-editor-block-list__layout.is-root-container {
padding-left: calc(2 * $gap);
padding-right: calc(2 * $gap);
padding-bottom: 128px;
@include breakpoint(">782px") {
padding-left: 0;
padding-right: 0;
max-width: 650px;
margin-left: auto;
margin-right: auto;
}
}
}
.components-input-control {
@ -82,18 +119,6 @@
margin-bottom: 0;
}
.wp-block-woocommerce-product-section {
> .block-editor-inner-blocks > .block-editor-block-list__layout {
> .wp-block:first-child {
margin-top: 32px;
}
> .wp-block:not( :first-child ) {
margin-top: $gap-large;
}
}
}
.woocommerce-experimental-select-control__label {
text-transform: uppercase;
font-size: 11px;
@ -101,7 +126,28 @@
font-weight: 500;
}
.block-editor-block-list__layout .block-editor-block-list__block:not( [contenteditable] ):focus:after {
.block-editor-block-list__layout
.block-editor-block-list__block:not([contenteditable]):focus:after {
display: none; // use important or increase specificity.
}
}
.woocommerce-layout:has(.woocommerce-product-block-editor) {
.woocommerce-layout__primary {
margin-top: calc($gap-largest + $gap-smaller);
}
.woocommerce-layout__header {
display: none;
}
}
.wp-admin.woocommerce-feature-enabled-product-block-editor {
.components-modal {
&__frame {
border-radius: $gap-smaller;
}
&__header {
border: none;
}
}
}

View File

@ -1,5 +1,5 @@
.woocommerce-product-link-edit-modal {
min-width: 650px;
max-width: 650px;
&__buttons {
margin-top: $gap-larger;
@ -9,11 +9,8 @@
justify-content: flex-end;
}
.components-modal__header {
border-color: $gray-300;
}
.woocommerce-product-link-edit-modal__description {
margin: $gap-large 0;
margin-top: 0;
margin-bottom: $gap-large;
}
}

View File

@ -54,7 +54,7 @@ export function usePublish( {
const isBusy = isSaving || isValidating;
const isCreating = productStatus === 'auto-draft';
const isPublished = productStatus === 'publish';
const { editEntityRecord, saveEditedEntityRecord } = useDispatch( 'core' );
@ -95,9 +95,9 @@ export function usePublish( {
}
return {
children: isCreating
? __( 'Add', 'woocommerce' )
: __( 'Save', 'woocommerce' ),
children: isPublished
? __( 'Update', 'woocommerce' )
: __( 'Add', 'woocommerce' ),
...props,
isBusy,
variant: 'primary',

View File

@ -26,7 +26,7 @@ export function PublishButton(
'status'
);
const isCreating = productStatus === 'auto-draft';
const isPublished = productStatus === 'publish';
const { createSuccessNotice, createErrorNotice } =
useDispatch( 'core/notices' );
@ -36,9 +36,9 @@ export function PublishButton(
onPublishSuccess( savedProduct: Product ) {
recordProductEvent( 'product_update', savedProduct );
const noticeContent = isCreating
? __( 'Product successfully created.', 'woocommerce' )
: __( 'Product published.', 'woocommerce' );
const noticeContent = isPublished
? __( 'Product published.', 'woocommerce' )
: __( 'Product successfully created.', 'woocommerce' );
const noticeOptions = {
icon: '🎉',
actions: [
@ -64,9 +64,9 @@ export function PublishButton(
}
},
onPublishError( error ) {
const defaultMessage = isCreating
? __( 'Failed to create product.', 'woocommerce' )
: __( 'Failed to publish product.', 'woocommerce' );
const defaultMessage = isPublished
? __( 'Failed to publish product.', 'woocommerce' )
: __( 'Failed to create product.', 'woocommerce' );
const message = getProductErrorMessage( error );
createErrorNotice( message || defaultMessage );

View File

@ -36,7 +36,7 @@
display: flex;
> * + * {
margin-left: $gap;
margin-left: $gap-smaller;
}
}

View File

@ -4,8 +4,8 @@
.components-button {
padding: $gap-smaller 0 20px 0;
margin-left: $gap;
margin-right: $gap;
margin-left: $gap-small;
margin-right: $gap-small;
border-bottom: 3.5px solid transparent;
border-radius: 0;
height: auto;

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix block grouping within a section

View File

@ -368,46 +368,53 @@ class Init {
'<a href="https://woocommerce.com/posts/how-to-price-products-strategies-expert-tips/" target="_blank" rel="noreferrer">',
'</a>'
),
'blockGap' => 'unit-40',
),
array(
array(
'core/columns',
'woocommerce/product-section',
array(),
array(
array(
'core/column',
array(
'templateLock' => 'all',
),
'core/columns',
array(),
array(
array(
'woocommerce/product-regular-price-field',
'core/column',
array(
'name' => 'regular_price',
'label' => __( 'List price', 'woocommerce' ),
'templateLock' => 'all',
),
array(
array(
'woocommerce/product-regular-price-field',
array(
'name' => 'regular_price',
'label' => __( 'List price', 'woocommerce' ),
),
),
),
),
array(
'core/column',
array(
'templateLock' => 'all',
),
array(
array(
'woocommerce/product-sale-price-field',
array(
'label' => __( 'Sale price', 'woocommerce' ),
),
),
),
),
),
),
array(
'core/column',
array(
'templateLock' => 'all',
),
array(
array(
'woocommerce/product-sale-price-field',
array(
'label' => __( 'Sale price', 'woocommerce' ),
),
),
),
'woocommerce/product-schedule-sale-fields',
),
),
),
array(
'woocommerce/product-schedule-sale-fields',
),
array(
'woocommerce/product-radio-field',
array(
@ -488,29 +495,36 @@ class Init {
'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=products&section=inventory' ) . '" target="_blank" rel="noreferrer">',
'</a>'
),
'blockGap' => 'unit-40',
),
array(
array(
'woocommerce/product-sku-field',
),
array(
'woocommerce/product-toggle-field',
array(
'label' => __( 'Track stock quantity for this product', 'woocommerce' ),
'property' => 'manage_stock',
'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
),
),
array(
'woocommerce/conditional',
array(
'mustMatch' => array(
'manage_stock' => array( true ),
),
),
'woocommerce/product-section',
array(),
array(
array(
'woocommerce/product-inventory-quantity-field',
'woocommerce/product-sku-field',
),
array(
'woocommerce/product-toggle-field',
array(
'label' => __( 'Track stock quantity for this product', 'woocommerce' ),
'property' => 'manage_stock',
'disabled' => 'yes' !== get_option( 'woocommerce_manage_stock' ),
),
),
array(
'woocommerce/conditional',
array(
'mustMatch' => array(
'manage_stock' => array( true ),
),
),
array(
array(
'woocommerce/product-inventory-quantity-field',
),
),
),
),
),
@ -554,61 +568,69 @@ class Init {
),
array(
array(
'woocommerce/conditional',
'woocommerce/product-section',
array(
'mustMatch' => array(
'manage_stock' => array( true ),
),
'blockGap' => 'unit-40',
),
array(
array(
'woocommerce/product-radio-field',
'woocommerce/conditional',
array(
'title' => __( 'When out of stock', 'woocommerce' ),
'property' => 'backorders',
'options' => array(
'mustMatch' => array(
'manage_stock' => array( true ),
),
),
array(
array(
'woocommerce/product-radio-field',
array(
'label' => __( 'Allow purchases', 'woocommerce' ),
'value' => 'yes',
),
array(
'label' => __(
'Allow purchases, but notify customers',
'woocommerce'
'title' => __( 'When out of stock', 'woocommerce' ),
'property' => 'backorders',
'options' => array(
array(
'label' => __( 'Allow purchases', 'woocommerce' ),
'value' => 'yes',
),
array(
'label' => __(
'Allow purchases, but notify customers',
'woocommerce'
),
'value' => 'notify',
),
array(
'label' => __( "Don't allow purchases", 'woocommerce' ),
'value' => 'no',
),
),
'value' => 'notify',
),
array(
'label' => __( "Don't allow purchases", 'woocommerce' ),
'value' => 'no',
),
),
array(
'woocommerce/product-inventory-email-field',
),
),
),
array(
'woocommerce/product-inventory-email-field',
'woocommerce/product-checkbox-field',
array(
'title' => __(
'Restrictions',
'woocommerce'
),
'label' => __(
'Limit purchases to 1 item per order',
'woocommerce'
),
'property' => 'sold_individually',
'tooltip' => __(
'When checked, customers will be able to purchase only 1 item in a single order. This is particularly useful for items that have limited quantity, like art or handmade goods.',
'woocommerce'
),
),
),
),
),
array(
'woocommerce/product-checkbox-field',
array(
'title' => __(
'Restrictions',
'woocommerce'
),
'label' => __(
'Limit purchases to 1 item per order',
'woocommerce'
),
'property' => 'sold_individually',
'tooltip' => __(
'When checked, customers will be able to purchase only 1 item in a single order. This is particularly useful for items that have limited quantity, like art or handmade goods.',
'woocommerce'
),
),
),
),
),
),
),