-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #34 - start making use of the SelectTextControlCombo block for …
…formats and orderby attributes
- Loading branch information
1 parent
2370402
commit 951aad3
Showing
3 changed files
with
70 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Implements a Select Control / Text control combo where the | ||
* text value overrides the option(s) selected from the SelectControl. | ||
* | ||
* | ||
* @copyright (C) Copyright Bobbing Wide 2020 | ||
* @author Herb Miller @bobbingwide | ||
*/ | ||
|
||
|
||
const { Component, Fragment } = wp.element; | ||
const { SelectControl, TextControl } = wp.components; | ||
|
||
export class SelectTextControlCombo extends Component { | ||
constructor() { | ||
super(...arguments); | ||
|
||
} | ||
|
||
renderSelect( props ) { | ||
|
||
//var options = formats.map((format) => this.formatsOption(format)); | ||
var custom_label = `Custom value: ${this.props.label}`; | ||
return ( | ||
<Fragment> | ||
<SelectControl label={this.props.label} value={this.props.value} | ||
options={this.props.options} | ||
onChange={this.props.onChange} | ||
/> | ||
<TextControl label={custom_label} hideLabelFromVision={ true } value={this.props.value} onChange={this.props.onChange} /> | ||
</Fragment> | ||
); | ||
|
||
} | ||
|
||
|
||
|
||
/** | ||
* Map the format_option to a select list option | ||
* | ||
* @param format | ||
* @returns {{label: *, value: *}} | ||
*/ | ||
formatOption( format ) { | ||
return( { value: format.value, label: format.label }); | ||
} | ||
|
||
render() { | ||
return( this.renderSelect() | ||
); | ||
} | ||
} |
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