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

PCH Redesign: Use Suffix and Prefix wrappers and size prop #2278

Merged
merged 1 commit into from
Mar 11, 2024
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
2 changes: 1 addition & 1 deletion build/content-helper/editor-sidebar.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '1013e223b437772e186b');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'a727f0bb3d0187a297dd');
6 changes: 3 additions & 3 deletions build/content-helper/editor-sidebar.css

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions build/content-helper/editor-sidebar.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {
__experimentalHeading as Heading,
__experimentalNumberControl as NumberControl,
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
RangeControl,
} from '@wordpress/components';

Expand All @@ -22,6 +23,7 @@ type InputRangeProps = {
initialPosition: number;
disabled: boolean;
className?: string;
size?: 'small' | 'default' | 'compact' | '__unstable-large',
};

/**
Expand All @@ -38,6 +40,7 @@ export const InputRange = ( {
max,
min,
suffix,
size,
label,
initialPosition,
disabled,
Expand All @@ -50,7 +53,8 @@ export const InputRange = ( {
<NumberControl
disabled={ disabled }
value={ value }
suffix={ suffix }
suffix={ <InputControlSuffixWrapper>{ suffix }</InputControlSuffixWrapper> }
size={ size ?? '__unstable-large' }
min={ min }
max={ max }
onChange={ ( newValue ) => {
Expand Down
13 changes: 0 additions & 13 deletions src/content-helper/common/components/input-range/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@

.components-input-control {
display: flex;
align-items: center;
gap: var(--grid-unit-05, to_rem(4px));
flex: 1 0 0;
align-self: stretch;


/* For Chrome, Safari, Edge */
input[type="number"]::-webkit-inner-spin-button,
Expand All @@ -41,18 +37,9 @@

.components-base-control__field {
flex-grow: 1;

.components-flex {
height: to_rem(40px);
}

input[type="number"] {
padding-left: to_rem(16px);
}
}

.components-input-control__suffix {
padding-right: to_rem(10px);
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/**
* WordPress dependencies
*/
import { Button, MenuGroup, MenuItem, SelectControl } from '@wordpress/components';
import {
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
Button,
MenuGroup,
MenuItem,
SelectControl,
} from '@wordpress/components';
import { useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import {
Expand Down Expand Up @@ -241,8 +247,13 @@ export const PerformanceStats = (
>
<div className="panel-settings">
<SelectControl
size="__unstable-large"
value={ settings.PerformanceStatsSettings.Period }
prefix={ __( 'Period: ', 'wp-parsely' ) }
prefix={
<InputControlPrefixWrapper>
{ __( 'Period: ', 'wp-parsely' ) }
</InputControlPrefixWrapper>
}
onChange={ ( selection ) => {
if ( isInEnum( selection, Period ) ) {
setSettings( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,6 @@
}
}

.panel-settings {

.components-select-control {
display: flex;
align-items: flex-start;
gap: to_rem(16px);
align-self: stretch;
}

.components-input-control__prefix {
margin-left: to_rem(8px);
}

.components-input-control {
display: flex;
height: to_rem(36px);
padding: var(--grid-unit-15, 12px) var(--grid-unit-10, 8px) var(--grid-unit-15, 12px) var(--grid-unit-20, 16px);
align-items: center;
gap: var(--grid-unit-05, 4px);
align-self: stretch;
}
}

.components-heading {
margin: 0;
font-weight: 500;
Expand Down
15 changes: 12 additions & 3 deletions src/content-helper/editor-sidebar/related-posts/component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';
import {
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
SelectControl,
} from '@wordpress/components';
import { useDebounce } from '@wordpress/compose';
// eslint-disable-next-line import/named
import { store as coreStore, Taxonomy, User } from '@wordpress/core-data';
Expand Down Expand Up @@ -340,8 +343,11 @@ export const RelatedPostsPanel = (): JSX.Element => {
<div className="related-posts-body">
<div className="related-posts-settings">
<SelectControl
size="__unstable-large"
onChange={ ( value ) => onMetricChange( value ) }
prefix={ __( 'Metric: ', 'wp-parsely' ) }
prefix={
<InputControlPrefixWrapper>{ __( 'Metric: ', 'wp-parsely' ) }</InputControlPrefixWrapper>
}
value={ metric }
>
{ Object.values( Metric ).map( ( value ) => (
Expand All @@ -351,8 +357,11 @@ export const RelatedPostsPanel = (): JSX.Element => {
) ) }
</SelectControl>
<SelectControl
size="__unstable-large"
value={ period }
prefix={ __( 'Period: ', 'wp-parsely' ) }
prefix={
<InputControlPrefixWrapper>{ __( 'Period: ', 'wp-parsely' ) } </InputControlPrefixWrapper>
}
onChange={ ( selection ) => onPeriodChange( selection ) }
>
{ Object.values( Period ).map( ( value ) => (
Expand Down
23 changes: 0 additions & 23 deletions src/content-helper/editor-sidebar/related-posts/related-posts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,7 @@
margin-bottom: 0;
}

.components-select-control {
display: flex;
align-items: flex-start;
gap: to_rem(16px);
align-self: stretch;
height: to_rem(36px);

.components-input-control__container {
padding: to_rem(3px);
}
}

.components-input-control__prefix {
margin-left: to_rem(8px);
}

.components-input-control {
display: flex;
height: to_rem(36px);
padding: var(--grid-unit-15, to_rem(12px)) var(--grid-unit-10, to_rem(8px)) var(--grid-unit-15, to_rem(12px)) var(--grid-unit-20, to_rem(16px));
align-items: center;
gap: var(--grid-unit-5, to_rem(4px));
align-self: stretch;
}
}

.related-posts-filter-settings {
Expand Down