Skip to content

Commit

Permalink
chore: rebuild and format
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-fenichel committed Jan 13, 2022
1 parent f659919 commit c1728df
Show file tree
Hide file tree
Showing 14 changed files with 370 additions and 103 deletions.
13 changes: 8 additions & 5 deletions core/renderers/geras/highlight_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class HighlightConstantProvider {
'a', '0 0,0', radius + offset,
svgPaths.point(radius + offset, radius + offset));

const pathBottomLtr = svgPaths.moveBy(distance45outside, -distance45outside) +
const pathBottomLtr =
svgPaths.moveBy(distance45outside, -distance45outside) +
svgPaths.arc(
'a', '0 0,0', radius + offset,
svgPaths.point(
Expand Down Expand Up @@ -205,11 +206,12 @@ class HighlightConstantProvider {
const width = this.constantProvider.TAB_WIDTH;
const height = this.constantProvider.TAB_HEIGHT;

// This is how much of the vertical block edge is actually drawn by the puzzle
// tab.
// This is how much of the vertical block edge is actually drawn by the
// puzzle tab.
const verticalOverlap = 2.5;

const highlightRtlUp = svgPaths.moveBy(-2, -height + verticalOverlap + 0.9) +
const highlightRtlUp =
svgPaths.moveBy(-2, -height + verticalOverlap + 0.9) +
svgPaths.lineTo(width * -0.45, -2.1);

const highlightRtlDown = svgPaths.lineOnAxis('v', verticalOverlap) +
Expand All @@ -226,7 +228,8 @@ class HighlightConstantProvider {
const highlightLtrUp = svgPaths.lineOnAxis('v', -1.5) +
svgPaths.moveBy(width * -0.92, -0.5) +
svgPaths.curve(
'q', [svgPaths.point(width * -0.19, -5.5), svgPaths.point(0, -11)]) +
'q',
[svgPaths.point(width * -0.19, -5.5), svgPaths.point(0, -11)]) +
svgPaths.moveBy(width * 0.92, 1);

const highlightLtrDown =
Expand Down
10 changes: 6 additions & 4 deletions core/renderers/geras/highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ class Highlighter {
} else if (Types.isHat(elem)) {
this.steps_ += this.startPaths_.path(this.RTL_);
} else if (Types.isSpacer(elem) && elem.width !== 0) {
// The end point of the spacer needs to be offset by the highlight amount.
// So instead of using the spacer's width for a relative horizontal, use
// its width and position for an absolute horizontal move.
// The end point of the spacer needs to be offset by the highlight
// amount. So instead of using the spacer's width for a relative
// horizontal, use its width and position for an absolute horizontal
// move.
this.steps_ += svgPaths.lineOnAxis(
'H', elem.xPos + elem.width - this.highlightOffset_);
}
Expand Down Expand Up @@ -252,7 +253,8 @@ class Highlighter {
if (!this.RTL_) {
const topRow = this.info_.topRow;
if (Types.isLeftRoundedCorner(topRow.elements[0])) {
this.steps_ += svgPaths.lineOnAxis('V', this.outsideCornerPaths_.height);
this.steps_ +=
svgPaths.lineOnAxis('V', this.outsideCornerPaths_.height);
} else {
this.steps_ +=
svgPaths.lineOnAxis('V', topRow.capline + this.highlightOffset_);
Expand Down
39 changes: 24 additions & 15 deletions core/renderers/geras/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class RenderInfo extends BaseRenderInfo {

// The minimum height of the bottom row is smaller in Geras than in other
// renderers, because the dark path adds a pixel.
// If one of the row's elements has a greater height this will be overwritten
// in the compute pass.
// If one of the row's elements has a greater height this will be
// overwritten in the compute pass.
if (!followsStatement) {
this.bottomRow.minHeight =
this.constants_.MEDIUM_PADDING - this.constants_.DARK_PATH_OFFSET;
Expand All @@ -97,8 +97,8 @@ class RenderInfo extends BaseRenderInfo {
activeRow.elements.push(new ExternalValueInput(this.constants_, input));
activeRow.hasExternalInput = true;
} else if (input.type === inputTypes.DUMMY) {
// Dummy inputs have no visual representation, but the information is still
// important.
// Dummy inputs have no visual representation, but the information is
// still important.
activeRow.minHeight =
Math.max(activeRow.minHeight, this.constants_.DUMMY_INPUT_MIN_HEIGHT);
activeRow.hasDummyInput = true;
Expand Down Expand Up @@ -138,7 +138,8 @@ class RenderInfo extends BaseRenderInfo {
}
row.elements.push(oldElems[oldElems.length - 1]);
if (row.endsWithElemSpacer()) {
let spacing = this.getInRowSpacing_(oldElems[oldElems.length - 1], null);
let spacing =
this.getInRowSpacing_(oldElems[oldElems.length - 1], null);
if (hasExternalInputs && row.hasDummyInput) {
spacing += this.constants_.TAB_WIDTH;
}
Expand Down Expand Up @@ -182,7 +183,8 @@ class RenderInfo extends BaseRenderInfo {
if (Types.isHat(prev)) {
return this.constants_.NO_PADDING;
}
// Establish a minimum width for a block with a previous or next connection.
// Establish a minimum width for a block with a previous or next
// connection.
if (Types.isPreviousOrNextConnection(prev)) {
return this.constants_.LARGE_PADDING;
}
Expand Down Expand Up @@ -255,9 +257,11 @@ class RenderInfo extends BaseRenderInfo {
if (Types.isPreviousConnection(next)) {
return next.notchOffset;
} else if (Types.isNextConnection(next)) {
// Next connections are shifted slightly to the left (in both LTR and RTL)
// to make the dark path under the previous connection show through.
const offset = (this.RTL ? 1 : -1) * this.constants_.DARK_PATH_OFFSET / 2;
// Next connections are shifted slightly to the left (in both LTR and
// RTL) to make the dark path under the previous connection show
// through.
const offset =
(this.RTL ? 1 : -1) * this.constants_.DARK_PATH_OFFSET / 2;
return next.notchOffset + offset;
}
}
Expand All @@ -267,9 +271,11 @@ class RenderInfo extends BaseRenderInfo {
if (Types.isPreviousConnection(next)) {
return next.notchOffset - this.constants_.CORNER_RADIUS;
} else if (Types.isNextConnection(next)) {
// Next connections are shifted slightly to the left (in both LTR and RTL)
// to make the dark path under the previous connection show through.
const offset = (this.RTL ? 1 : -1) * this.constants_.DARK_PATH_OFFSET / 2;
// Next connections are shifted slightly to the left (in both LTR and
// RTL) to make the dark path under the previous connection show
// through.
const offset =
(this.RTL ? 1 : -1) * this.constants_.DARK_PATH_OFFSET / 2;
return next.notchOffset - this.constants_.CORNER_RADIUS + offset;
}
}
Expand Down Expand Up @@ -344,7 +350,8 @@ class RenderInfo extends BaseRenderInfo {
if (Types.isField(elem) || Types.isIcon(elem)) {
result += (elem.height / 2);
if ((row.hasInlineInput || row.hasStatement) &&
elem.height + this.constants_.TALL_INPUT_FIELD_OFFSET_Y <= row.height) {
elem.height + this.constants_.TALL_INPUT_FIELD_OFFSET_Y <=
row.height) {
result += this.constants_.TALL_INPUT_FIELD_OFFSET_Y;
}
} else if (Types.isInlineInput(elem)) {
Expand Down Expand Up @@ -375,7 +382,8 @@ class RenderInfo extends BaseRenderInfo {
this.alignStatementRow_(
/** @type {!InputRow} */ (row));
}
if (prevInput && prevInput.hasStatement && row.width < prevInput.width) {
if (prevInput && prevInput.hasStatement &&
row.width < prevInput.width) {
row.nextRightEdge = prevInput.width;
} else {
nextRightEdge = row.width;
Expand Down Expand Up @@ -410,7 +418,8 @@ class RenderInfo extends BaseRenderInfo {
getDesiredRowWidth_(row) {
// Limit the width of a statement row when a block is inline.
if (this.isInline && row.hasStatement) {
return this.statementEdge + this.constants_.MAX_BOTTOM_WIDTH + this.startX;
return this.statementEdge + this.constants_.MAX_BOTTOM_WIDTH +
this.startX;
}
return super.getDesiredRowWidth_(row);
}
Expand Down
4 changes: 2 additions & 2 deletions core/renderers/geras/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class Renderer extends BaseRenderer {
}

/**
* Get the renderer's highlight constant provider. We assume that when this is
* called, the renderer has already been initialized.
* Get the renderer's highlight constant provider. We assume that when this
* is called, the renderer has already been initialized.
* @return {!HighlightConstantProvider} The highlight constant
* provider.
* @package
Expand Down
9 changes: 6 additions & 3 deletions core/renderers/thrasos/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class RenderInfo extends BaseRenderInfo {
}
row.elements.push(oldElems[oldElems.length - 1]);
if (row.endsWithElemSpacer()) {
let spacing = this.getInRowSpacing_(oldElems[oldElems.length - 1], null);
let spacing =
this.getInRowSpacing_(oldElems[oldElems.length - 1], null);
if (hasExternalInputs && row.hasDummyInput) {
spacing += this.constants_.TAB_WIDTH;
}
Expand Down Expand Up @@ -129,7 +130,8 @@ class RenderInfo extends BaseRenderInfo {
if (Types.isHat(prev)) {
return this.constants_.NO_PADDING;
}
// Establish a minimum width for a block with a previous or next connection.
// Establish a minimum width for a block with a previous or next
// connection.
if (Types.isPreviousOrNextConnection(prev)) {
return this.constants_.LARGE_PADDING;
}
Expand Down Expand Up @@ -274,7 +276,8 @@ class RenderInfo extends BaseRenderInfo {

let result = row.yPos;
if (Types.isField(elem) && row.hasStatement) {
const offset = this.constants_.TALL_INPUT_FIELD_OFFSET_Y + elem.height / 2;
const offset =
this.constants_.TALL_INPUT_FIELD_OFFSET_Y + elem.height / 2;
result += offset;
} else {
result += (row.height / 2);
Expand Down
43 changes: 23 additions & 20 deletions core/renderers/zelos/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ class ConstantProvider extends BaseConstantProvider {
this.selectedGlowFilter_ = null;

/**
* The ID of the replacement glow filter, or the empty string if no filter is
* set.
* The ID of the replacement glow filter, or the empty string if no filter
* is set.
* @type {string}
* @package
*/
Expand Down Expand Up @@ -440,7 +440,8 @@ class ConstantProvider extends BaseConstantProvider {

this.SELECTED_GLOW_COLOUR = theme.getComponentStyle('selectedGlowColour') ||
this.SELECTED_GLOW_COLOUR;
const selectedGlowSize = Number(theme.getComponentStyle('selectedGlowSize'));
const selectedGlowSize =
Number(theme.getComponentStyle('selectedGlowSize'));
this.SELECTED_GLOW_SIZE = selectedGlowSize && !isNaN(selectedGlowSize) ?
selectedGlowSize :
this.SELECTED_GLOW_SIZE;
Expand Down Expand Up @@ -494,10 +495,10 @@ class ConstantProvider extends BaseConstantProvider {

/**
* Make the main path for the hexagonal connection shape out of two lines.
* The lines are defined with relative positions and require the block height.
* The 'up' and 'down' versions of the paths are the same, but the Y sign
* flips. The 'left' and 'right' versions of the path are also the same, but
* the X sign flips.
* The lines are defined with relative positions and require the block
* height. The 'up' and 'down' versions of the paths are the same, but the Y
* sign flips. The 'left' and 'right' versions of the path are also the
* same, but the X sign flips.
* @param {number} height The height of the block the connection is on.
* @param {boolean} up True if the path should be drawn from bottom to top,
* false otherwise.
Expand Down Expand Up @@ -559,12 +560,11 @@ class ConstantProvider extends BaseConstantProvider {
/**
* Make the main path for the rounded connection shape out of two arcs and
* a line that joins them. The arcs are defined with relative positions.
* Usually, the height of the block is split between the two arcs. In the case
* where the height of the block exceeds the maximum height, a line is drawn
* in between the two arcs.
* The 'up' and 'down' versions of the paths are the same, but the Y sign
* flips. The 'up' and 'right' versions of the path flip the sweep-flag
* which moves the arc at negative angles.
* Usually, the height of the block is split between the two arcs. In the
* case where the height of the block exceeds the maximum height, a line is
* drawn in between the two arcs. The 'up' and 'down' versions of the paths
* are the same, but the Y sign flips. The 'up' and 'right' versions of the
* path flip the sweep-flag which moves the arc at negative angles.
* @param {number} blockHeight The height of the block the connection is on.
* @param {boolean} up True if the path should be drawn from bottom to top,
* false otherwise.
Expand All @@ -579,7 +579,8 @@ class ConstantProvider extends BaseConstantProvider {
const radius = height / 2;
return svgPaths.arc(
'a', '0 0,1', radius,
svgPaths.point((up ? -1 : 1) * radius, (up ? -1 : 1) * radius)) +
svgPaths.point(
(up ? -1 : 1) * radius, (up ? -1 : 1) * radius)) +
svgPaths.lineOnAxis('v', (right ? 1 : -1) * remainingHeight) +
svgPaths.arc(
'a', '0 0,1', radius,
Expand Down Expand Up @@ -631,8 +632,8 @@ class ConstantProvider extends BaseConstantProvider {
* and a single line in-between (a and v). These are defined in relative
* positions and require the height of the block.
* The 'left' and 'right' versions of the paths are the same, but the Y sign
* flips. The 'up' and 'down' versions of the path determine where the corner
* point is placed and in turn the direction of the corners.
* flips. The 'up' and 'down' versions of the path determine where the
* corner point is placed and in turn the direction of the corners.
* @param {number} height The height of the block the connection is on.
* @param {boolean} up True if the path should be drawn from bottom to top,
* false otherwise.
Expand All @@ -644,7 +645,8 @@ class ConstantProvider extends BaseConstantProvider {
const innerHeight = height - radius * 2;
return svgPaths.arc(
'a', '0 0,1', radius,
svgPaths.point((up ? -1 : 1) * radius, (up ? -1 : 1) * radius)) +
svgPaths.point(
(up ? -1 : 1) * radius, (up ? -1 : 1) * radius)) +
svgPaths.lineOnAxis('v', (right ? 1 : -1) * innerHeight) +
svgPaths.arc(
'a', '0 0,1', radius,
Expand Down Expand Up @@ -965,13 +967,14 @@ class ConstantProvider extends BaseConstantProvider {
selector + ' .blocklyDraggable:not(.blocklyDisabled)',
' .blocklyEditableText:not(.editing):hover>rect,',
selector + ' .blocklyDraggable:not(.blocklyDisabled)',
' .blocklyEditableText:not(.editing):hover>.blocklyPath {', 'stroke: #fff;',
'stroke-width: 2;', '}',
' .blocklyEditableText:not(.editing):hover>.blocklyPath {',
'stroke: #fff;', 'stroke-width: 2;', '}',

// Text field input.
selector + ' .blocklyHtmlInput {',
'font-family: ' + this.FIELD_TEXT_FONTFAMILY + ';',
'font-weight: ' + this.FIELD_TEXT_FONTWEIGHT + ';', 'color: #575E75;', '}',
'font-weight: ' + this.FIELD_TEXT_FONTWEIGHT + ';', 'color: #575E75;',
'}',

// Dropdown field.
selector + ' .blocklyDropdownText {', 'fill: #fff !important;', '}',
Expand Down
12 changes: 7 additions & 5 deletions core/renderers/zelos/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class Drawer extends BaseDrawer {
const cornerHeight = this.constants_.INSIDE_CORNERS.rightHeight;
const remainingHeight =
row.height - (row.precedesStatement ? cornerHeight : 0);
this.outlinePath_ +=
(row.followsStatement ? this.constants_.INSIDE_CORNERS.pathBottomRight :
'') +
this.outlinePath_ += (row.followsStatement ?
this.constants_.INSIDE_CORNERS.pathBottomRight :
'') +
(remainingHeight > 0 ?
svgPaths.lineOnAxis('V', row.yPos + remainingHeight) :
'') +
Expand Down Expand Up @@ -198,7 +198,8 @@ class Drawer extends BaseDrawer {
const outlinePath = svgPaths.moveTo(connectionRight, yPos) +
svgPaths.lineOnAxis('h', width) +
input.shape.pathRightDown(input.height) +
svgPaths.lineOnAxis('h', -width) + input.shape.pathUp(input.height) + 'z';
svgPaths.lineOnAxis('h', -width) + input.shape.pathUp(input.height) +
'z';
this.block_.pathObject.setOutlinePath(inputName, outlinePath);
}

Expand All @@ -215,7 +216,8 @@ class Drawer extends BaseDrawer {
'h', -(input.notchOffset - this.constants_.INSIDE_CORNERS.width)) +
this.constants_.INSIDE_CORNERS.pathTop;

const innerHeight = row.height - (2 * this.constants_.INSIDE_CORNERS.height);
const innerHeight =
row.height - (2 * this.constants_.INSIDE_CORNERS.height);

const innerBottomLeftCorner = this.constants_.INSIDE_CORNERS.pathBottom +
svgPaths.lineOnAxis(
Expand Down
Loading

0 comments on commit c1728df

Please sign in to comment.