mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-20 07:04:24 +09:00
First pass, buttons not rendering
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* global wp, wpStrava */
|
||||
import EmbedPlaceholder from './embed-placeholder';
|
||||
import EmbedControls from './embed-controls';
|
||||
import SOMOverride from './som-override';
|
||||
|
||||
const { __ } = wp.i18n;
|
||||
const { Component } = wp.element;
|
||||
@@ -98,6 +99,9 @@ class Edit extends Component {
|
||||
checked={ displayMarkers }
|
||||
onChange={ (checked ) => this.toggleDisplayMarkers( checked ) }
|
||||
/>
|
||||
<SOMOverride
|
||||
onChange={ ( value ) => this.props.setAttributes( { som: value } ) }
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
</>
|
||||
|
||||
@@ -18,7 +18,11 @@ registerBlockType( 'wp-strava/activity', {
|
||||
displayMarkers: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
som: {
|
||||
type: 'string',
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
edit,
|
||||
save: () => null,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import mapValues from 'lodash';
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
} from '@wordpress/components';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
const SOM_PRESETS = {
|
||||
'english': __( 'English', 'wp-strava' ),
|
||||
'metric': __( 'Metric', 'wp-strava' ),
|
||||
};
|
||||
|
||||
export default function SOMOverride( {
|
||||
onChange,
|
||||
} ) {
|
||||
|
||||
function updateSOM( newSOM ) {
|
||||
return () => {
|
||||
onChange( { som: newSOM } );
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="block-editor-som-control">
|
||||
<ButtonGroup aria-label={ __( 'System of Measure (override from Settings)' ) }>
|
||||
{ mapValues( SOM_PRESETS, ( key, label ) => {
|
||||
return (
|
||||
<Button
|
||||
key={ key }
|
||||
isSmall
|
||||
isPrimary={ true }
|
||||
isPressed={ true }
|
||||
onClick={ updateSOM(
|
||||
key
|
||||
) }
|
||||
>
|
||||
{ label }
|
||||
</Button>
|
||||
);
|
||||
} ) }
|
||||
</ButtonGroup>
|
||||
<Button isSmall onClick={ updateSOM() }>
|
||||
{ __( 'Reset' ) }
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user