Skip to content

Commit

Permalink
Tweak Tag Cloud controls and description (#64151)
Browse files Browse the repository at this point in the history
* improve layout of controls

* update description

Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
  • Loading branch information
3 people authored Jul 31, 2024
1 parent 843a7f7 commit 635c134
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ Summarize your post with a list of headings. Add HTML anchors to Heading blocks

## Tag Cloud

A cloud of your most used tags. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/tag-cloud))
A cloud of popular keywords, each sized by how often it appears. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/tag-cloud))

- **Name:** core/tag-cloud
- **Category:** widgets
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/tag-cloud/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "core/tag-cloud",
"title": "Tag Cloud",
"category": "widgets",
"description": "A cloud of your most used tags.",
"description": "A cloud of popular keywords, each sized by how often it appears.",
"textdomain": "default",
"attributes": {
"numberOfTags": {
Expand Down
79 changes: 45 additions & 34 deletions packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
__experimentalUseCustomUnits as useCustomUnits,
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
Disabled,
BaseControl,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -111,21 +112,50 @@ function TagCloudEdit( { attributes, setAttributes } ) {
<PanelBody title={ __( 'Settings' ) }>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Taxonomy' ) }
options={ getTaxonomyOptions() }
value={ taxonomy }
onChange={ ( selectedTaxonomy ) =>
setAttributes( { taxonomy: selectedTaxonomy } )
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show post counts' ) }
checked={ showTagCounts }
onChange={ () =>
setAttributes( { showTagCounts: ! showTagCounts } )
}
/>
<BaseControl>
<Flex gap={ 4 }>
<FlexItem isBlock>
<UnitControl
label={ __( 'Smallest size' ) }
value={ smallestFontSize }
onChange={ ( value ) => {
onFontSizeChange(
'smallestFontSize',
value
);
} }
units={ units }
min={ MIN_FONT_SIZE }
max={ MAX_FONT_SIZE }
size="__unstable-large"
/>
</FlexItem>
<FlexItem isBlock>
<UnitControl
label={ __( 'Largest size' ) }
value={ largestFontSize }
onChange={ ( value ) => {
onFontSizeChange(
'largestFontSize',
value
);
} }
units={ units }
min={ MIN_FONT_SIZE }
max={ MAX_FONT_SIZE }
size="__unstable-large"
/>
</FlexItem>
</Flex>
</BaseControl>
<RangeControl
__nextHasNoMarginBottom
__next40pxDefaultSize
Expand All @@ -138,32 +168,13 @@ function TagCloudEdit( { attributes, setAttributes } ) {
max={ MAX_TAGS }
required
/>
<Flex>
<FlexItem isBlock>
<UnitControl
label={ __( 'Smallest size' ) }
value={ smallestFontSize }
onChange={ ( value ) => {
onFontSizeChange( 'smallestFontSize', value );
} }
units={ units }
min={ MIN_FONT_SIZE }
max={ MAX_FONT_SIZE }
/>
</FlexItem>
<FlexItem isBlock>
<UnitControl
label={ __( 'Largest size' ) }
value={ largestFontSize }
onChange={ ( value ) => {
onFontSizeChange( 'largestFontSize', value );
} }
units={ units }
min={ MIN_FONT_SIZE }
max={ MAX_FONT_SIZE }
/>
</FlexItem>
</Flex>
<ToggleControl
label={ __( 'Show tag counts' ) }
checked={ showTagCounts }
onChange={ () =>
setAttributes( { showTagCounts: ! showTagCounts } )
}
/>
</PanelBody>
</InspectorControls>
);
Expand Down

0 comments on commit 635c134

Please sign in to comment.