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

DevDocs: add a Gutenberg blocks section #26065

Merged
merged 10 commits into from
Jul 18, 2018
8 changes: 8 additions & 0 deletions client/devdocs/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ const devdocs = {
context.primary = React.createElement( DevWelcome, {} );
next();
},

// Gutenberg Blocks
gutenbergBlocks: function( context, next ) {
context.primary = (
<AsyncLoad component={ context.params.component } require="./design/gutenberg-blocks" />
);
next();
},
};

export default devdocs;
27 changes: 27 additions & 0 deletions client/devdocs/design/gutenberg-blocks.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @format */

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

If we add /** @format */ above this line, prettier, will handle whitespace formatting for us.

* External dependencies
*/
import React from 'react';
import classnames from 'classnames';

/**
* Internal dependencies
*/
import DocumentHead from 'components/data/document-head';
import Main from 'components/main';
import ReadmeViewer from 'components/readme-viewer';

export default class GutenbergBlocks extends React.Component {
render() {
const className = classnames( 'devdocs', 'devdocs__gutenberg-blocks' );

return (
<Main className={ className }>
<DocumentHead title="Gutenberg Blocks" />
<ReadmeViewer readmeFilePath="/client/devdocs/gutenberg-blocks/README.md" />
</Main>
);
}
}
13 changes: 13 additions & 0 deletions client/devdocs/gutenberg-blocks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Gutenberg Blocks
====

[Gutenberg](https://wordpress.org/gutenberg/) is the new publishing experience for WordPress.

The Gutenberg editor uses
[blocks](https://github.com/WordPress/gutenberg/blob/master/blocks/README.md) to create all types
of content. A Gutenberg block is the abstract term used to describe units of markup that,
composed together, form the content or layout of a webpage.

Calypso provides all the
[built-in Gutenberg blocks](https://github.com/WordPress/gutenberg/tree/master/core-blocks), so
they can be used in any React component.
11 changes: 11 additions & 0 deletions client/devdocs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ export default function() {
);
page( '/devdocs/start', controller.pleaseLogIn, makeLayout, clientRender );
page( '/devdocs/welcome', controller.sidebar, controller.welcome, makeLayout, clientRender );

if ( config.isEnabled( 'devdocs/gutenberg-blocks' ) ) {
page(
'/devdocs/gutenberg-blocks',
controller.sidebar,
controller.gutenbergBlocks,
makeLayout,
clientRender
);
}

page( '/devdocs/:path*', controller.sidebar, controller.singleDoc, makeLayout, clientRender );
}
}
10 changes: 10 additions & 0 deletions client/devdocs/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Sidebar from 'layout/sidebar';
import SidebarHeading from 'layout/sidebar/heading';
import SidebarMenu from 'layout/sidebar/menu';
import SidebarItem from 'layout/sidebar/item';
import { isEnabled } from 'config';

export default class DevdocsSidebar extends React.PureComponent {
static displayName = 'DevdocsSidebar';
Expand Down Expand Up @@ -103,6 +104,15 @@ export default class DevdocsSidebar extends React.PureComponent {
link="/devdocs/blocks"
selected={ this.isItemSelected( '/devdocs/blocks', false ) }
/>
{ isEnabled( 'devdocs/gutenberg-blocks' ) && (
<SidebarItem
className="devdocs__navigation-item"
icon="grid"
label="Gutenberg Blocks"
link="/devdocs/gutenberg-blocks"
selected={ this.isItemSelected( '/devdocs/gutenberg-blocks', false ) }
/>
) }
<SidebarItem
className="devdocs__navigation-item"
icon="code"
Expand Down
1 change: 1 addition & 0 deletions config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"devdocs": true,
"devdocs/redirect-loggedout-homepage": true,
"devdocs/components-usage-stats": false,
"devdocs/gutenberg-blocks": true,
"dev/test-helper": true,
"dev/preferences-helper": true,
"domains/cctlds": true,
Expand Down
1 change: 1 addition & 0 deletions config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"devdocs": true,
"devdocs/redirect-loggedout-homepage": true,
"devdocs/components-usage-stats": false,
"devdocs/gutenberg-blocks": true,
"gdpr-banner": false,
"google-analytics": false,
"google-my-business": false,
Expand Down