Added ActivitiesList block

This commit is contained in:
Justin Foell
2021-03-26 14:14:57 -05:00
parent eddba0e2c3
commit a6838be1eb
9 changed files with 181 additions and 12 deletions
+18
View File
@@ -0,0 +1,18 @@
{
"name": "wp-strava/activitieslist",
"title": "Strava Activities List",
"category": "embed",
"icon": "editor-ul",
"description": "List of Strava Activities",
"keywords": [ "activity", "ride" ],
"textdomain": "wp-strava",
"attributes": {
"som": {
"type": "string",
"default": null
}
},
"editorScript": "file:../../../build/index.js",
"editorStyle": "file:../../../build/editor.css",
"style": "file:../../../build/style.css"
}
+52
View File
@@ -0,0 +1,52 @@
/* global wp, wpStrava */
import SOMOverride from '../components/som-override';
const { __ } = wp.i18n;
const { Component } = wp.element;
const { InspectorControls } = wp.editor;
const { PanelBody, ToggleControl, ServerSideRender } = wp.components;
class Edit extends Component {
constructor() {
super( ...arguments );
this.overrideSOM = this.overrideSOM.bind( this );
this.state = {
som: this.props.attributes.som,
};
}
overrideSOM( newSOM ) {
this.setState( { som: newSOM } );
this.props.setAttributes( { som: newSOM } );
}
render() {
const {
som
} = this.state;
return (
<>
<ServerSideRender
block="wp-strava/activitieslist"
attributes={ {
som: som,
} }
/>
<InspectorControls>
<PanelBody
title={ __( 'Display Options', 'wp-strava' ) }
>
<SOMOverride
onChange={ this.overrideSOM }
/>
</PanelBody>
</InspectorControls>
</>
);
}
}
export default Edit;
+9
View File
@@ -0,0 +1,9 @@
/* global wp, wpStrava */
import { registerBlockType } from '@wordpress/blocks';
import edit from './edit';
import metadata from './block.json';
metadata.edit = edit;
metadata.save = () => null;
registerBlockType( metadata.name, metadata );