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

TreeSelect: remove margin overrides and add new opt-in prop #47515

Merged
merged 10 commits into from
Mar 30, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
}
}

// Reset unexpected margin-bottom from being applied to the `BaseControl`
// component of the `FocalPointPicker` component.
.components-focal-point-picker-control .components-base-control {
margin-bottom: 0;
// Reset unwanted margin-bottom from being applied to BaseControls within certain components.
.components-focal-point-picker-control,
.components-query-controls {
.components-base-control {
margin-bottom: 0;
}
}

.components-panel__body {
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
) }
</PanelBody>

<PanelBody title={ __( 'Sorting and filtering' ) }>
<PanelBody
className="wp-block-latest-posts__sorting-filtering"
brookewp marked this conversation as resolved.
Show resolved Hide resolved
title={ __( 'Sorting and filtering' ) }
>
<QueryControls
{ ...{ order, orderBy } }
numberOfItems={ postsToShow }
Expand Down
9 changes: 5 additions & 4 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@
- `ColorPicker`: Convert to TypeScript ([#49214](https://github.com/WordPress/gutenberg/pull/49214)).
- `GradientPicker`: Convert to TypeScript ([#48316](https://github.com/WordPress/gutenberg/pull/48316)).
- `FormTokenField`: Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles ([48609](https://github.com/WordPress/gutenberg/pull/48609)).
- `QueryControls`: Replace bottom margin overrides with `__nextHasNoMarginBottom`([47515](https://github.com/WordPress/gutenberg/pull/47515)).

### Enhancements

- `CustomGradientPicker`: improve initial state UI ([#49146](https://github.com/WordPress/gutenberg/pull/49146)).
- `AnglePickerControl`: Style to better fit in narrow contexts and improve RTL layout ([#49046](https://github.com/WordPress/gutenberg/pull/49046)).
- `AnglePickerControl`: Style to better fit in narrow contexts and improve RTL layout ([#49046](https://github.com/WordPress/gutenberg/pull/49046)).
- `ImageSizeControl`: Use large 40px sizes ([#49113](https://github.com/WordPress/gutenberg/pull/49113)).

### Bug Fix

- `CircularOptionPicker`: force swatches to visually render on top of the rest of the component's content ([#49245](https://github.com/WordPress/gutenberg/pull/49245)).
- `InputControl`: Fix misaligned textarea input control ([#49116](https://github.com/WordPress/gutenberg/pull/49116)).
- `ToolsPanel`: Ensure consistency in menu item order ([#49222](https://github.com/WordPress/gutenberg/pull/49222)).
- `CircularOptionPicker`: force swatches to visually render on top of the rest of the component's content ([#49245](https://github.com/WordPress/gutenberg/pull/49245)).
- `InputControl`: Fix misaligned textarea input control ([#49116](https://github.com/WordPress/gutenberg/pull/49116)).
- `ToolsPanel`: Ensure consistency in menu item order ([#49222](https://github.com/WordPress/gutenberg/pull/49222)).

### Internal

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/query-controls/author-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function AuthorSelect( {
? String( selectedAuthorId )
: undefined
}
__nextHasNoMarginBottom
brookewp marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function CategorySelect( {
: undefined
}
{ ...props }
__nextHasNoMarginBottom
/>
);
}
6 changes: 4 additions & 2 deletions packages/components/src/query-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CategorySelect from './category-select';
import FormTokenField from '../form-token-field';
import RangeControl from '../range-control';
import SelectControl from '../select-control';
import { VStack } from '../v-stack';
import type {
QueryControlsProps,
QueryControlsWithMultipleCategorySelectionProps,
Expand Down Expand Up @@ -75,7 +76,7 @@ export function QueryControls( {
...props
}: QueryControlsProps ) {
return (
<>
<VStack spacing="4" className="components-query-controls">
{ [
onOrderChange && onOrderByChange && (
<SelectControl
Expand Down Expand Up @@ -142,6 +143,7 @@ export function QueryControls( {
props.categorySuggestions &&
props.onCategoryChange && (
<FormTokenField
__nextHasNoMarginBottom
key="query-controls-categories-select"
label={ __( 'Categories' ) }
value={
Expand Down Expand Up @@ -185,7 +187,7 @@ export function QueryControls( {
/>
),
] }
</>
</VStack>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
TextControl,
TreeSelect,
withFilters,
__experimentalVStack as VStack,
Flex,
ciampo marked this conversation as resolved.
Show resolved Hide resolved
FlexItem,
} from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { useDebounce } from '@wordpress/compose';
Expand Down Expand Up @@ -392,11 +393,10 @@ export function HierarchicalTermSelector( { slug } ) {
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;

return (
<>
<Flex direction="column" gap="4">
{ showFilter && (
<TextControl
__nextHasNoMarginBottom
className="editor-post-taxonomies__hierarchical-terms-filter"
label={ filterLabel }
value={ filterValue }
onChange={ setFilter }
Expand All @@ -413,18 +413,20 @@ export function HierarchicalTermSelector( { slug } ) {
) }
</div>
{ ! loading && hasCreateAction && (
<Button
onClick={ onToggleForm }
className="editor-post-taxonomies__hierarchical-terms-add"
aria-expanded={ showForm }
variant="link"
>
{ newTermButtonLabel }
</Button>
<FlexItem>
<Button
onClick={ onToggleForm }
className="editor-post-taxonomies__hierarchical-terms-add"
aria-expanded={ showForm }
variant="link"
>
{ newTermButtonLabel }
</Button>
</FlexItem>
) }
{ showForm && (
<form onSubmit={ onAddTerm }>
<VStack>
<Flex direction="column" gap="4">
ciampo marked this conversation as resolved.
Show resolved Hide resolved
<TextControl
__nextHasNoMarginBottom
className="editor-post-taxonomies__hierarchical-terms-input"
Expand All @@ -435,24 +437,27 @@ export function HierarchicalTermSelector( { slug } ) {
/>
{ !! availableTerms.length && (
<TreeSelect
__nextHasNoMarginBottom
label={ parentSelectLabel }
noOptionLabel={ noParentOption }
onChange={ onChangeFormParent }
selectedId={ formParent }
tree={ availableTermsTree }
/>
) }
</VStack>
<Button
variant="secondary"
type="submit"
className="editor-post-taxonomies__hierarchical-terms-submit"
>
{ newTermSubmitLabel }
</Button>
<FlexItem>
<Button
variant="secondary"
type="submit"
className="editor-post-taxonomies__hierarchical-terms-submit"
>
{ newTermSubmitLabel }
</Button>
</FlexItem>
</Flex>
</form>
) }
</>
</Flex>
);
}

Expand Down
22 changes: 6 additions & 16 deletions packages/editor/src/components/post-taxonomies/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,20 @@
}

.editor-post-taxonomies__hierarchical-terms-choice {
margin-bottom: 8px;
margin-bottom: $grid-unit-10;
&:last-child {
margin-bottom: $grid-unit-05;
}
}

.editor-post-taxonomies__hierarchical-terms-subchoices {
margin-top: 8px;
margin-top: $grid-unit-10;
ciampo marked this conversation as resolved.
Show resolved Hide resolved
margin-left: $grid-unit-20;
}

.components-button.editor-post-taxonomies__hierarchical-terms-submit,
.components-button.editor-post-taxonomies__hierarchical-terms-add {
margin-top: 12px;
}

.editor-post-taxonomies__hierarchical-terms-label {
display: inline-block;
margin-top: 12px;
}

.editor-post-taxonomies__hierarchical-terms-input {
margin-top: 8px;
}
.editor-post-taxonomies__hierarchical-terms-filter {
margin-bottom: 8px;
width: 100%;
margin-top: $grid-unit-15;
brookewp marked this conversation as resolved.
Show resolved Hide resolved
}

.editor-post-taxonomies__flat-term-most-used {
Expand Down