Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
NumberControl
to support min/max font size for Tag Cloud Block
(
#37311) * Add `NumberControl` to support min/max font size for `Tag Cloud Block` * Regenerate fixtures for `tag-cloud` block * address review comment In this commit, I have addressed following comments: 1. fix label of the NumberControl field 2. add min and max value of NumberControl field 3. Wrap NumberControl fields inside flex to make UI consistent * Remove space in label Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> * Remove space from label of smallest size input field Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> * add smallestFontSize and largestFontSize in core blocks docs * fix NumberControl typecasting issue This commit is done inorder to fix type issue since NumberControl returns string and because of that It was not able to render font size properly. * change font size units from `pt` to `px` * fix php lint error replace tabs with spaces during mid-line alignment * replace `NumberControl` with `InputControl` this is done to be in sync with the UI illustrations and UI design pattern * add new attribute `fontSizeUnit` In this commit, a new attribute is introduced to select different font unit example `px` or `pt`. Core blocks docs is also updated * replace `InputControl` with `UnitControl` In this commit, `UnitControl` component is used to configure smallestFontSize and largestFontSize. UnitControl offers input field with a select html tag. `fontSizeUnit` single attribute is used to keep unit in both the fields in sync * update `wp_tag_cloud` args to handle `fontSizeUnit` * fix unit test test cases were failing because of new attribute `fontSizeUnit`. It is fixed now. * change `smallestFontSize` and `largestFontSize` attribute to string * add condition to update font unit * extract font unit from integer fontSize attribute * remove `fontSizeUnit` attribute * fix test cases after removing `fontSizeUnit` and str (smallest/largest)FontSize * fix php lint errors * implement `useCustomUnits` hooks to support different units * add `addFontChange` common function for `(smallest/largest)FontSize` * use `preg_replace` to handle font unit and pass integer font size `wp_tag_cloud` * refactor `onFontChange` function to `onFontSizeChange` function * `tag-cloud` block php handle decimal values `unit` property given a comment to handle decimal value case when passed to `unit` property. I updated the regex to `/^\d*\.?\d*/`. This regex can parse values like `123.3px` or `.33px` or `123px`. * write descriptive variables names Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> * rename `parseUnit` to `parseQuantityAndUnitFromRawValue` Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> * rename `parseUnit` import name Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> * rename `parseUnit` to `parseQuantityAndUnitFromRawValue` Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com> * Apply suggestions from code review Fix formatting * fix: security vulnerability add validate unit method for `wp_tag_cloud` args * fix php lint error using `composer format` command * update regex for unit attribute in `wp_tag_cloud` function * Update UnitControl to have min/max check * change `MIN_FONT_SIZE` to 0.1 Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
- Loading branch information