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

Remove/font management #519

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Removed Font Management tooling from plugin
pbking committed Mar 15, 2024
commit ea0861fa6249087ffb98c1a885a71e71f022a2e5
34 changes: 0 additions & 34 deletions .github/workflows/deploy-to-dotorg.yml
Original file line number Diff line number Diff line change
@@ -14,40 +14,6 @@ on:
- minor
- patch
jobs:
update-google-fonts-json:
if: github.repository_owner == 'WordPress'
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

# Runs a single command using the runners shell
# This script fetchs the Goolgle Fonts API data and creates a PR if new data is available
- name: Update Google Fonts JSON file
env:
GOOGLE_FONTS_API_KEY: ${{ secrets.GOOGLE_FONTS_API_KEY }}
run: |
echo "Updating Google fonts JSON file"
node ./update-google-fonts-json-file.js
- name: Commit Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git config --global --add --bool push.autoSetupRemote true

git diff-index --quiet HEAD -- || \
( git add assets/google-fonts/fallback-fonts-list.json && \
git checkout trunk && \
git commit -m "Automation: update Google Fonts data file" --no-verify && \
git push
)
tag:
name: Checkout repo
runs-on: ubuntu-latest
423 changes: 0 additions & 423 deletions admin/class-manage-fonts.php

This file was deleted.

30 changes: 0 additions & 30 deletions admin/font-helpers.php

This file was deleted.

114 changes: 0 additions & 114 deletions admin/manage-fonts/font-form-messages.php

This file was deleted.

34 changes: 0 additions & 34 deletions admin/manage-fonts/fonts-page.php

This file was deleted.

14 changes: 0 additions & 14 deletions admin/manage-fonts/google-fonts-page.php

This file was deleted.

19 changes: 0 additions & 19 deletions admin/manage-fonts/local-fonts-page.php

This file was deleted.

38,884 changes: 0 additions & 38,884 deletions assets/google-fonts/fallback-fonts-list.json

This file was deleted.

