mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
fix: removed underscore from isLabel_ in flyout_button.ts (#7533)
* Removed underscore from isLabel_ in flyout_button.ts * chore: rename isLabel_ to isFlyoutLabel in flyout_button.ts * fix: format --------- Co-authored-by: sayali-kandarkar <skandark@andrew.cmu.edu>
This commit is contained in:
@@ -59,14 +59,14 @@ export class FlyoutButton {
|
|||||||
* @param workspace The workspace in which to place this button.
|
* @param workspace The workspace in which to place this button.
|
||||||
* @param targetWorkspace The flyout's target workspace.
|
* @param targetWorkspace The flyout's target workspace.
|
||||||
* @param json The JSON specifying the label/button.
|
* @param json The JSON specifying the label/button.
|
||||||
* @param isLabel_ Whether this button should be styled as a label.
|
* @param isFlyoutLabel Whether this button should be styled as a label.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private readonly workspace: WorkspaceSvg,
|
private readonly workspace: WorkspaceSvg,
|
||||||
private readonly targetWorkspace: WorkspaceSvg,
|
private readonly targetWorkspace: WorkspaceSvg,
|
||||||
json: toolbox.ButtonOrLabelInfo,
|
json: toolbox.ButtonOrLabelInfo,
|
||||||
private readonly isLabel_: boolean,
|
private readonly isFlyoutLabel: boolean,
|
||||||
) {
|
) {
|
||||||
this.text = json['text'];
|
this.text = json['text'];
|
||||||
|
|
||||||
@@ -93,7 +93,9 @@ export class FlyoutButton {
|
|||||||
* @returns The button's SVG group.
|
* @returns The button's SVG group.
|
||||||
*/
|
*/
|
||||||
createDom(): SVGElement {
|
createDom(): SVGElement {
|
||||||
let cssClass = this.isLabel_ ? 'blocklyFlyoutLabel' : 'blocklyFlyoutButton';
|
let cssClass = this.isFlyoutLabel
|
||||||
|
? 'blocklyFlyoutLabel'
|
||||||
|
: 'blocklyFlyoutButton';
|
||||||
if (this.cssClass) {
|
if (this.cssClass) {
|
||||||
cssClass += ' ' + this.cssClass;
|
cssClass += ' ' + this.cssClass;
|
||||||
}
|
}
|
||||||
@@ -105,7 +107,7 @@ export class FlyoutButton {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let shadow;
|
let shadow;
|
||||||
if (!this.isLabel_) {
|
if (!this.isFlyoutLabel) {
|
||||||
// Shadow rectangle (light source does not mirror in RTL).
|
// Shadow rectangle (light source does not mirror in RTL).
|
||||||
shadow = dom.createSvgElement(
|
shadow = dom.createSvgElement(
|
||||||
Svg.RECT,
|
Svg.RECT,
|
||||||
@@ -123,7 +125,7 @@ export class FlyoutButton {
|
|||||||
const rect = dom.createSvgElement(
|
const rect = dom.createSvgElement(
|
||||||
Svg.RECT,
|
Svg.RECT,
|
||||||
{
|
{
|
||||||
'class': this.isLabel_
|
'class': this.isFlyoutLabel
|
||||||
? 'blocklyFlyoutLabelBackground'
|
? 'blocklyFlyoutLabelBackground'
|
||||||
: 'blocklyFlyoutButtonBackground',
|
: 'blocklyFlyoutButtonBackground',
|
||||||
'rx': FlyoutButton.BORDER_RADIUS,
|
'rx': FlyoutButton.BORDER_RADIUS,
|
||||||
@@ -135,7 +137,7 @@ export class FlyoutButton {
|
|||||||
const svgText = dom.createSvgElement(
|
const svgText = dom.createSvgElement(
|
||||||
Svg.TEXT,
|
Svg.TEXT,
|
||||||
{
|
{
|
||||||
'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
'class': this.isFlyoutLabel ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
||||||
'x': 0,
|
'x': 0,
|
||||||
'y': 0,
|
'y': 0,
|
||||||
'text-anchor': 'middle',
|
'text-anchor': 'middle',
|
||||||
@@ -148,7 +150,7 @@ export class FlyoutButton {
|
|||||||
text += '\u200F';
|
text += '\u200F';
|
||||||
}
|
}
|
||||||
svgText.textContent = text;
|
svgText.textContent = text;
|
||||||
if (this.isLabel_) {
|
if (this.isFlyoutLabel) {
|
||||||
this.svgText = svgText;
|
this.svgText = svgText;
|
||||||
this.workspace
|
this.workspace
|
||||||
.getThemeManager()
|
.getThemeManager()
|
||||||
@@ -172,7 +174,7 @@ export class FlyoutButton {
|
|||||||
);
|
);
|
||||||
this.height = fontMetrics.height;
|
this.height = fontMetrics.height;
|
||||||
|
|
||||||
if (!this.isLabel_) {
|
if (!this.isFlyoutLabel) {
|
||||||
this.width += 2 * FlyoutButton.TEXT_MARGIN_X;
|
this.width += 2 * FlyoutButton.TEXT_MARGIN_X;
|
||||||
this.height += 2 * FlyoutButton.TEXT_MARGIN_Y;
|
this.height += 2 * FlyoutButton.TEXT_MARGIN_Y;
|
||||||
shadow?.setAttribute('width', String(this.width));
|
shadow?.setAttribute('width', String(this.width));
|
||||||
@@ -228,7 +230,7 @@ export class FlyoutButton {
|
|||||||
|
|
||||||
/** @returns Whether or not the button is a label. */
|
/** @returns Whether or not the button is a label. */
|
||||||
isLabel(): boolean {
|
isLabel(): boolean {
|
||||||
return this.isLabel_;
|
return this.isFlyoutLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,19 +281,19 @@ export class FlyoutButton {
|
|||||||
gesture.cancel();
|
gesture.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isLabel_ && this.callbackKey) {
|
if (this.isFlyoutLabel && this.callbackKey) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Labels should not have callbacks. Label text: ' + this.text,
|
'Labels should not have callbacks. Label text: ' + this.text,
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
!this.isLabel_ &&
|
!this.isFlyoutLabel &&
|
||||||
!(
|
!(
|
||||||
this.callbackKey &&
|
this.callbackKey &&
|
||||||
this.targetWorkspace.getButtonCallback(this.callbackKey)
|
this.targetWorkspace.getButtonCallback(this.callbackKey)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
console.warn('Buttons should have callbacks. Button text: ' + this.text);
|
console.warn('Buttons should have callbacks. Button text: ' + this.text);
|
||||||
} else if (!this.isLabel_) {
|
} else if (!this.isFlyoutLabel) {
|
||||||
const callback = this.targetWorkspace.getButtonCallback(this.callbackKey);
|
const callback = this.targetWorkspace.getButtonCallback(this.callbackKey);
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(this);
|
callback(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user