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

Font Library: Use SearchControl component for search input #59589

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '@wordpress/element';
import {
__experimentalSpacer as Spacer,
__experimentalInputControl as InputControl,
__experimentalText as Text,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Expand All @@ -21,20 +20,15 @@ import {
Notice,
SelectControl,
Spinner,
Icon,
FlexItem,
Flex,
Button,
DropdownMenu,
SearchControl,
} from '@wordpress/components';
import { debounce } from '@wordpress/compose';
import { sprintf, __, _x } from '@wordpress/i18n';
import {
search,
closeSmall,
moreVertical,
chevronLeft,
} from '@wordpress/icons';
import { moreVertical, chevronLeft } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -168,11 +162,6 @@ function FontCollection( { slug } ) {
setPage( 1 );
};

const resetSearch = () => {
setFilters( { ...filters, search: '' } );
setPage( 1 );
};

const handleToggleVariant = ( font, face ) => {
const newFontsToInstall = toggleFont( font, face, fontsToInstall );
setFontsToInstall( newFontsToInstall );
Expand Down Expand Up @@ -288,20 +277,14 @@ function FontCollection( { slug } ) {
<Spacer margin={ 4 } />
<Flex>
<FlexItem>
<InputControl
<SearchControl
className="font-library-modal__search"
value={ filters.search }
placeholder={ __( 'Font name…' ) }
label={ __( 'Search' ) }
onChange={ debouncedUpdateSearchInput }
prefix={ <Icon icon={ search } /> }
suffix={
filters?.search ? (
<Icon
icon={ closeSmall }
onClick={ resetSearch }
/>
) : null
}
__nextHasNoMarginBottom
hideLabelFromVision={ false }
/>
</FlexItem>
<FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,10 @@ button.font-library-modal__upload-area {
max-width: 400px;
}
}

.font-library-modal__search {
mikachan marked this conversation as resolved.
Show resolved Hide resolved
.components-input-control__container {
background-color: transparent;
border: 1px solid $gray-700;
}
}
Loading