This repository has been archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5e5d9
commit d66b6ac
Showing
8 changed files
with
235 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
#Gutenly - A collection of must have Gutenberg blocks by Rhys Clay | ||
# Gutenly - A collection of must have Gutenberg blocks by Rhys Clay | ||
|
||
This project was bootstrapped with [Create Guten Block](https://github.com/ahmadawais/create-guten-block). | ||
|
||
## Current blocks | ||
|
||
* Image & Text : a simple, side by side image and text block | ||
* Feature list (in development): a list of features with nice thumbnails | ||
|
||
Getting started: | ||
|
||
## 👉 `npm start` | ||
- Use to compile and run the block in development mode. | ||
- Watches for any changes and reports back any errors in your code. | ||
## 👉 `npm start` | ||
|
||
* Use to compile and run the block in development mode. | ||
* Watches for any changes and reports back any errors in your code. | ||
|
||
## 👉 `npm run build` | ||
|
||
* Use to build production code for your block inside `dist` folder. | ||
* Runs once and reports back the gzip file sizes of the produced code. | ||
|
||
## 👉 `npm run build` | ||
- Use to build production code for your block inside `dist` folder. | ||
- Runs once and reports back the gzip file sizes of the produced code. | ||
## 👉 `npm run eject` | ||
|
||
## 👉 `npm run eject` | ||
- Use to eject your plugin out of `create-guten-block`. | ||
- Provides all the configurations so you can customize the project as you want. | ||
- It's a one-way street, `eject` and you have to maintain everything yourself. | ||
- You don't normally have to `eject` a project because by ejecting you lose the connection with `create-guten-block` and from there onwards you have to update and maintain all the dependencies on your own. | ||
* Use to eject your plugin out of `create-guten-block`. | ||
* Provides all the configurations so you can customize the project as you want. | ||
* It's a one-way street, `eject` and you have to maintain everything yourself. | ||
* You don't normally have to `eject` a project because by ejecting you lose the connection with `create-guten-block` and from there onwards you have to update and maintain all the dependencies on your own. | ||
|
||
--- | ||
--- |
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
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,109 @@ | ||
/** | ||
* BLOCK: Features | ||
* | ||
* A simple block to show some features | ||
*/ | ||
import icons from "../icons"; | ||
|
||
import { times } from "lodash"; | ||
/** | ||
* Internal block libraries | ||
*/ | ||
|
||
const { __ } = wp.i18n; // Import __() from wp.i18n | ||
const { registerBlockType, Editable, MediaUpload, BlockControls } = wp.blocks; | ||
const { Button, Toolbar, Tooltip, Dashicon } = wp.components; | ||
/** | ||
* Register: aa Gutenberg Block. | ||
* | ||
* Registers a new block provided a unique name and an object defining its | ||
* behavior. Once registered, the block is made editor as an option to any | ||
* editor interface where blocks are implemented. | ||
* | ||
* @param {string} name Block name. | ||
* @param {Object} settings Block settings. | ||
* @return {?WPBlock} The block, if it has been successfully | ||
* registered; otherwise `undefined`. | ||
*/ | ||
registerBlockType("cgb/block-features-list", { | ||
// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. | ||
title: __("Features", "CGB"), // Block title. | ||
icon: "heart", // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. | ||
category: "common", // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. | ||
keywords: [__("features"), __("Features")], | ||
attributes: { | ||
content: { | ||
type: "array", | ||
source: "query", | ||
selector: ".feature-text", | ||
query: { | ||
children: { | ||
source: "children" | ||
} | ||
}, | ||
default: [[], [], [], []] | ||
}, | ||
columns: { | ||
type: "number", | ||
default: 4 | ||
} | ||
}, | ||
|
||
// The "edit" property must be a valid function. | ||
edit({ attributes, setAttributes, className, focus, setFocus }) { | ||
const { content, columns } = attributes; | ||
|
||
return ( | ||
<div className={className}> | ||
<div className="row flex"> | ||
{times(columns, index => ( | ||
<div className="col-3" key={index}> | ||
<Editable | ||
tagName="div" | ||
multiline="p" | ||
value={content && content[index] && content[index].children} | ||
onChange={nextContent => { | ||
setAttributes({ | ||
content: [ | ||
...content.slice(0, index), | ||
{ children: nextContent }, | ||
...content.slice(index + 1) | ||
] | ||
}); | ||
}} | ||
focus={focus && focus.column === index} | ||
onFocus={() => setFocus({ column: index })} | ||
placeholder={__("New Feature")} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
|
||
<p>preview</p> | ||
<div className="row flex"> | ||
{times(columns, index => ( | ||
<div className="wp-block-column col-3" key={`column-${index}`}> | ||
<div>{content[index].children}</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}, | ||
|
||
// The "save" property must be specified and must be a valid function. | ||
save({ attributes, className }) { | ||
const { content, columns } = attributes; | ||
return ( | ||
<div className={className}> | ||
<div className="row flex"> | ||
{times(columns, index => ( | ||
<div className="wp-block-column col-3" key={`column-${index}`}> | ||
<div className="feature-text">{content[index].children}</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
}); |
File renamed without changes.
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.