Skip to content

Commit

Permalink
Merge pull request #2 from bigbite/feat/BBT-37-use-wp-scripts
Browse files Browse the repository at this point in the history
Feature: Use wp-scripts BBT-37
  • Loading branch information
g-elwell authored Jun 23, 2023
2 parents 53a933f + 7d79da3 commit 1408f5b
Show file tree
Hide file tree
Showing 19 changed files with 27,889 additions and 21,081 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules/
vendor/
dist/
build/

.DS_Store
inc/asset-settings.php
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Install JS packages.
npm install
```

Build all assets - additional commands can be found on the [`bigbite/build-tools` repo.](https://github.com/bigbite/build-tools#commands)
Build all assets
```
npm run build:dev
npm run build:prod
```

Install PHP packages and create autoloader for the plugin.
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"autoload": {
"files": [
"inc/constants.php",
"inc/asset-settings.php",
"inc/utils.php",
"inc/class-admin.php",
"inc/setup.php"
Expand Down
11 changes: 6 additions & 5 deletions inc/class-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@ public function __construct() {
*/
public function enqueue_themer_assets() : void {
$plugin_name = basename(THEMER_DIR);
$asset_file = include THEMER_DIR . '/build/index.asset.php';

wp_enqueue_style('wp-components');

wp_enqueue_script(
self::SCRIPT_NAME,
plugins_url($plugin_name . '/dist/scripts/' . THEMER_EDITOR_JS, $plugin_name),
[ 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-plugins', 'wp-edit-post', 'wp-api' ],
(string) filemtime(THEMER_DIR . '/dist/scripts/' . THEMER_EDITOR_JS),
plugins_url($plugin_name . '/build/index.js', $plugin_name),
array_merge( $asset_file['dependencies'], [ 'wp-edit-post'] ),
$asset_file['version'],
false
);

wp_enqueue_style(
self::STYLE_NAME,
plugins_url($plugin_name . '/dist/styles/' . THEMER_EDITOR_CSS, $plugin_name),
plugins_url($plugin_name . '/build/index.css', $plugin_name),
[],
(string) filemtime(THEMER_DIR . '/dist/styles/' . THEMER_EDITOR_CSS)
$asset_file['version']
);
}
}
Expand Down
7 changes: 0 additions & 7 deletions inc/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
* @return void
*/
function setup() : void {
if(
! defined( 'THEMER_EDITOR_JS' ) ||
! defined( 'THEMER_EDITOR_CSS' )
) {
throw new \Error( "Asset constants are not defined. You may need to run an asset build." );
}

new Loader();
new AdminSetup();
}
48,820 changes: 27,843 additions & 20,977 deletions package-lock.json

Large diffs are not rendered by default.

47 changes: 24 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"name": "@big-bite/themer",
"description": "",
"version": "1.0.0-alpha.1",
"author": "Big Bite",
"prettier": "@bigbite/build-tools/configs/prettier",
"scripts": {
"build:dev": "build-tools build --once",
"build:prod": "build-tools build --once --production",
"watch:dev": "build-tools build",
"watch:prod": "build-tools build --production"
},
"dependencies": {
"@bigbite/build-tools": "^1.2.0",
"@wordpress/block-editor": "^11.8.0",
"@wordpress/components": "^23.8.0",
"@wordpress/core-data": "^6.8.0",
"@wordpress/data": "^9.5.0",
"@wordpress/edit-site": "^5.8.0",
"@wordpress/element": "^5.8.0",
"@wordpress/i18n": "^4.20.0",
"@wordpress/plugins": "^6.3.0",
"lodash": "^4.17.21"
}
"name": "@big-bite/themer",
"description": "",
"version": "1.0.0-alpha.1",
"author": "Big Bite",
"prettier": "@wordpress/prettier-config",
"scripts": {
"watch:dev": "wp-scripts start",
"build:prod": "wp-scripts build"
},
"dependencies": {
"@wordpress/block-editor": "^11.8.0",
"@wordpress/components": "^23.8.0",
"@wordpress/core-data": "^6.8.0",
"@wordpress/data": "^9.5.0",
"@wordpress/dom-ready": "^3.35.0",
"@wordpress/edit-site": "^5.8.0",
"@wordpress/element": "^5.8.0",
"@wordpress/i18n": "^4.20.0",
"@wordpress/plugins": "^6.3.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"@wordpress/scripts": "^26.6.0"
}
}
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ parameters:
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- inc/constants.php
- inc/asset-settings.php
paths:
- inc/
ignoreErrors:
Expand Down
17 changes: 0 additions & 17 deletions src/editor/api.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/editor/components/fields/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { set, merge } from 'lodash';
import { useState } from '@wordpress/element';
import ComponentMap from './ComponentMap';
import { select, dispatch } from '@wordpress/data';

const { select, dispatch } = wp.data;
import ComponentMap from './ComponentMap';

/**
* main component
Expand Down
10 changes: 5 additions & 5 deletions src/editor/components/fields/ThemerComponent.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import CanvasSpinner from '@wordpress/edit-site/build-module/components/canvas-spinner';
import { mergeWith, isEmpty } from 'lodash';
import {
Button,
Spinner,
__experimentalNavigatorProvider as NavigatorProvider,
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalNavigatorButton as NavigatorButton,
__experimentalNavigatorToParentButton as NavigatorToParentButton,
} from '@wordpress/components';
import { select, dispatch, subscribe } from '@wordpress/data';
import { useState } from '@wordpress/element';

import Preview from './Preview';
import SingleField from './Field';

const { select, dispatch, subscribe } = wp.data;
const { useState } = wp.element;

/**
* main component
*/
Expand Down Expand Up @@ -139,7 +139,7 @@ const ThemerComponent = () => {
if (isEmpty(config))
return (
<>
<CanvasSpinner />
<Spinner />
</>
);

Expand Down
3 changes: 0 additions & 3 deletions src/editor/store/actions.js

This file was deleted.

1 change: 0 additions & 1 deletion src/editor/store/effects.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/editor/store/index.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/editor/store/reducer.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/editor/store/selectors.js

This file was deleted.

Empty file removed src/entrypoints/frontend.js
Empty file.
10 changes: 6 additions & 4 deletions src/entrypoints/editor.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { registerPlugin } from '@wordpress/plugins';
import { render } from '@wordpress/element';
import { NAMESPACE } from '../editor/settings';
import ComponentWrapper from '../editor/components/ComponentWrapper';
import domReady from '@wordpress/dom-ready';

import '../editor/styles/styles.scss';
import { NAMESPACE } from './editor/settings';
import ComponentWrapper from './editor/components/ComponentWrapper';

import './editor/styles/styles.scss';

// Register the plugin.
wp.domReady(() => {
domReady(() => {
registerPlugin(NAMESPACE, {
icon: 'editor-paragraph',
render: ComponentWrapper,
Expand Down
1 change: 0 additions & 1 deletion webpack.config.js

This file was deleted.

0 comments on commit 1408f5b

Please sign in to comment.