Review feedback.

This commit is contained in:
Rachel Fenichel
2019-10-30 15:58:53 -07:00
parent dd33d772f7
commit 46fad66ab1
5 changed files with 16 additions and 19 deletions

View File

@@ -1043,8 +1043,6 @@ Blockly.BlockSvg.prototype.applyColour = function() {
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
// TODO: Decide whether to make icon and field applyColour take in a
// colourer object.
icons[i].applyColour();
}

View File

@@ -63,9 +63,9 @@ Blockly.blockRendering.PathObject = function(root) {
/**
* The style object to use when colouring block paths.
* @type {!Blockly.Theme.BlockStyle}
* @public
* @package
*/
this.style = Blockly.Theme.createBlockStyle('#0000000');
this.style = Blockly.Theme.createBlockStyle('#000000');
};
/**

View File

@@ -25,6 +25,7 @@
goog.provide('Blockly.geras.PathObject');
goog.require('Blockly.blockRendering.IPathObject');
goog.require('Blockly.Theme');
goog.require('Blockly.utils.dom');
goog.require('Blockly.utils.object');
@@ -73,14 +74,14 @@ Blockly.geras.PathObject = function(root) {
* @type {string}
* @package
*/
this.darkColour = '#000000';
this.colourDark = '#000000';
/**
* The style object to use when colouring block paths.
* @type {!Blockly.Theme.BlockStyle}
* @public
* @package
*/
this.style = Blockly.Theme.createBlockStyle('#0000000');
this.style = Blockly.Theme.createBlockStyle('#000000');
};
/**

View File

@@ -38,12 +38,12 @@ goog.require('Blockly.utils.colour');
Blockly.Theme = function(blockStyles, categoryStyles, opt_componentStyles) {
/**
* The block styles map.
* @type {!Object.<string, Blockly.Theme.BlockStyle>}
* @type {!Object.<string, !Blockly.Theme.BlockStyle>}
* @private
*/
this.blockStyles_ = {};
// Make sure all styles are valid before insterting them into the map.
// Make sure all styles are valid before inserting them into the map.
this.setAllBlockStyles(blockStyles);
/**
@@ -106,18 +106,14 @@ Blockly.Theme.prototype.getAllBlockStyles = function() {
* if no style with the given name was found.
*/
Blockly.Theme.prototype.getBlockStyle = function(blockStyleName) {
var defaultStyle = Blockly.Theme.createBlockStyle('#000000');
if (blockStyleName == null) {
return defaultStyle;
}
return this.blockStyles_[blockStyleName] || defaultStyle;
return this.blockStyles_[blockStyleName || ''] ||
Blockly.Theme.createBlockStyle('#000000');
};
/**
* Overrides or adds a style to the blockStyles map.
* @param {string} blockStyleName The name of the block style.
* @param {Blockly.Theme.BlockStyle} blockStyle The block style.
* @package
*/
Blockly.Theme.prototype.setBlockStyle = function(blockStyleName, blockStyle) {
blockStyle = Blockly.Theme.validatedBlockStyle(blockStyle);
@@ -159,7 +155,7 @@ Blockly.Theme.createBlockStyle = function(colour) {
/**
* Get a full block style object based on the input style object. Populate
* any missing values.
* @param {!Blockly.Theme.BlockStyle} blockStyle A full or partial block
* @param {Blockly.Theme.BlockStyle} blockStyle A full or partial block
* style object.
* @return {!Blockly.Theme.BlockStyle} A full block style object, with all
* required properties populated.
@@ -168,11 +164,13 @@ Blockly.Theme.createBlockStyle = function(colour) {
Blockly.Theme.validatedBlockStyle = function(blockStyle) {
// Make a new object with all of the same properties.
var valid = {};
Blockly.utils.object.mixin(valid, blockStyle);
if (blockStyle) {
Blockly.utils.object.mixin(valid, blockStyle);
}
// Validate required properties.
var parsedColour = Blockly.utils.colour.parseBlockColour(
valid.colourPrimary || '#000000');
valid.colourPrimary || '#000');
valid.colourPrimary = parsedColour.hex;
valid.colourSecondary = valid.colourSecondary ||
Blockly.utils.colour.blend('#fff', valid.colourPrimary, 0.6) ||

View File

@@ -219,7 +219,7 @@ Blockly.utils.colour.names = {
* or a message reference string pointing to one of those two values.
* @return {{hue: ?number, hex: string}} An object containing the colour as
* a #RRGGBB string, and the hue if the input was an HSV hue value.
* @throws {Error} If If the colour cannot be parsed.
* @throws {Error} If the colour cannot be parsed.
*/
Blockly.utils.colour.parseBlockColour = function(colour) {
var dereferenced = (typeof colour == 'string') ?