Skip to content

Commit

Permalink
fix!: Replace Closure UI CSS classes with Blockly CSS classes (#8339)
Browse files Browse the repository at this point in the history
* fix!: Replace Closure UI CSS classes with Blockly CSS classes

* chore: remove comments about deprecated goog-x class

* chore: remove deprecated goog-x classes

* fix: correct coding format to pass CI checks
  • Loading branch information
Arun-cn authored Jul 17, 2024
1 parent 33b5371 commit ae80adf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
3 changes: 1 addition & 2 deletions core/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ export class Menu {
*/
render(container: Element): HTMLDivElement {
const element = document.createElement('div');
// goog-menu is deprecated, use blocklyMenu. May 2020.
element.className = 'blocklyMenu goog-menu blocklyNonSelectable';
element.className = 'blocklyMenu blocklyNonSelectable';
element.tabIndex = 0;
if (this.roleName) {
aria.setRole(element, this.roleName);
Expand Down
23 changes: 7 additions & 16 deletions core/menuitem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,19 @@ export class MenuItem {
this.element = element;

// Set class and style
// goog-menuitem* is deprecated, use blocklyMenuItem*. May 2020.
element.className =
'blocklyMenuItem goog-menuitem ' +
(this.enabled ? '' : 'blocklyMenuItemDisabled goog-menuitem-disabled ') +
(this.checked ? 'blocklyMenuItemSelected goog-option-selected ' : '') +
(this.highlight
? 'blocklyMenuItemHighlight goog-menuitem-highlight '
: '') +
(this.rightToLeft ? 'blocklyMenuItemRtl goog-menuitem-rtl ' : '');
'blocklyMenuItem ' +
(this.enabled ? '' : 'blocklyMenuItemDisabled ') +
(this.checked ? 'blocklyMenuItemSelected ' : '') +
(this.highlight ? 'blocklyMenuItemHighlight ' : '') +
(this.rightToLeft ? 'blocklyMenuItemRtl ' : '');

const content = document.createElement('div');
content.className = 'blocklyMenuItemContent goog-menuitem-content';
content.className = 'blocklyMenuItemContent';
// Add a checkbox for checkable menu items.
if (this.checkable) {
const checkbox = document.createElement('div');
checkbox.className = 'blocklyMenuItemCheckbox goog-menuitem-checkbox';
checkbox.className = 'blocklyMenuItemCheckbox ';
content.appendChild(checkbox);
}

Expand Down Expand Up @@ -188,19 +185,13 @@ export class MenuItem {
*/
setHighlighted(highlight: boolean) {
this.highlight = highlight;

const el = this.getElement();
if (el && this.isEnabled()) {
// goog-menuitem-highlight is deprecated, use blocklyMenuItemHighlight.
// May 2020.
const name = 'blocklyMenuItemHighlight';
const nameDep = 'goog-menuitem-highlight';
if (highlight) {
dom.addClass(el, name);
dom.addClass(el, nameDep);
} else {
dom.removeClass(el, name);
dom.removeClass(el, nameDep);
}
}
}
Expand Down

0 comments on commit ae80adf

Please sign in to comment.