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

Update SearchControl consumers #58014

Merged
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
16 changes: 3 additions & 13 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ $block-inserter-tabs-height: 44px;

.block-editor-inserter__search {
padding: $grid-unit-20 $grid-unit-20 0 $grid-unit-20;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR necessarily, but I think technically it would be better to add margin, instead of padding — at least more future-proof!


.components-search-control__icon {
right: $grid-unit-10 + ($grid-unit-60 - $icon-size) * 0.5;
}
}

.block-editor-inserter__tabs {
Expand Down Expand Up @@ -615,15 +611,9 @@ $block-inserter-tabs-height: 44px;
}

.block-editor-inserter__media-panel-search {
&.components-search-control {
input[type="search"].components-search-control__input {
background: $white;
}
button.components-button {
min-width: auto;
padding-left: $grid-unit-05 * 0.5;
padding-right: $grid-unit-05 * 0.5;
}
// TODO: Consider using the Theme component to automatically adapt to a gray background.
&:not(:focus-within) {
--wp-components-color-background: #{$white};
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/navigation/menu/menu-title-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { __, _n, sprintf } from '@wordpress/i18n';
import withSpokenMessages from '../../higher-order/with-spoken-messages';
import { useNavigationMenuContext } from './context';
import { useNavigationContext } from '../context';
import { MenuTitleSearchUI } from '../styles/navigation-styles';
import { SEARCH_FOCUS_DELAY } from '../constants';

import type { NavigationMenuTitleSearchProps } from '../types';
import SearchControl from '../../search-control';
import { MenuTitleSearchControlWrapper } from '../styles/navigation-styles';

function MenuTitleSearch( {
debouncedSpeak,
Expand Down Expand Up @@ -80,20 +81,19 @@ function MenuTitleSearch( {
).trim();

return (
<div className="components-navigation__menu-title-search">
<MenuTitleSearchUI
autoComplete="off"
<MenuTitleSearchControlWrapper>
<SearchControl
__nextHasNoMarginBottom
className="components-navigation__menu-search-input"
id={ inputId }
onChange={ ( value ) => onSearch?.( value ) }
onKeyDown={ onKeyDown }
placeholder={ placeholder }
onClose={ onClose }
ref={ inputRef }
type="search"
value={ search }
/>
</div>
</MenuTitleSearchControlWrapper>
);
}

Expand Down
32 changes: 5 additions & 27 deletions packages/components/src/navigation/styles/navigation-styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Text } from '../../text';
import { Heading } from '../../heading';
import { reduceMotion, rtl } from '../../utils';
import { space } from '../../utils/space';
import SearchControl from '../../search-control';

export const NavigationUI = styled.div`
width: 100%;
Expand Down Expand Up @@ -69,6 +68,11 @@ export const MenuTitleUI = styled.div`
width: 100%;
`;

export const MenuTitleSearchControlWrapper = styled.div`
margin: 11px 0; // non-ideal hardcoding to maintain same height as Heading, could be improved
padding: 1px; // so the focus border doesn't get cut off by the overflow hidden on MenuTitleUI
`;

export const MenuTitleActionsUI = styled.span`
height: ${ space( 6 ) }; // 24px, same height as the buttons inside
Expand All @@ -91,32 +95,6 @@ export const MenuTitleActionsUI = styled.span`
}
`;

export const MenuTitleSearchUI = styled( SearchControl )`
input[type='search'].components-search-control__input {
margin: 0;
background: #303030;
color: #fff;
&:focus {
background: #434343;
color: #fff;
}
&::placeholder {
color: rgba( 255, 255, 255, 0.6 );
}
}
svg {
fill: white;
}
.components-button.has-icon {
padding: 0;
min-width: auto;
}
`;

export const GroupTitleUI = styled( Heading )`
min-height: ${ space( 12 ) };
align-items: center;
Expand Down
12 changes: 0 additions & 12 deletions packages/edit-site/src/components/add-new-template/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
}
}

.components-search-control {
input[type="search"].components-search-control__input {
background: $white;
border: 1px solid $gray-300;

&:focus {
border-color: var(--wp-admin-theme-color);
box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
}
}
}

@include break-medium() {
width: 456px;
}
Expand Down
13 changes: 4 additions & 9 deletions packages/edit-site/src/components/page-patterns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@
flex-grow: 1;
}

// The increased specificity here is to overcome component styles
// without relying on internal component class names.
// TODO: Consider using the Theme component to automatically adapt to a dark background.
.edit-site-patterns__search {
input[type="search"] {
height: $button-size-next-default-40px;
background: $gray-800;
color: $gray-200;
--wp-components-color-foreground: #{$gray-200};

&:focus {
background: $gray-800;
}
.components-input-control__container {
background: $gray-800;
}

svg {
Expand Down
Loading