I managed to create what I was after by using the Plugin Api
I created module with the file structure
mymodule
-src
-Plugin
-Block
Block.php
In block PHP I used the following
<?php
/**
* @file
* Contains \Drupal\mymodule\Plugin\Block\Basic.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
/**
*
* @Block(
* id = "basic_text",
* admin_label = @Translation("Basic MyModule Block (basic_text)")
* )
*/
class Basic extends BlockBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return array(
'mymodule_string' => $this->t('Enter text here'),
);
}
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state){
$form['mymodule_string_text'] = array(
'#type' => 'textarea',
'#title' => $this->t('Block contents'),
'#description' => $this->t('This text will appear in the block.'),
'#default_value' => $this->configuration['mymodule_string'],
);
$form['mymodule_style_selected'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => array(
0 => t('default'),
1 => t('black'),
2 => t('white'),
),
'#default_value' => $this->configuration['mymodule_style'],
);
return $form;
}
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['mymodule_string']
= $form_state->getValue('mymodule_string_text');
}
/**
* {@inheritdoc}
*/
public function build(){
return array(
'#type' => 'markup',
'#markup' => $this->configuration['mymodule_string'],
);
}
}
I haven't implemented the logic handling the style options but I can now place a pane using the IPE and configure the style pane by pane.