forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Font Library: Font Collections frontend (WordPress#54566)
* remove wrong comment around code merge * registering google fonts collection * registering google fonts collection * TEMPORAL: Adding Google Fonts list data as JSON file * removing unused constant * add data resolvers to fetch font collections * fetching collections data from context * adding collections tabs in font library modal * refactor google-fonts categories * add filter fonts functions * add filterFonts functions tests * move actionHandler into FontCard component * adding ui filters for font collections * add font collections selected variants indicator * add tests for fonts-outline functions * install fonts * fixing the css font family name in the previews to handle font names with spaces * add tests for previews styles functions * change value used for refresh font library posts * removing not needed prefix on slug * updating google fonts data file with previews * loading svg previews * fixing categories in google fonts json file * format php * adding google fonts confirmation * Removing ordering because it is not needed here. Use the default order provided by the font colletion data * updating google fonts preview urls to load from the new repo * update wording Co-authored-by: Brian Alexander <[email protected]> * update wording Co-authored-by: Brian Alexander <[email protected]> * update wording Co-authored-by: Brian Alexander <[email protected]> * changing src by downloadFromUrl * use window.localStorage instead of localStorage * fixing font collection getData test * refactor getFontCollections php unit tests to the the default font collection too * renaming Google Fonts to Default Font Collection * adding font name to tab title when a font is selected * replace button deprecated prop * implement a fontface sort function * adding unit tests for fontface sorting function * use fontface sorting' * use Google fonts as tab title * format php * revert unwanted changes * add translation domain --------- Co-authored-by: Brian Alexander <[email protected]>
- Loading branch information
1 parent
ceadbe4
commit 1873738
Showing
30 changed files
with
56,764 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55,714 changes: 55,714 additions & 0 deletions
55,714
lib/experimental/fonts/font-library/default-font-collection.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ages/edit-site/src/components/global-styles/font-library-modal/collection-font-details.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalVStack as VStack, | ||
__experimentalSpacer as Spacer, | ||
} from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import CollectionFontVariant from './collection-font-variant'; | ||
import { isFontFontFaceInOutline } from './utils/fonts-outline'; | ||
import { sortFontFaces } from './utils/sort-font-faces'; | ||
|
||
function CollectionFontDetails( { | ||
font, | ||
handleToggleVariant, | ||
fontToInstallOutline, | ||
} ) { | ||
const fontFaces = | ||
font.fontFace && font.fontFace.length | ||
? sortFontFaces( font.fontFace ) | ||
: [ | ||
{ | ||
fontFamily: font.fontFamily, | ||
fontStyle: 'normal', | ||
fontWeight: '400', | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<Spacer margin={ 4 } /> | ||
<VStack spacing={ 0 }> | ||
<Spacer margin={ 8 } /> | ||
{ fontFaces.map( ( face, i ) => ( | ||
<CollectionFontVariant | ||
font={ font } | ||
face={ face } | ||
key={ `face${ i }` } | ||
handleToggleVariant={ handleToggleVariant } | ||
selected={ isFontFontFaceInOutline( | ||
font.slug, | ||
face, | ||
fontToInstallOutline | ||
) } | ||
/> | ||
) ) } | ||
</VStack> | ||
<Spacer margin={ 8 } /> | ||
</> | ||
); | ||
} | ||
|
||
export default CollectionFontDetails; |
45 changes: 45 additions & 0 deletions
45
...ages/edit-site/src/components/global-styles/font-library-modal/collection-font-variant.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { CheckboxControl, Flex } from '@wordpress/components'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getFontFaceVariantName } from './utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import FontFaceDemo from './font-demo'; | ||
|
||
function CollectionFontVariant( { | ||
face, | ||
font, | ||
handleToggleVariant, | ||
selected, | ||
} ) { | ||
const handleToggleActivation = () => { | ||
if ( font?.fontFace ) { | ||
handleToggleVariant( font, face ); | ||
return; | ||
} | ||
handleToggleVariant( font ); | ||
}; | ||
|
||
const displayName = font.name + ' ' + getFontFaceVariantName( face ); | ||
|
||
return ( | ||
<div className="font-library-modal__library-font-variant"> | ||
<Flex justify="space-between" align="center" gap="1rem"> | ||
<FontFaceDemo fontFace={ face } text={ displayName } /> | ||
<CheckboxControl | ||
checked={ selected } | ||
onChange={ handleToggleActivation } | ||
__nextHasNoMarginBottom={ true } | ||
/> | ||
</Flex> | ||
</div> | ||
); | ||
} | ||
|
||
export default CollectionFontVariant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.