Skip to content

Commit

Permalink
fix: removed underscore from isLabel_ in flyout_button.ts (#7533)
Browse files Browse the repository at this point in the history
* Removed underscore from isLabel_ in flyout_button.ts

* chore: rename isLabel_ to isFlyoutLabel in flyout_button.ts

* fix: format

---------

Co-authored-by: sayali-kandarkar <[email protected]>
  • Loading branch information
sayalikandarkar and sayali-kandarkar authored Sep 22, 2023
1 parent c37f4b8 commit e4d8f16
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions core/flyout_button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export class FlyoutButton {
* @param workspace The workspace in which to place this button.
* @param targetWorkspace The flyout's target workspace.
* @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
*/
constructor(
private readonly workspace: WorkspaceSvg,
private readonly targetWorkspace: WorkspaceSvg,
json: toolbox.ButtonOrLabelInfo,
private readonly isLabel_: boolean,
private readonly isFlyoutLabel: boolean,
) {
this.text = json['text'];

Expand All @@ -93,7 +93,9 @@ export class FlyoutButton {
* @returns The button's SVG group.
*/
createDom(): SVGElement {
let cssClass = this.isLabel_ ? 'blocklyFlyoutLabel' : 'blocklyFlyoutButton';
let cssClass = this.isFlyoutLabel
? 'blocklyFlyoutLabel'
: 'blocklyFlyoutButton';
if (this.cssClass) {
cssClass += ' ' + this.cssClass;
}
Expand All @@ -105,7 +107,7 @@ export class FlyoutButton {
);

let shadow;
if (!this.isLabel_) {
if (!this.isFlyoutLabel) {
// Shadow rectangle (light source does not mirror in RTL).
shadow = dom.createSvgElement(
Svg.RECT,
Expand All @@ -123,7 +125,7 @@ export class FlyoutButton {
const rect = dom.createSvgElement(
Svg.RECT,
{
'class': this.isLabel_
'class': this.isFlyoutLabel
? 'blocklyFlyoutLabelBackground'
: 'blocklyFlyoutButtonBackground',
'rx': FlyoutButton.BORDER_RADIUS,
Expand All @@ -135,7 +137,7 @@ export class FlyoutButton {
const svgText = dom.createSvgElement(
Svg.TEXT,
{
'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
'class': this.isFlyoutLabel ? 'blocklyFlyoutLabelText' : 'blocklyText',
'x': 0,
'y': 0,
'text-anchor': 'middle',
Expand All @@ -148,7 +150,7 @@ export class FlyoutButton {
text += '\u200F';
}
svgText.textContent = text;
if (this.isLabel_) {
if (this.isFlyoutLabel) {
this.svgText = svgText;
this.workspace
.getThemeManager()
Expand All @@ -172,7 +174,7 @@ export class FlyoutButton {
);
this.height = fontMetrics.height;

if (!this.isLabel_) {
if (!this.isFlyoutLabel) {
this.width += 2 * FlyoutButton.TEXT_MARGIN_X;
this.height += 2 * FlyoutButton.TEXT_MARGIN_Y;
shadow?.setAttribute('width', String(this.width));
Expand Down Expand Up @@ -228,7 +230,7 @@ export class FlyoutButton {

/** @returns Whether or not the button is a label. */
isLabel(): boolean {
return this.isLabel_;
return this.isFlyoutLabel;
}

/**
Expand Down Expand Up @@ -279,19 +281,19 @@ export class FlyoutButton {
gesture.cancel();
}

if (this.isLabel_ && this.callbackKey) {
if (this.isFlyoutLabel && this.callbackKey) {
console.warn(
'Labels should not have callbacks. Label text: ' + this.text,
);
} else if (
!this.isLabel_ &&
!this.isFlyoutLabel &&
!(
this.callbackKey &&
this.targetWorkspace.getButtonCallback(this.callbackKey)
)
) {
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);
if (callback) {
callback(this);
Expand Down

0 comments on commit e4d8f16

Please sign in to comment.