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 faust blockset command #1585

Merged
merged 108 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
464b4c3
Add new block-support example project
josephfusco Aug 18, 2023
1be9609
Auto analyze new project
josephfusco Aug 18, 2023
377942f
Update dependencies
josephfusco Aug 18, 2023
dfea166
Remove hardcoded theme.json
josephfusco Aug 18, 2023
d1e2db5
Ignore globalStylesheet.css
josephfusco Sep 5, 2023
e7c9075
Reduce example to just block things
josephfusco Sep 6, 2023
929f37a
Add newline to EOF
josephfusco Sep 6, 2023
1bc1645
Reduce example
josephfusco Sep 6, 2023
b8627b6
Merge branch 'canary' into nojira-block-support-example
josephfusco Sep 6, 2023
29d10da
Update lockfile after merge
josephfusco Sep 6, 2023
4257d0e
Constrain layout using existing core class
josephfusco Sep 6, 2023
da3c5bf
Not being used
josephfusco Sep 6, 2023
b9a235c
Irrelevant comment
josephfusco Sep 6, 2023
34334ba
Merge branch 'canary' into nojira-block-support-example
josephfusco Sep 18, 2023
5f4c85a
Merge branch 'canary' into nojira-block-support-example
josephfusco Sep 20, 2023
fed767d
Scaffold out new plugin files
josephfusco Sep 20, 2023
e1dcc3a
Add new dependencies
josephfusco Sep 20, 2023
85b5b6e
Add blockset command
josephfusco Sep 20, 2023
cef820f
Add new command to block support example
josephfusco Sep 20, 2023
574078d
Register new REST endpoint to handle unzipping blocks
josephfusco Sep 20, 2023
92e62a9
Fix example project deps
josephfusco Sep 21, 2023
a9da48f
Fix namespace issue
josephfusco Sep 21, 2023
b9ba524
Refactor into testable functions
josephfusco Sep 21, 2023
6cb61e1
Mock custom block
josephfusco Sep 21, 2023
d00d39c
Ignore .faust
josephfusco Sep 21, 2023
1389e03
Fix namespacing issues in WP plugin
josephfusco Sep 21, 2023
9f8e189
Clean up comments
josephfusco Sep 21, 2023
df858e7
Improve readability
josephfusco Sep 21, 2023
c29d432
Add deps
josephfusco Sep 21, 2023
b1b1d3b
Add second block example to test blockset
josephfusco Sep 21, 2023
419bb8b
Export functions for tests
josephfusco Sep 21, 2023
762b762
Remove unused jest-dom in CLI package
josephfusco Sep 21, 2023
037a7c1
Remove unused package
josephfusco Sep 22, 2023
0e426cf
Add new utility function
josephfusco Sep 22, 2023
bbe7e55
Ignore for tests
josephfusco Sep 22, 2023
1e3745e
Refactor blockset command
josephfusco Sep 22, 2023
98bc082
New line at EOF
josephfusco Sep 22, 2023
88ccd17
Linting fixes
josephfusco Sep 22, 2023
2259219
Return true upon success
josephfusco Sep 22, 2023
80fead9
Use available logging methods
josephfusco Sep 22, 2023
b7383ad
Remove code already in handle_uploaded_blockset & setup translations
josephfusco Sep 22, 2023
b12f11f
Add missing dep
josephfusco Sep 22, 2023
87e6268
Linting fixes
josephfusco Sep 22, 2023
c88b4cb
Linting fixes
josephfusco Sep 22, 2023
7d8db16
Merge branch 'canary' into nojira-block-support-example
josephfusco Sep 25, 2023
c9dd1f8
Resolve merge conflicts
josephfusco Sep 25, 2023
d668c1c
Merge branch 'nojira-block-support-example' into nojira-add-blockset-…
josephfusco Sep 25, 2023
4a71216
Feat: Add compileBlocks step.
theodesp Sep 25, 2023
808d2a4
Automatically load custom blocks from uploads
josephfusco Sep 25, 2023
6a8657d
Fix enqueues from the uploads directory
josephfusco Sep 26, 2023
958ad70
Fix linting issues
josephfusco Sep 26, 2023
6150bb3
Feat: Check if project uses yarn when compiling blocks
theodesp Sep 26, 2023
086a656
Use enqueue_block_editor_assets to avoid unnecessary runs
josephfusco Sep 26, 2023
c4aa34d
Remove explicit registration using args
josephfusco Sep 26, 2023
e111cb2
Add required titles
josephfusco Sep 26, 2023
c3c6425
Correct the asset src for the blocks in uploads
josephfusco Sep 26, 2023
904b760
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco Sep 26, 2023
41f0199
Linting fixes
josephfusco Sep 26, 2023
92dd89c
Remove unused functions
josephfusco Sep 26, 2023
bbcf423
Deps: Add wp-scripts in peer deps.
theodesp Sep 27, 2023
e8d42a2
Chore: Add changeset.
theodesp Sep 27, 2023
02a0039
Deps: Update rimraf
theodesp Sep 27, 2023
ccf5928
Chore: Update deps.
theodesp Sep 27, 2023
c8737e9
Merge branch 'canary' into nojira-add-blockset-command
josephfusco Oct 1, 2023
7297578
Refactor: Update hasYarn
theodesp Oct 10, 2023
ac7bc05
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
theodesp Oct 10, 2023
65ee414
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 10, 2023
056f545
Chore: Update package-lock
theodesp Oct 10, 2023
5b0c8fc
Chore: update package-lock again
theodesp Oct 10, 2023
037d5ac
Chore: add missing export.
theodesp Oct 10, 2023
9a4a812
Chore: remove faust blockset from predev,prebuild
theodesp Oct 10, 2023
b03e8ec
Fix blocks missing from WPGraphQL & prevent unnecessary block registr…
josephfusco Oct 10, 2023
129e246
Fix linting issues
josephfusco Oct 10, 2023
f3a67b0
Example: Add block using `registerFaustBlock` helper
theodesp Oct 10, 2023
903eaee
Refactor: Update block comments
theodesp Oct 10, 2023
51533eb
Add plugin tests
josephfusco Oct 10, 2023
26e72cb
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco Oct 10, 2023
974984e
Add Plugin Tests (#1601)
josephfusco Oct 10, 2023
33b477d
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco Oct 10, 2023
32a265f
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 11, 2023
ff4c1be
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco Oct 11, 2023
4e9a51f
Remove orphaned test
josephfusco Oct 11, 2023
e3c60e1
Track possibleTypes & globalStylesheet generated files
josephfusco Oct 12, 2023
77fb05f
Build possibleTypes
josephfusco Oct 12, 2023
84e45c5
Add @wordpress/scripts to block-support-example
josephfusco Oct 12, 2023
8156972
Auto run blockset in block example
josephfusco Oct 12, 2023
e010712
Ignore Faust generated files
josephfusco Oct 12, 2023
b3105be
Remove previously tracked file
josephfusco Oct 12, 2023
5007a2f
Fix version regression from merge conflict
josephfusco Oct 12, 2023
81466fd
Refactor: Change block-C as block-B
theodesp Oct 13, 2023
ecf032c
Fix: Remove @ts-ignore comment.
theodesp Oct 13, 2023
6b0a23e
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 13, 2023
4333e77
CI/CD fix tests with faustwp-cli
theodesp Oct 13, 2023
4b3df8f
Example block support: Remove blockset.
theodesp Oct 13, 2023
7152ae2
Chore: Code review fixes.
theodesp Oct 16, 2023
666d9bf
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 17, 2023
d5367c0
Chore: add Component.fragments
theodesp Oct 17, 2023
c79ff97
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 17, 2023
a7f9c8e
Chore: Update package-lock.json
theodesp Oct 17, 2023
1125b6e
Chore: Add gql missing import.
theodesp Oct 17, 2023
7db0b8d
Tests: Update fromThemeJson.test snapshot.
theodesp Oct 17, 2023
7913f9b
Style: Add block styles in front-end
theodesp Oct 17, 2023
0f86e06
Styles: Consistent styles fixed.
theodesp Oct 17, 2023
a3c0ffc
CI/CD: Fix test cases.
theodesp Oct 17, 2023
b214c75
Test: Update CoreCode test snapshot.
theodesp Oct 17, 2023
1fd4356
CI/CD: Update types in Toolbar.test.tsx
theodesp Oct 17, 2023
3db3d41
CI/CD: Remove examples/next/block-support from bundle analysis.
theodesp Oct 17, 2023
b641ca8
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp Oct 18, 2023
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
8 changes: 8 additions & 0 deletions .changeset/rotten-hats-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@faustwp/cli': minor
'@faustwp/wordpress-plugin': minor
---

Add blockset command in @faust/cli and faustwp plugin.

Add your blocks inside `wp-blocks` folder. Then run `faust blockset` to compile and upload the blocks into WordPress. Blocks will be available in the editor.
1 change: 0 additions & 1 deletion .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
matrix:
next-dir: [
'examples/next/faustwp-getting-started',
'examples/next/block-support'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this one is problematic.

]

runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion examples/next/block-support/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
possibleTypes.json
.faust
globalStylesheet.css
possibleTypes.json
5 changes: 3 additions & 2 deletions examples/next/block-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"prebuild": "faust generatePossibleTypes && faust generateGlobalStylesheet",
"dev": "faust dev",
"build": "faust build",
"blockset": "faust blockset",
"start": "faust start"
},
"dependencies": {
"@apollo/client": "^3.6.6",
"@faustwp/blocks": "2.0.0",
"@faustwp/cli": "1.0.1",
"@faustwp/core": "1.1.0",
"@faustwp/cli": "1.1.4",
"@faustwp/core": "1.1.2",
"@wordpress/base-styles": "^4.26.0",
"@wordpress/block-library": "^7.19.0",
"classnames": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/next/block-support/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
import { WordPressBlocksProvider, fromThemeJson } from '@faustwp/blocks';
import { FaustProvider } from '@faustwp/core';
import blocks from '../wp-blocks';
// import '../styles/blocks.scss'; // <-- Import block styles from WordPress.
import '../styles/blocks.scss'; // <-- Import block styles from WordPress.
import '../globalStylesheet.css'; // <-- Generated by @faustwp/cli

export default function MyApp({ Component, pageProps }) {
Expand Down
2 changes: 2 additions & 0 deletions examples/next/block-support/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
@import '@wordpress/base-styles/breakpoints';
@import '@wordpress/block-library/src/style';
@import '@wordpress/block-library/src/theme';

@import '../wp-blocks/block-b/style.scss'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include block style here is next.js hates importing global styles within the components.

17 changes: 17 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "create-block/block-a",
"version": "0.1.0",
"title": "Block A",
"category": "widgets",
"icon": "smiley",
"description": "Example static block scaffolded with Create Block tool.",
"supports": {
"html": false
},
"textdomain": "block-a",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css"
}
38 changes: 38 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Retrieves the translation of text.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/
*/
import { __ } from '@wordpress/i18n';

/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps
*/
import { useBlockProps } from '@wordpress/block-editor';

/**
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
* Those files can contain any CSS code that gets applied to the editor.
*
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
*/
import './editor.scss';

/**
* The edit function describes the structure of your block in the context of the
* editor. This represents what the editor will render when the block is used.
*
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit
*
* @return {WPElement} Element to render.
*/
export default function Edit() {
return (
<p {...useBlockProps()}>
{__('Block A – hello from the editor!', 'block-a')}
</p>
);
}
9 changes: 9 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* The following styles get applied inside the editor only.
*
* Replace them with your own styles or remove the file completely.
*/

.wp-block-create-block-block-a {
border: 1px dotted #f00;
}
39 changes: 39 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Registers a new block provided a unique name and an object defining its behavior.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
*/
import { registerBlockType } from '@wordpress/blocks';

/**
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
* All files containing `style` keyword are bundled together. The code used
* gets applied both to the front of your site and to the editor.
*
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
*/
import './style.scss';

/**
* Internal dependencies
*/
import Edit from './edit';
import save from './save';
import metadata from './block.json';

/**
* Every block starts by registering a new block type definition.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
*/
registerBlockType(metadata.name, {
title: 'Block A',
josephfusco marked this conversation as resolved.
Show resolved Hide resolved
/**
* @see ./edit.js
*/
edit: Edit,
/**
* @see ./save.js
*/
save,
});
31 changes: 31 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Retrieves the translation of text.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/
*/
import { __ } from '@wordpress/i18n';

/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps
*/
import { useBlockProps } from '@wordpress/block-editor';

/**
* The save function defines the way in which the different attributes should
* be combined into the final markup, which is then serialized by the block
* editor into `post_content`.
*
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#save
*
* @return {WPElement} Element to render.
*/
export default function save() {
return (
<p {...useBlockProps.save()}>
{__('Block A – hello from the saved content!', 'block-a')}
</p>
);
}
12 changes: 12 additions & 0 deletions examples/next/block-support/wp-blocks/block-a/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* The following styles get applied both on the front of your site
* and in the editor.
*
* Replace them with your own styles or remove the file completely.
*/

.wp-block-create-block-block-a {
background-color: #21759b;
color: #fff;
padding: 2px;
}
38 changes: 38 additions & 0 deletions examples/next/block-support/wp-blocks/block-b/Component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { gql } from '@apollo/client';

function Component({ style, attributes, children, ...props }) {
const styles = {
...style,
};
const cssClassName = 'create-block-block-b-message';
return (
<div
style={styles}
className={cssClassName}
dangerouslySetInnerHTML={{ __html: attributes.message }}
/>
);
}

Component.fragments = {
key: `CreateBlockBlockBFragment`,
entry: gql`
fragment CreateBlockBlockBFragment on CreateBlockBlockB {
attributes {
message
}
}
`,
};

Component.config = {
name: 'CreateBlockBlockB',
editorFields: {
message: {
type: 'string',
label: 'My Message',
location: 'editor',
},
},
};
export default Component;
23 changes: 23 additions & 0 deletions examples/next/block-support/wp-blocks/block-b/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "create-block/block-b",
"version": "0.1.0",
"title": "Block B",
"category": "widgets",
"icon": "smiley",
"description": "Example static block scaffolded with Create Block tool.",
"supports": {
"html": false
},
"attributes": {
"message": {
"type": "string",
"default": "Hello World"
}
},
"textdomain": "block-b",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css"
}
13 changes: 13 additions & 0 deletions examples/next/block-support/wp-blocks/block-b/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { registerFaustBlock } from '@faustwp/block-editor-utils';
import './style.scss';
import BlockB from './Component.js'
/**
* Block.json metadata
*/
import metadata from './block.json';
/**
* Register React block on the Block Editor
*/
registerFaustBlock(BlockB, {
blockJson: metadata
});
15 changes: 15 additions & 0 deletions examples/next/block-support/wp-blocks/block-b/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* The following styles get applied both on the front of your site
* and in the editor.
*
* Replace them with your own styles or remove the file completely.
*/

