[zelos] Set dropdown div colour to match block colour (#3462)

* Set dropdown div colour to match block colour
This commit is contained in:
Sam El-Husseini
2019-11-27 09:30:29 -08:00
committed by GitHub
parent c2bf971947
commit b038c1cef5
5 changed files with 30 additions and 1 deletions

View File

@@ -595,7 +595,8 @@ Blockly.Css.CONTENT = [
'.blocklyWidgetDiv .goog-menuitem-content,',
'.blocklyDropDownDiv .goog-menuitem-content {',
'font: normal 13px Arial, sans-serif;',
'font-family: Arial, sans-serif;',
'font-size: 13px;',
'}',
'.blocklyWidgetDiv .goog-menuitem-content {',

View File

@@ -256,6 +256,14 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
Blockly.utils.dom.addClass(
/** @type {!Element} */ (this.menu_.getElement()), 'blocklyDropdownMenu');
if (this.constants_.FIELD_DROPDOWN_COLOURED_DIV) {
var primaryColour = (this.sourceBlock_.isShadow()) ?
this.sourceBlock_.getParent().getColour() :
this.sourceBlock_.getColour();
Blockly.DropDownDiv.setColour(primaryColour,
this.sourceBlock_.style.colourTertiary);
}
Blockly.DropDownDiv.showPositionedByField(
this, this.dropdownDispose_.bind(this));

View File

@@ -300,6 +300,13 @@ Blockly.blockRendering.ConstantProvider = function() {
*/
this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT = this.FIELD_BORDER_RECT_HEIGHT;
/**
* Whether or not a dropdown field's div should be coloured to match the
* block colours.
* @type {boolean}
*/
this.FIELD_DROPDOWN_COLOURED_DIV = false;
/**
* Whether or not a dropdown field uses a text or SVG arrow.
* @type {boolean}

View File

@@ -212,6 +212,11 @@ Blockly.zelos.ConstantProvider = function() {
*/
this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT = 8 * this.GRID_UNIT;
/**
* @override
*/
this.FIELD_DROPDOWN_COLOURED_DIV = true;
/**
* @override
*/

View File

@@ -166,6 +166,14 @@ Blockly.zelos.Renderer.prototype.getCSS_ = function() {
selector + ' .blocklyDropdownText {',
'fill: #fff !important;',
'}',
// Widget and Dropdown Div
selector + '.blocklyWidgetDiv .goog-menuitem,',
selector + '.blocklyDropDownDiv .goog-menuitem {',
'font-family: ' + constants.FIELD_TEXT_FONTFAMILY + ';',
'}',
selector + '.blocklyDropDownDiv .goog-menuitem-content {',
'color: #fff;',
'}',
// Connection highlight.
selector + ' .blocklyHighlightedConnectionPath {',