Skip to content
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ size offered.
### `hm_button_icon_mobile_breakpoint`

The viewport width below which a button's label set to **Hide below 782px**
clips. Defaults to `782`, the width core treats as the top of mobile. Has no
effect on a label set to **Always hide**, which carries no breakpoint.
clips. Defaults to `782`, the width core treats as the top of mobile. The
option's name in the editor follows the filtered value. Has no effect on a
label set to **Always hide**, which carries no breakpoint.

```php
add_filter( 'hm_button_icon_mobile_breakpoint', fn (): int => 600 );
Expand Down
7 changes: 4 additions & 3 deletions inc/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ function enqueue_editor_assets(): void {
EDITOR_HANDLE,
'window.hmButtonIcon = ' . wp_json_encode(
[
'attributes' => Attributes\definitions(),
'collections' => Attributes\collections(),
'sizes' => Attributes\sizes(),
'attributes' => Attributes\definitions(),
'collections' => Attributes\collections(),
'sizes' => Attributes\sizes(),
'mobileBreakpoint' => mobile_breakpoint(),
]
) . ';',
'before'
Expand Down
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const SETTINGS = window.hmButtonIcon ?? {};
const ATTRIBUTES = SETTINGS.attributes ?? {};
const COLLECTIONS = SETTINGS.collections ?? [];
const SIZES = SETTINGS.sizes?.length ? SETTINGS.sizes : [ 16, 24, 32 ];
const MOBILE_BREAKPOINT = SETTINGS.mobileBreakpoint ?? 782;

/** Attribute values that clear whichever source is not in use. */
const NO_ICON = {
Expand Down Expand Up @@ -480,9 +481,13 @@ const withIconControls = createHigherOrderComponent(
value: 'visible',
},
{
label: __(
'Hide below 782px',
'button-block-icon'
label: sprintf(
/* translators: %d: viewport width in pixels. */
__(
'Hide below %dpx',
'button-block-icon'
),
MOBILE_BREAKPOINT
),
value: 'mobile',
},
Expand Down
Loading