Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header to the quick edit when bulk editing #67390

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
57 changes: 34 additions & 23 deletions packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
@mixin heading-small() {
@include _text-heading();
font-size: $font-size-x-small;
line-height: $line-height-x-small;
line-height: $font-line-height--x-small;
}

@mixin heading-medium() {
@include _text-heading();
font-size: $font-size-medium;
line-height: $line-height-small;
line-height: $font-line-height-small;
}

@mixin heading-large() {
@include _text-heading();
font-size: $font-size-large;
line-height: $line-height-small;
line-height: $font-line-height-small;
}

@mixin heading-x-large() {
@include _text-heading();
font-size: $font-size-x-large;
line-height: $line-height-medium;
line-height: $font-line-height-medium;
}

@mixin heading-2x-large() {
Expand All @@ -48,25 +48,25 @@
@mixin body-small() {
@include _text-body();
font-size: $font-size-small;
line-height: $line-height-x-small;
line-height: $font-line-height-x-small;
}

@mixin body-medium() {
@include _text-body();
font-size: $font-size-medium;
line-height: $line-height-small;
line-height: $font-line-height-small;
}

@mixin body-large() {
@include _text-body();
font-size: $font-size-large;
line-height: $line-height-medium;
line-height: $font-line-height-medium;
}

@mixin body-x-large() {
@include _text-body();
font-size: $font-size-x-large;
line-height: $line-height-x-large;
line-height: $font-line-height-x-large;
}

/**
Expand Down Expand Up @@ -178,15 +178,18 @@
*/

@mixin editor-left($selector) {
#{$selector} { /* Set left position when auto-fold is not on the body element. */
#{$selector} {
/* Set left position when auto-fold is not on the body element. */
left: 0;

@media (min-width: #{ ($break-medium + 1) }) {
left: $admin-sidebar-width;
}
}

.auto-fold #{$selector} { /* Auto fold is when on smaller breakpoints, nav menu auto collapses. */
.auto-fold #{$selector} {

/* Auto fold is when on smaller breakpoints, nav menu auto collapses. */
@media (min-width: #{ ($break-medium + 1) }) {
left: $admin-sidebar-width-collapsed;
}
Expand Down Expand Up @@ -236,12 +239,12 @@

@mixin reduce-motion($property: "") {

@if $property == "transition" {
@if $property =="transition" {
@media (prefers-reduced-motion: reduce) {
transition-duration: 0s;
transition-delay: 0s;
}
} @else if $property == "animation" {
} @else if $property =="animation" {
@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms;
animation-delay: 0s;
Expand All @@ -265,6 +268,7 @@
font-size: $mobile-text-min-font-size;
/* Override core line-height. To be reviewed. */
line-height: normal;

@include break-small {
font-size: $default-font-size;
/* Override core line-height. To be reviewed. */
Expand Down Expand Up @@ -447,6 +451,7 @@

// Fonts smaller than 16px causes mobile safari to zoom.
font-size: $mobile-text-min-font-size !important;

@include break-small {
font-size: $default-font-size !important;
}
Expand All @@ -464,7 +469,7 @@
* Reset the WP Admin page styles for Gutenberg-like pages.
*/

@mixin wp-admin-reset( $content-container ) {
@mixin wp-admin-reset($content-container ) {
background: $white;

#wpcontent {
Expand Down Expand Up @@ -515,7 +520,8 @@
// Focus style width.
// Avoid rounding issues by showing a whole 2px for 1x screens, and 1.5px on high resolution screens.
--wp-admin-border-width-focus: 2px;
@media ( -webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
--wp-admin-border-width-focus: 1.5px;
}
}
Expand Down Expand Up @@ -582,32 +588,33 @@

/* stylelint-disable @stylistic/function-comma-space-after -- We can not use spacing because of WP multi site kses rule. */
.has-vivid-green-cyan-to-vivid-cyan-blue-gradient-background {
background: linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%);
background: linear-gradient(135deg, rgba(0, 208, 132, 1) 0%, rgba(6, 147, 227, 1) 100%);
}

.has-purple-crush-gradient-background {
background: linear-gradient(135deg,rgb(52,226,228) 0%,rgb(71,33,251) 50%,rgb(171,29,254) 100%);
background: linear-gradient(135deg, rgb(52, 226, 228) 0%, rgb(71, 33, 251) 50%, rgb(171, 29, 254) 100%);
}

.has-hazy-dawn-gradient-background {
background: linear-gradient(135deg,rgb(250,172,168) 0%,rgb(218,208,236) 100%);
background: linear-gradient(135deg, rgb(250, 172, 168) 0%, rgb(218, 208, 236) 100%);
}

.has-subdued-olive-gradient-background {
background: linear-gradient(135deg,rgb(250,250,225) 0%,rgb(103,166,113) 100%);
background: linear-gradient(135deg, rgb(250, 250, 225) 0%, rgb(103, 166, 113) 100%);
}

.has-atomic-cream-gradient-background {
background: linear-gradient(135deg,rgb(253,215,154) 0%,rgb(0,74,89) 100%);
background: linear-gradient(135deg, rgb(253, 215, 154) 0%, rgb(0, 74, 89) 100%);
}

.has-nightshade-gradient-background {
background: linear-gradient(135deg,rgb(51,9,104) 0%,rgb(49,205,207) 100%);
background: linear-gradient(135deg, rgb(51, 9, 104) 0%, rgb(49, 205, 207) 100%);
}

.has-midnight-gradient-background {
background: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);
background: linear-gradient(135deg, rgb(2, 3, 129) 0%, rgb(40, 116, 252) 100%);
}

/* stylelint-enable @stylistic/function-comma-space-after */
}

Expand All @@ -618,16 +625,20 @@
width: 12px;
height: 12px;
}

&::-webkit-scrollbar-track {
background-color: transparent;
}

&::-webkit-scrollbar-thumb {
background-color: $handle-color;
border-radius: 8px;
border: 3px solid transparent;
background-clip: padding-box;
}
&:hover::-webkit-scrollbar-thumb, // This needs specificity.

&:hover::-webkit-scrollbar-thumb,
// This needs specificity.
&:focus::-webkit-scrollbar-thumb,
&:focus-within::-webkit-scrollbar-thumb {
background-color: $handle-color-hover;
Expand Down Expand Up @@ -659,7 +670,7 @@
outline-color: var(--wp-admin-theme-color);
outline-style: solid;
outline-width: calc(#{$widthRatio} * (var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1)));
outline-offset: calc(#{$widthRatio} * ((-1 * var(--wp-admin-border-width-focus) ) / var(--wp-block-editor-iframe-zoom-out-scale, 1)));
outline-offset: calc(#{$widthRatio} * ((-1 * var(--wp-admin-border-width-focus)) / var(--wp-block-editor-iframe-zoom-out-scale, 1)));
}

@mixin selected-block-focus($widthRatio: 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these random CSS changes related to this PR?

Expand Down
83 changes: 83 additions & 0 deletions packages/edit-site/src/components/post-edit/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* WordPress dependencies
*/
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Icon,
__experimentalText as Text,
} from '@wordpress/components';
import { useMemo } from '@wordpress/element';
import {
privateApis as editorPrivateApis,
store as editorStore,
} from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { sprintf, __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { unlock } from '../../lock-unlock';

const { PostCardPanel } = unlock( editorPrivateApis );

export default function PostEditHeader( { postType, postId } ) {
const ids = useMemo( () => postId.split( ',' ), [ postId ] );
const { icon, labels } = useSelect(
( select ) => {
const { getEditedEntityRecord, getPostType } = select( coreStore );
const { getPostIcon } = unlock( select( editorStore ) );
const _record = getEditedEntityRecord(
'postType',
postType,
ids[ 0 ]
);

return {
icon: getPostIcon( postType, {
area: _record?.area,
} ),
labels: getPostType( postType )?.labels,
};
},
[ ids, postType ]
);

if ( ids.length === 1 ) {
return <PostCardPanel postType={ postType } postId={ ids[ 0 ] } />;
}

return (
<VStack spacing={ 1 } className="edit-site-post-edit-header">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of me wonders if PostCardPanel should support multiple posts (as this seems to recreate a similar UI)

<HStack spacing={ 2 } align="center" justify="normal">
<Icon
className="edit-site-post-edit-header__icon"
icon={ icon }
/>
<Text
numberOfLines={ 2 }
truncate
className="edit-site-post-edit-header__title"
as="h2"
>
{ labels?.name &&
sprintf(
// translators: %i number of selected items %s: Name of the plural post type e.g: "Posts".
__( '%i %s' ),
ids.length,
labels?.name
) }
</Text>
</HStack>
<Text className="edit-site-post-edit-header__description">
{ sprintf(
// translators: %s: Name of the plural post type e.g: "Posts".
__( 'Changes will be applied to all selected %s.' ),
labels?.name.toLowerCase()
) }
</Text>
</VStack>
);
}
7 changes: 3 additions & 4 deletions packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
* Internal dependencies
*/
import Page from '../page';
import PostEditHeader from '../post-edit/header';
import { unlock } from '../../lock-unlock';

const { PostCardPanel, usePostFields } = unlock( editorPrivateApis );
const { usePostFields } = unlock( editorPrivateApis );

const fieldsWithBulkEditSupport = [
'title',
Expand Down Expand Up @@ -125,9 +126,7 @@ function PostEditForm( { postType, postId } ) {

return (
<VStack spacing={ 4 }>
{ ids.length === 1 && (
<PostCardPanel postType={ postType } postId={ ids[ 0 ] } />
) }
<PostEditHeader postType={ postType } postId={ postId } />
<DataForm
data={ ids.length === 1 ? record : multiEdits }
fields={ fields }
Expand Down
10 changes: 10 additions & 0 deletions packages/edit-site/src/components/post-edit/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@
padding-top: $grid-unit-20;
}
}

.edit-site-post-edit-header {
.edit-site-post-edit-header__description {
color: $gray-700;
}

.edit-site-post-edit-header__title {
@include heading-medium();
}
}
1 change: 1 addition & 0 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
mix-blend-mode: normal;
display: block;
}

/* stylelint-enable */

body.js #wpadminbar {
Expand Down
Loading