diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 106863c020c5d..5447608a3a9eb 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -6,6 +6,7 @@ - `FormToggle`: fix sass deprecation warning ([#56672](https://github.com/WordPress/gutenberg/pull/56672)). - `QueryControls`: Add opt-in prop for 40px default size ([#56576](https://github.com/WordPress/gutenberg/pull/56576)). +- `CheckboxControl`: Add option to not render label ([#56158](https://github.com/WordPress/gutenberg/pull/56158)). ## 25.13.0 (2023-11-29) diff --git a/packages/components/src/checkbox-control/README.md b/packages/components/src/checkbox-control/README.md index 12f792ea8577b..66f3cae2be379 100644 --- a/packages/components/src/checkbox-control/README.md +++ b/packages/components/src/checkbox-control/README.md @@ -77,11 +77,12 @@ const MyCheckboxControl = () => { The set of props accepted by the component will be specified below. Props not included in this set will be applied to the input element. -#### `label`: `string` +#### `label`: `string|false` A label for the input field, that appears at the side of the checkbox. The prop will be rendered as content a label element. If no prop is passed an empty label is rendered. +If the prop is set to false no label is rendered. - Required: No diff --git a/packages/components/src/checkbox-control/index.tsx b/packages/components/src/checkbox-control/index.tsx index cd70bb8485ac7..54a9952d19949 100644 --- a/packages/components/src/checkbox-control/index.tsx +++ b/packages/components/src/checkbox-control/index.tsx @@ -125,12 +125,14 @@ export function CheckboxControl( /> ) : null } - + { label && ( + + ) } ); } diff --git a/packages/components/src/checkbox-control/test/__snapshots__/index.tsx.snap b/packages/components/src/checkbox-control/test/__snapshots__/index.tsx.snap index 408f18d8c7e77..f3bdccc1ccff6 100644 --- a/packages/components/src/checkbox-control/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/checkbox-control/test/__snapshots__/index.tsx.snap @@ -5,14 +5,14 @@ Snapshot Diff: - First value + Second value -@@ -8,17 +8,31 @@ +@@ -8,13 +8,27 @@ @@ -31,11 +31,6 @@ Snapshot Diff: /> + - ); } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js index 32e18c023cecb..010f3efdbeb91 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/library-font-variant.js @@ -3,16 +3,14 @@ */ import { useContext } from '@wordpress/element'; import { CheckboxControl, Flex } from '@wordpress/components'; -/** - * Internal dependencies - */ -import { getFontFaceVariantName } from './utils'; /** * Internal dependencies */ +import { getFontFaceVariantName } from './utils'; import { FontLibraryContext } from './context'; import FontFaceDemo from './font-demo'; +import { kebabCase } from '../../../../../block-editor/src/utils/object'; function LibraryFontVariant( { face, font } ) { const { isFontActivated, toggleActivateFont } = @@ -36,18 +34,26 @@ function LibraryFontVariant( { face, font } ) { }; const displayName = font.name + ' ' + getFontFaceVariantName( face ); + const checkboxId = kebabCase( + `${ font.slug }-${ getFontFaceVariantName( face ) }` + ); return ( -
+
+ ); } diff --git a/test/e2e/specs/site-editor/font-library.spec.js b/test/e2e/specs/site-editor/font-library.spec.js index 6aca027a30e78..531398fb49590 100644 --- a/test/e2e/specs/site-editor/font-library.spec.js +++ b/test/e2e/specs/site-editor/font-library.spec.js @@ -70,5 +70,26 @@ test.describe( 'Font Library', () => { page.getByRole( 'heading', { name: 'Fonts' } ) ).toBeVisible(); } ); + + test( 'should show font variant panel when clicking on a font family', async ( { + page, + } ) => { + await page.getByRole( 'button', { name: /styles/i } ).click(); + await page + .getByRole( 'button', { name: /typography styles/i } ) + .click(); + await page + .getByRole( 'button', { + name: /manage fonts/i, + } ) + .click(); + await page.getByRole( 'button', { name: /system font/i } ).click(); + await expect( + page.getByRole( 'heading', { name: /system font/i } ) + ).toBeVisible(); + await expect( + page.getByRole( 'checkbox', { name: /system font normal/i } ) + ).toBeVisible(); + } ); } ); } );