.wp-block-create-block-block-b {
color: #333;
padding: 2px;
}

.create-block-block-b-message {
border: 1px solid pink;
}
2 changes: 2 additions & 0 deletions examples/next/block-support/wp-blocks/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CoreBlocks } from '@faustwp/blocks';
import BlockB from './block-b/Component.js';

export default {
CoreParagraph: CoreBlocks.CoreParagraph,
Expand All @@ -12,4 +13,5 @@ export default {
CoreButton: CoreBlocks.CoreButton,
CoreButtons: CoreBlocks.CoreButtons,
CoreHeading: CoreBlocks.CoreHeading,
CreateBlockBlockB: BlockB,
};
2 changes: 2 additions & 0 deletions examples/next/block-support/wp-templates/front-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Component.query = gql`
${blocks.CoreSeparator.fragments.entry}
${blocks.CoreList.fragments.entry}
${blocks.CoreHeading.fragments.entry}
${blocks.CreateBlockBlockB.fragments.entry}
query GetPage(
$databaseId: ID!
$asPreview: Boolean = false
Expand All @@ -56,6 +57,7 @@ Component.query = gql`
...${blocks.CoreSeparator.fragments.key}
...${blocks.CoreList.fragments.key}
...${blocks.CoreHeading.fragments.key}
...${blocks.CreateBlockBlockB.fragments.key}
}
}
}
Expand Down
Loading
Loading