Skip to content

Commit

Permalink
Merge branch 'trunk' into combobox-40px
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka authored Aug 16, 2024
2 parents 42deaf2 + 78722b9 commit 563439d
Show file tree
Hide file tree
Showing 56 changed files with 426 additions and 185 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ module.exports = {
'BorderBoxControl',
'BorderControl',
'ComboboxControl',
'CustomSelectControl',
'DimensionControl',
'FontSizePicker',
'NumberControl',
'ToggleGroupControl',
].map( ( componentName ) => ( {
// Falsy `__next40pxDefaultSize` without a non-default `size` prop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Dynamic blocks, which we'll explore in the following section, can specify an ini
For a practical demonstration of how this works, refer to the [Building your first block](/docs/getting-started/tutorial.md) tutorial. Specifically, the [Adding static rendering](/docs/getting-started/tutorial.md#adding-static-rendering) section illustrates how a block can have both a saved HTML structure and dynamic rendering capabilities.

<div class="callout callout-info">
WordPress provides mechanisms like the <a href="https://developer.wordpress.org/reference/functions/render_block/"><code>render_block</code></a> are the <code>$render_callback</code> function to alter the saved HTML of a block before it appears on the front end. These tools offer developers the capability to customize block output dynamically, catering to complex and interactive user experiences.
WordPress provides mechanisms like the <a href="https://developer.wordpress.org/reference/functions/render_block/"><code>render_block</code></a> and the <a href="https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/creating-dynamic-blocks/"><code>render_callback</code></a> function to alter the saved HTML of a block before it appears on the front end. These tools offer developers the capability to customize block output dynamically, catering to complex and interactive user experiences.
</div>

Additional examples of WordPress blocks that use static rendering, meaning their output is fixed at the time of saving and doesn't rely on server-side processing, include:
Expand Down
3 changes: 3 additions & 0 deletions packages/base-styles/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ $light-gray-placeholder: rgba($white, 0.65);
$alert-yellow: #f0b849;
$alert-red: #cc1818;
$alert-green: #4ab866;

// Deprecated, please avoid using these.
$dark-theme-focus: $white; // Focus color when the theme is dark.
2 changes: 1 addition & 1 deletion packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $radius-x-small: 1px; // Applied to elements like buttons nested within primit
$radius-small: 2px; // Applied to most primitives.
$radius-medium: 4px; // Applied to containers with smaller padding.
$radius-large: 8px; // Applied to containers with larger padding.
$radius-full: 9999px; // For lozenges.
$radius-full: 9999px; // For pills.
$radius-round: 50%; // For circles and ovals.

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function NonDefaultControls( { format, onChange } ) {
return (
<VStack>
<CustomSelectControl
__next40pxDefaultSize
label={ __( 'Choose a format' ) }
options={ [ ...suggestedOptions, customOption ] }
value={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const getFontAppearanceLabel = ( hasFontStyles, hasFontWeights ) => {
*/
export default function FontAppearanceControl( props ) {
const {
/** Start opting into the larger default height that will become the default size in a future version. */
__next40pxDefaultSize = false,
onChange,
hasFontStyles = true,
hasFontWeights = true,
Expand Down Expand Up @@ -150,6 +152,7 @@ export default function FontAppearanceControl( props ) {
<CustomSelectControl
{ ...otherProps }
className="components-font-appearance-control"
__next40pxDefaultSize={ __next40pxDefaultSize }
label={ label }
describedBy={ getDescribedBy() }
options={ selectOptions }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
__experimentalHStack as HStack,
__experimentalTruncate as Truncate,
Dropdown,
Placeholder,
Spinner,
__experimentalDropdownContentWrapper as DropdownContentWrapper,
} from '@wordpress/components';
import { __, _x, sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -268,6 +270,14 @@ function BackgroundControlsPanel( {
);
}

function LoadingSpinner() {
return (
<Placeholder className="block-editor-global-styles-background-panel__loading">
<Spinner />
</Placeholder>
);
}

function BackgroundImageControls( {
onChange,
style,
Expand All @@ -277,10 +287,8 @@ function BackgroundImageControls( {
displayInPanel,
defaultValues,
} ) {
const mediaUpload = useSelect(
( select ) => select( blockEditorStore ).getSettings().mediaUpload,
[]
);
const [ isUploading, setIsUploading ] = useState( false );
const { getSettings } = useSelect( blockEditorStore );

const { id, title, url } = style?.background?.backgroundImage || {
...inheritedValue?.background?.backgroundImage,
Expand All @@ -289,6 +297,7 @@ function BackgroundImageControls( {
const { createErrorNotice } = useDispatch( noticesStore );
const onUploadError = ( message ) => {
createErrorNotice( message, { type: 'snackbar' } );
setIsUploading( false );
};

const resetBackgroundImage = () =>
Expand All @@ -303,10 +312,12 @@ function BackgroundImageControls( {
const onSelectMedia = ( media ) => {
if ( ! media || ! media.url ) {
resetBackgroundImage();
setIsUploading( false );
return;
}

if ( isBlobURL( media.url ) ) {
setIsUploading( true );
return;
}

Expand Down Expand Up @@ -349,16 +360,21 @@ function BackgroundImageControls( {
backgroundSize: sizeValue,
} )
);
setIsUploading( false );
};

// Drag and drop callback, restricting image to one.
const onFilesDrop = ( filesList ) => {
mediaUpload( {
if ( filesList?.length > 1 ) {
onUploadError(
__( 'Only one image can be used as a background image.' )
);
return;
}
getSettings().mediaUpload( {
allowedTypes: [ IMAGE_BACKGROUND_TYPE ],
filesList,
onFileChange( [ image ] ) {
if ( isBlobURL( image?.url ) ) {
return;
}
onSelectMedia( image );
},
onError: onUploadError,
Expand Down Expand Up @@ -393,6 +409,7 @@ function BackgroundImageControls( {
ref={ replaceContainerRef }
className="block-editor-global-styles-background-panel__image-tools-panel-item"
>
{ isUploading && <LoadingSpinner /> }
<MediaReplaceFlow
mediaId={ id }
mediaURL={ url }
Expand All @@ -414,6 +431,7 @@ function BackgroundImageControls( {
/>
}
variant="secondary"
onError={ onUploadError }
>
{ canRemove && (
<MenuItem
Expand Down
11 changes: 11 additions & 0 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
}
}

.block-editor-global-styles-background-panel__loading {
height: 100%;
position: absolute;
z-index: 1;
width: 100%;
padding: 10px 0 0 0;
svg {
margin: 0;
}
}
}

.block-editor-global-styles-background-panel__image-preview-content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ The value of the line height.

A callback function that handles the application of the line height value.

#### `__next40pxDefaultSize`

- **Type:** `boolean`
- **Default:** `false`

Start opting into the larger default height that will become the default size in a future version.

## Related components

Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
} from './utils';

const LineHeightControl = ( {
/** Start opting into the larger default height that will become the default size in a future version. */
__next40pxDefaultSize = false,
value: lineHeight,
onChange,
__unstableInputWidth = '60px',
Expand Down Expand Up @@ -91,6 +93,7 @@ const LineHeightControl = ( {
<div className="block-editor-line-height-control">
<NumberControl
{ ...otherProps }
__next40pxDefaultSize={ __next40pxDefaultSize }
__unstableInputWidth={ __unstableInputWidth }
__unstableStateReducer={ stateReducer }
onChange={ handleOnChange }
Expand Down
15 changes: 14 additions & 1 deletion packages/block-library/src/comment-author-name/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
},
"interactivity": {
"clientNavigation": true
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true,
"__experimentalDefaultControls": {
"radius": true,
"color": true,
"width": true,
"style": true
}
}
}
},
"style": "wp-block-comment-author-name"
}
4 changes: 4 additions & 0 deletions packages/block-library/src/comment-author-name/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wp-block-comment-author-name {
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
}
1 change: 1 addition & 0 deletions packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@import "./comment-template/style.scss";
@import "./comment-date/style.scss";
@import "./comment-content/style.scss";
@import "./comment-author-name/style.scss";
@import "./cover/style.scss";
@import "./details/style.scss";
@import "./embed/style.scss";
Expand Down
27 changes: 27 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- `ToggleControl`
- `ToggleGroupControl`
- `TreeSelect`
- Deprecate `NavigatorToParentButton` and `useNavigator().goToParent()` in favor of `NavigatorBackButton` and `useNavigator().goBack()` ([#63317](https://github.com/WordPress/gutenberg/pull/63317)).

### Enhancements

Expand All @@ -27,6 +28,32 @@
- `TimePicker`: add `hideLabelFromVision` prop ([#64267](https://github.com/WordPress/gutenberg/pull/64267)).
- `FocalPointPicker`: Default to new 40px size ([#64456](https://github.com/WordPress/gutenberg/pull/64456)).
- `DropdownMenuV2`: adopt elevation scale ([#64432](https://github.com/WordPress/gutenberg/pull/64432)).
- `AlignmentMatrixControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `AnglePickerControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `BorderControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ButtonGroup`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Button`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `CircularOptionPicker`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ColorIndicator`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ColorPalette`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `CustomGradientPicker`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `DropZone`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `DropdownMenuV2`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `FocalPointPicker`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Guide`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Modal`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Placeholder`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Popover`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ProgressBar`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `RadioControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Snackbar`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `TabPanel`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Text`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ToggleGroupControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `ToolbarGroup`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Toolbar`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Tooltip`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `UnitControl`: Adopt radius scale ([#64368](https://github.com/WordPress/gutenberg/pull/64368)).
- `Popover`: allow `style` prop usage ([#64489](https://github.com/WordPress/gutenberg/pull/64489)).
- `ToolsPanel`: sets column-gap to 16px for ToolsPanel grid ([#64497](https://github.com/WordPress/gutenberg/pull/64497)).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { css } from '@emotion/react';
/**
* Internal dependencies
*/
import { COLORS } from '../../utils';
import { COLORS, CONFIG } from '../../utils';
import type {
AlignmentMatrixControlProps,
AlignmentMatrixControlCellProps,
} from '../types';

export const rootBase = () => {
return css`
border-radius: 2px;
border-radius: ${ CONFIG.radiusMedium };
box-sizing: border-box;
direction: ltr;
display: grid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CIRCLE_SIZE = 32;
const INNER_CIRCLE_SIZE = 6;

export const CircleRoot = styled.div`
border-radius: 50%;
border-radius: ${ CONFIG.radiusRound };
border: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };
box-sizing: border-box;
cursor: grab;
Expand All @@ -41,7 +41,7 @@ export const CircleIndicatorWrapper = styled.div`

export const CircleIndicator = styled.div`
background: ${ COLORS.theme.accent };
border-radius: 50%;
border-radius: ${ CONFIG.radiusRound };
box-sizing: border-box;
display: block;
left: 50%;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/border-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const colorIndicatorWrapper = (
const { style } = border || {};

return css`
border-radius: 9999px;
border-radius: ${ CONFIG.radiusFull };
border: 2px solid transparent;
${ style ? colorIndicatorBorder( border ) : undefined }
width: ${ size === '__unstable-large' ? '24px' : '22px' };
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/button-group/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
}

&:first-child {
border-radius: $radius-block-ui 0 0 $radius-block-ui;
border-radius: $radius-small 0 0 $radius-small;
}

&:last-child {
border-radius: 0 $radius-block-ui $radius-block-ui 0;
border-radius: 0 $radius-small $radius-small 0;
}

// The focused button should be elevated so the focus ring isn't cropped,
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
align-items: center;
box-sizing: border-box;
padding: 6px 12px;
border-radius: $radius-block-ui;
border-radius: $radius-small;
color: $components-color-foreground;

&.is-next-40px-default-size {
Expand Down Expand Up @@ -249,7 +249,7 @@
height: auto;

&:focus {
border-radius: $radius-block-ui;
border-radius: $radius-small;
}

&:disabled,
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/circular-option-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $color-palette-circle-spacing: 12px;
height: 100%;
width: 100%;
border: none;
border-radius: 50%;
border-radius: $radius-round;
background: transparent;
box-shadow: inset 0 0 0 ($color-palette-circle-size * 0.5);
transition: 100ms box-shadow ease;
Expand All @@ -93,7 +93,7 @@ $color-palette-circle-spacing: 12px;
position: absolute;
left: 2px;
top: 2px;
border-radius: 50%;
border-radius: $radius-round;
z-index: z-index(".components-circular-option-picker__option.is-pressed + svg");
pointer-events: none;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-indicator/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
width: $grid-unit-50 * 0.5;
height: $grid-unit-50 * 0.5;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
border-radius: 50%;
border-radius: $radius-round;
display: inline-block;
padding: 0;
background: $white linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
Expand Down
Loading

0 comments on commit 563439d

Please sign in to comment.