Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels around Google font family checkbox controls #297

Merged
merged 2 commits into from
Apr 4, 2023
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
16 changes: 13 additions & 3 deletions src/google-fonts/font-variant.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,31 @@ function FontVariant( { font, variant, isSelected, handleToggle } ) {
} );
}, [ font, variant ] );

const formattedFontFamily = font.family.toLowerCase().replace( ' ', '-' );
const fontId = `${ formattedFontFamily }-${ variant }`;

return (
<tr>
<td className="">
<input
type="checkbox"
name="google-font-variant"
id={ fontId }
value={ variant }
checked={ isSelected }
onClick={ handleToggle }
/>
</td>
<td className="">{ weight }</td>
<td className="">{ style }</td>
<td className="">
<label htmlFor={ fontId }>{ weight }</label>
</td>
<td className="">
<label htmlFor={ fontId }>{ style }</label>
</td>
<td className="demo-cell">
<Demo style={ previewStyles } />
<label htmlFor={ fontId }>
<Demo style={ previewStyles } />
</label>
</td>
</tr>
);
Expand Down
44 changes: 32 additions & 12 deletions src/google-fonts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ function GoogleFonts() {
setSelectedFont( googleFontsData.items[ value ] );
};

let selectedFontFamilyId = '';
if ( selectedFont ) {
selectedFontFamilyId = selectedFont.family
.toLowerCase()
.replace( ' ', '-' );
}

return (
<FontsPageLayout>
<main>
Expand Down Expand Up @@ -235,6 +242,7 @@ function GoogleFonts() {
<td className="">
<input
type="checkbox"
id={ `select-all-${ selectedFontFamilyId }` }
onClick={ () =>
handleToggleAllVariants(
selectedFont.family
Expand All @@ -250,22 +258,34 @@ function GoogleFonts() {
/>
</td>
<td className="">
{ __(
'Weight',
'create-block-theme'
) }
<label
htmlFor={ `select-all-${ selectedFontFamilyId }` }
>
{ __(
'Weight',
'create-block-theme'
) }
</label>
</td>
<td className="">
{ __(
'Style',
'create-block-theme'
) }
<label
htmlFor={ `select-all-${ selectedFontFamilyId }` }
>
{ __(
'Style',
'create-block-theme'
) }
</label>
</td>
<td className="">
{ __(
'Preview',
'create-block-theme'
) }
<label
htmlFor={ `select-all-${ selectedFontFamilyId }` }
>
{ __(
'Preview',
'create-block-theme'
) }
</label>
</td>
</tr>
</thead>
Expand Down