Skip to content

Commit

Permalink
FontSizePicker: implement display: contents for font-size-picker-se…
Browse files Browse the repository at this point in the history
…lect
  • Loading branch information
yogeshbhutkar committed Dec 25, 2024
1 parent e11978c commit adbdbb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
FontSizePickerSelectOption,
} from './types';
import { getCommonSizeUnit, isSimpleCssValue } from './utils';
import { useViewportMatch } from '@wordpress/compose';

const DEFAULT_OPTION: FontSizePickerSelectOption = {
key: 'default',
Expand Down Expand Up @@ -67,11 +66,6 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
? options.find( ( option ) => option.value === value ) ?? CUSTOM_OPTION
: DEFAULT_OPTION;

const isMobileViewport = useViewportMatch( 'medium', '<' );
const truncate = ( str: string, maxLength: number ) => {
return str.length > maxLength ? str.slice( 0, maxLength ) + '…' : str;
};

return (
<CustomSelectControl
__next40pxDefaultSize={ __next40pxDefaultSize }
Expand All @@ -85,13 +79,7 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
selectedOption.name
) }
options={ options }
value={ {
...selectedOption,
name: truncate(
selectedOption.name,
isMobileViewport ? 45 : 30
),
} }
value={ selectedOption }
showSelectedHint
onChange={ ( {
selectedItem,
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/font-size-picker/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.components-font-size-picker {
display: contents;
}
1 change: 1 addition & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@import "./duotone-picker/style.scss";
@import "./duotone-picker/color-list-picker/style.scss";
@import "./external-link/style.scss";
@import "./font-size-picker/style.scss";
@import "./form-toggle/style.scss";
@import "./form-token-field/style.scss";
@import "./guide/style.scss";
Expand Down

0 comments on commit adbdbb5

Please sign in to comment.