Make WordPress Core


Ignore:
Timestamp:
01/24/2023 08:38:25 PM (2 years ago)
Author:
hellofromTonya
Message:

Editor: Adds 'settings.typography.fluid.minFontSize' support to wp_get_typography_font_size_value().

In wp_get_typography_font_size_value(), adds support for using a minimum font size for fluid typography when defined in a theme's theme.json file.

Reference:

Follow-up to [54497], [54260].

Props andrewserong, ramonopoly, hellofromTonya, joen.
Fixes #57529.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/typography.php

    r54889 r55133  
    568568     * @ticket 56467
    569569     * @ticket 57065
     570     * @ticket 57529
    570571     *
    571572     * @covers ::wp_register_typography_support
     
    573574     * @dataProvider data_generate_block_supports_font_size_fixtures
    574575     *
    575      * @param string $font_size_value             The block supports custom font size value.
    576      * @param bool   $should_use_fluid_typography An override to switch fluid typography "on". Can be used for unit testing.
    577      * @param string $expected_output             Expected value of style property from wp_apply_typography_support().
    578      */
    579     public function test_should_covert_font_sizes_to_fluid_values( $font_size_value, $should_use_fluid_typography, $expected_output ) {
    580         if ( $should_use_fluid_typography ) {
    581             switch_theme( 'block-theme-child-with-fluid-typography' );
    582         } else {
    583             switch_theme( 'default' );
    584         }
     576     * @param string $font_size_value The block supports custom font size value.
     577     * @param string $theme_slug      A theme slug corresponding to an available test theme.
     578     * @param string $expected_output Expected value of style property from wp_apply_typography_support().
     579     */
     580    public function test_should_covert_font_sizes_to_fluid_values( $font_size_value, $theme_slug, $expected_output ) {
     581        switch_theme( $theme_slug );
    585582
    586583        $this->test_block_name = 'test/font-size-fluid-value';
     
    624621    public function data_generate_block_supports_font_size_fixtures() {
    625622        return array(
    626             'default_return_value'               => array(
    627                 'font_size_value'             => '50px',
    628                 'should_use_fluid_typography' => false,
    629                 'expected_output'             => 'font-size:50px;',
    630             ),
    631             'return_value_with_fluid_typography' => array(
    632                 'font_size_value'             => '50px',
    633                 'should_use_fluid_typography' => true,
    634                 'expected_output'             => 'font-size:clamp(37.5px, 2.344rem + ((1vw - 7.68px) * 1.502), 50px);',
     623            'returns value when fluid typography is not active' => array(
     624                'font_size_value' => '15px',
     625                'theme_slug'      => 'default',
     626                'expected_output' => 'font-size:15px;',
     627            ),
     628            'returns clamp value using default config' => array(
     629                'font_size_value' => '15px',
     630                'theme_slug'      => 'block-theme-child-with-fluid-typography',
     631                'expected_output' => 'font-size:clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px);',
     632            ),
     633            'returns value when font size <= default min font size bound' => array(
     634                'font_size_value' => '13px',
     635                'theme_slug'      => 'block-theme-child-with-fluid-typography',
     636                'expected_output' => 'font-size:13px;',
     637            ),
     638            'returns clamp value using custom fluid config' => array(
     639                'font_size_value' => '17px',
     640                'theme_slug'      => 'block-theme-child-with-fluid-typography-config',
     641                'expected_output' => 'font-size:clamp(16px, 1rem + ((1vw - 7.68px) * 0.12), 17px);',
     642            ),
     643            'returns value when font size <= custom min font size bound' => array(
     644                'font_size_value' => '15px',
     645                'theme_slug'      => 'block-theme-child-with-fluid-typography-config',
     646                'expected_output' => 'font-size:15px;',
    635647            ),
    636648        );
Note: See TracChangeset for help on using the changeset viewer.