2 changes: 0 additions & 2 deletions includes/class-create-block-theme.php
Original file line number Diff line number Diff line change
@@ -41,7 +41,6 @@ private function load_dependencies() {
* The class responsible for defining all actions that occur in the admin area.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-create-theme.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-manage-fonts.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/wp-org-theme-directory.php';

require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-create-block-theme-api.php';
@@ -60,7 +59,6 @@ private function load_dependencies() {
private function define_admin_hooks() {

$plugin_admin = new Create_Block_Theme_Admin();
$manage_fonts_admin = new Manage_Fonts_Admin();
$wp_theme_directory = new WP_Theme_Directory();
$plugin_api = new Create_Block_Theme_API();
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -20,8 +20,7 @@
},
"main": "build/index.js",
"dependencies": {
"@wordpress/icons": "^9.24.0",
"lib-font": "^2.4.0"
"@wordpress/icons": "^9.24.0"
},
"devDependencies": {
"@actions/core": "^1.10.0",
@@ -41,7 +40,7 @@
"simple-git": "^3.18.0"
},
"scripts": {
"build": "wp-scripts build src/index.js src/plugin-sidebar.js src/wp-org-theme-directory.js",
"build": "wp-scripts build src/plugin-sidebar.js src/wp-org-theme-directory.js",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:css:fix": "npm run lint:css -- --fix",
27 changes: 0 additions & 27 deletions src/demo-text-input/axis-range-control.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/demo-text-input/demo-text-input.css

This file was deleted.

22 changes: 0 additions & 22 deletions src/demo-text-input/demo.js

This file was deleted.

96 changes: 0 additions & 96 deletions src/demo-text-input/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/demo-text-input/utils.js

This file was deleted.

31 changes: 0 additions & 31 deletions src/demo-text-input/variable-controls.js

This file was deleted.

96 changes: 0 additions & 96 deletions src/fonts-context.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/fonts-page-layout/fonts-page-layout.css

This file was deleted.

7 changes: 0 additions & 7 deletions src/fonts-page-layout/index.js

This file was deleted.

102 changes: 0 additions & 102 deletions src/fonts-sidebar/fonts-sidebar.css

This file was deleted.

203 changes: 0 additions & 203 deletions src/fonts-sidebar/index.js

This file was deleted.

77 changes: 0 additions & 77 deletions src/google-fonts/font-variant.js

This file was deleted.

37 changes: 0 additions & 37 deletions src/google-fonts/google-fonts.css

This file was deleted.

410 changes: 0 additions & 410 deletions src/google-fonts/index.js

This file was deleted.

50 changes: 0 additions & 50 deletions src/index.js

This file was deleted.

141 changes: 0 additions & 141 deletions src/local-fonts/index.js

This file was deleted.

41 changes: 0 additions & 41 deletions src/local-fonts/local-fonts.css

This file was deleted.

230 changes: 0 additions & 230 deletions src/local-fonts/upload-font-form.js

This file was deleted.

24 changes: 0 additions & 24 deletions src/manage-fonts/back-button.js

This file was deleted.

51 changes: 0 additions & 51 deletions src/manage-fonts/confirm-delete-modal.js

This file was deleted.

45 changes: 0 additions & 45 deletions src/manage-fonts/font-face.js

This file was deleted.

141 changes: 0 additions & 141 deletions src/manage-fonts/font-family.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/manage-fonts/help-modal.js

This file was deleted.

203 changes: 0 additions & 203 deletions src/manage-fonts/index.js

This file was deleted.

135 changes: 0 additions & 135 deletions src/manage-fonts/manage-fonts.css

This file was deleted.

46 changes: 0 additions & 46 deletions src/manage-fonts/page-header.js

This file was deleted.

30 changes: 0 additions & 30 deletions src/test/unit.js

This file was deleted.

86 changes: 12 additions & 74 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,26 @@
import { __, _x } from '@wordpress/i18n';

export function getStyleFromGoogleVariant( variant ) {
return variant.includes( 'italic' ) ? 'italic' : 'normal';
}

export function getWeightFromGoogleVariant( variant ) {
return variant === 'regular' || variant === 'italic'
? '400'
: variant.replace( 'italic', '' );
}

export function getGoogleVariantFromStyleAndWeight( style, weight ) {
if ( weight === '400' ) {
if ( style === 'italic' ) {
return 'italic';
}
return 'regular';
}
if ( style === 'normal' ) {
return weight;
}
return weight + style;
}

export function localizeFontStyle( style ) {
const styles = {
normal: _x( 'Normal', 'Font style', 'create-block-theme' ),
italic: _x( 'Italic', 'Font style', 'create-block-theme' ),
};
return styles[ style ] !== undefined ? styles[ style ] : style;
}

export function forceHttps( url ) {
return url.replace( 'http://', 'https://' );
}

export function bytesToSize( bytes ) {
const sizes = [ 'Bytes', 'KB', 'MB', 'GB', 'TB' ];
if ( bytes === 0 ) return __( 'n/a', 'create-block-theme' );
const i = parseInt( Math.floor( Math.log( bytes ) / Math.log( 1024 ) ) );
if ( i === 0 ) return bytes + ' ' + sizes[ i ];
return ( bytes / Math.pow( 1024, i ) ).toFixed( 1 ) + ' ' + sizes[ i ];
}

export function localFileAsThemeAssetUrl( url ) {
if ( ! url ) {
return url;
}
return url.replace( 'file:./', createBlockTheme.themeUrl + '/' );
}

export async function downloadFile( response ) {
export async function downloadFile(response) {

Check failure on line 1 in src/utils.js

GitHub Actions / Lint

Replace `response` with `·response·`
const blob = await response.blob();
const filename = response.headers
.get( 'Content-Disposition' )
.split( 'filename=' )[ 1 ];
.get('Content-Disposition')

Check failure on line 4 in src/utils.js

GitHub Actions / Lint

Replace `'Content-Disposition'` with `·'Content-Disposition'·`
.split('filename=')[1];

Check failure on line 5 in src/utils.js

GitHub Actions / Lint

Replace `'filename=')[1` with `·'filename='·)[·1·`

// Check if the browser supports navigator.msSaveBlob or navigator.saveBlob
if ( navigator.msSaveBlob || navigator.saveBlob ) {
if (navigator.msSaveBlob || navigator.saveBlob) {

Check failure on line 8 in src/utils.js

GitHub Actions / Lint

Replace `navigator.msSaveBlob·||·navigator.saveBlob` with `·navigator.msSaveBlob·||·navigator.saveBlob·`
const saveBlob = navigator.msSaveBlob || navigator.saveBlob;
saveBlob.call( navigator, blob, filename );
saveBlob.call(navigator, blob, filename);

Check failure on line 10 in src/utils.js

GitHub Actions / Lint

Replace `navigator,·blob,·filename` with `·navigator,·blob,·filename·`
} else {
// Fall back to creating an object URL and triggering a download using an anchor element
const url = URL.createObjectURL( blob );
const url = URL.createObjectURL(blob);

Check failure on line 13 in src/utils.js

GitHub Actions / Lint

Replace `blob` with `·blob·`

const a = document.createElement( 'a' );
const a = document.createElement('a');

Check failure on line 15 in src/utils.js

GitHub Actions / Lint

Replace `'a'` with `·'a'·`
a.href = url;
a.download = filename;
document.body.appendChild( a );
document.body.appendChild(a);

Check failure on line 18 in src/utils.js

GitHub Actions / Lint

Replace `a` with `·a·`
a.click();
document.body.removeChild( a );
document.body.removeChild(a);

Check failure on line 20 in src/utils.js

GitHub Actions / Lint

Replace `a` with `·a·`

setTimeout( () => {
URL.revokeObjectURL( url );
}, 100 );
setTimeout(() => {

Check failure on line 22 in src/utils.js

GitHub Actions / Lint

Insert `·`
URL.revokeObjectURL(url);
}, 100);
}
}

/*
* Add quotes to font name.
* @param {string} familyName The font family name.
* @return {string} The font family name with quotes.
*/

export function addQuotesToName( familyName ) {
return `'${ familyName }'`.trim();
}
10 changes: 0 additions & 10 deletions test/unit/jest.config.js

This file was deleted.

7 changes: 0 additions & 7 deletions test/unit/setup.js

This file was deleted.

70 changes: 0 additions & 70 deletions update-google-fonts-json-file.js

This file was deleted.

12 changes: 1 addition & 11 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
/**
* WordPress Dependencies
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config.js' );
const defaultConfig = require('@wordpress/scripts/config/webpack.config.js');

module.exports = {
// Default wordpress config
...defaultConfig,

// custom config to avoid errors with lib-font dependency
...{
resolve: {
fallback: {
zlib: false,
fs: false,
},
},
},
};