Skip to content

Commit 6fbc2e5

Browse files
authored
fix: fix the styling of contextual menus (#147)
1 parent d3e1a1b commit 6fbc2e5

File tree

2 files changed

+8
-214
lines changed

2 files changed

+8
-214
lines changed

src/colours.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const cssColours = {
120120
numPadText: "white", // Do not use hex here, it cannot be inlined with data-uri SVG
121121
valueReportBackground: "#FFFFFF",
122122
valueReportBorder: "#AAAAAA",
123-
menuHover: "rgba(0, 0, 0, 0.2)",
123+
menuHover: "rgba(77, 151, 255, .25)",
124124
};
125125

126126
const Colours = {

src/css.js

Lines changed: 7 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,6 @@ const styles = `
735735
background-color: var(--colour-numPadBackground);
736736
}
737737
738-
/* Override the default Closure URL. */
739-
.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,
740-
.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {
741-
background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;
742-
}
743-
744738
/* Category tree in Toolbox. */
745739
.blocklyToolboxDiv {
746740
background-color: var(--colour-toolbox);
@@ -966,7 +960,7 @@ const styles = `
966960
* @author [email protected] (Attila Bodis)
967961
*/
968962
969-
.blocklyWidgetDiv .goog-menu {
963+
.blocklyWidgetDiv .blocklyMenu {
970964
background: #fff;
971965
border-color: #ccc #666 #666 #ccc;
972966
border-style: solid;
@@ -984,223 +978,23 @@ const styles = `
984978
box-shadow: none;
985979
}
986980
987-
.blocklyWidgetDiv .blocklyMenu.blocklyFocused {
981+
.blocklyWidgetDiv .blocklyMenu:focus {
988982
box-shadow: none;
989983
}
990984
991-
.blocklyDropDownDiv .goog-menu {
985+
.blocklyDropDownDiv .blocklyMenu {
992986
cursor: default;
993987
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
994988
outline: none;
995989
z-index: 20000; /* Arbitrary, but some apps depend on it... */
996990
}
997991
998-
/* Copied from: goog/css/menuitem.css */
999-
/*
1000-
* Copyright 2009 The Closure Library Authors. All Rights Reserved.
1001-
*
1002-
* Use of this source code is governed by the Apache License, Version 2.0.
1003-
* See the COPYING file for details.
1004-
*/
1005-
1006-
/**
1007-
* Standard styling for menus created by goog.ui.MenuItemRenderer.
1008-
*
1009-
* @author [email protected] (Attila Bodis)
1010-
*/
1011-
1012-
/**
1013-
* State: resting.
1014-
*
1015-
* NOTE(mleibman,chrishenry):
1016-
* The RTL support in Closure is provided via two mechanisms -- "rtl" CSS
1017-
* classes and BiDi flipping done by the CSS compiler. Closure supports RTL
1018-
* with or without the use of the CSS compiler. In order for them not
1019-
* to conflict with each other, the "rtl" CSS classes need to have the #noflip
1020-
* annotation. The non-rtl counterparts should ideally have them as well, but,
1021-
* since .goog-menuitem existed without .goog-menuitem-rtl for so long before
1022-
* being added, there is a risk of people having templates where they are not
1023-
* rendering the .goog-menuitem-rtl class when in RTL and instead rely solely
1024-
* on the BiDi flipping by the CSS compiler. That's why we're not adding the
1025-
* #noflip to .goog-menuitem.
1026-
*/
1027-
.blocklyWidgetDiv .goog-menuitem {
1028-
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
1029-
list-style: none;
1030-
margin: 0;
1031-
/* 28px on the left for icon or checkbox; 7em on the right for shortcut. */
1032-
padding: 4px 7em 4px 28px;
1033-
white-space: nowrap;
1034-
}
1035-
1036-
.blocklyDropDownDiv .goog-menuitem {
1037-
color: var(--colour-text);
1038-
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
1039-
font-weight: bold;
1040-
list-style: none;
1041-
margin: 0;
1042-
min-height: 24px;
1043-
/* 28px on the left for icon or checkbox; 7em on the right for shortcut. */
1044-
padding: 4px 7em 4px 28px;
1045-
white-space: nowrap;
1046-
}
1047-
1048-
/* BiDi override for the resting state. */
1049-
/* #noflip */
1050-
.blocklyWidgetDiv .goog-menuitem.goog-menuitem-rtl, ,
1051-
.blocklyDropDownDiv .goog-menuitem.goog-menuitem-rtl {
1052-
/* Flip left/right padding for BiDi. */
1053-
padding-left: 7em;
1054-
padding-right: 28px;
1055-
}
1056-
1057-
/* If a menu doesn't have checkable items or items with icons, remove padding. */
1058-
.blocklyWidgetDiv .goog-menu-nocheckbox .goog-menuitem,
1059-
.blocklyWidgetDiv .goog-menu-noicon .goog-menuitem, ,
1060-
.blocklyDropDownDiv .goog-menu-nocheckbox .goog-menuitem,
1061-
.blocklyDropDownDiv .goog-menu-noicon .goog-menuitem { ,
1062-
padding-left: 12px;
1063-
}
1064-
1065-
/*
1066-
* If a menu doesn't have items with shortcuts, leave just enough room for
1067-
* submenu arrows, if they are rendered.
1068-
*/
1069-
.blocklyWidgetDiv .goog-menu-noaccel .goog-menuitem, ,
1070-
.blocklyDropDownDiv .goog-menu-noaccel .goog-menuitem {
1071-
padding-right: 20px;
1072-
}
1073-
1074-
.blocklyWidgetDiv .goog-menuitem-content ,
1075-
.blocklyDropDownDiv .goog-menuitem-content {
1076-
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
1077-
}
1078-
1079-
/* State: disabled. */
1080-
.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-accel,
1081-
.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-content, ,
1082-
.blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-accel,
1083-
.blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-content {
1084-
color: #ccc !important;
1085-
}
1086-
1087-
.blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon, ,
1088-
.blocklyDropDownDiv .goog-menuitem-disabled .goog-menuitem-icon {
1089-
opacity: 0.3;
1090-
-moz-opacity: 0.3;
1091-
filter: alpha(opacity=30);
1092-
}
1093-
1094-
/* State: hover. */
1095-
.blocklyWidgetDiv .goog-menuitem-highlight,
1096-
.blocklyWidgetDiv .goog-menuitem-hover {
1097-
background-color: #d6e9f8;
1098-
/* Use an explicit top and bottom border so that the selection is visible
1099-
* in high contrast mode. */
1100-
border-color: #d6e9f8;
1101-
border-style: dotted;
1102-
border-width: 1px 0;
1103-
padding-bottom: 3px;
1104-
padding-top: 3px;
1105-
}
1106-
1107-
.blocklyDropDownDiv .goog-menuitem-highlight,
1108-
.blocklyDropDownDiv .goog-menuitem-hover {
1109-
background-color: var(--colour-menuHover);
1110-
}
1111-
1112-
/* State: selected/checked. */
1113-
.blocklyWidgetDiv .goog-menuitem-checkbox,
1114-
.blocklyWidgetDiv .goog-menuitem-icon, ,
1115-
.blocklyDropDownDiv .goog-menuitem-checkbox,
1116-
.blocklyDropDownDiv .goog-menuitem-icon {
1117-
background-repeat: no-repeat;
1118-
height: 16px;
1119-
left: 6px;
1120-
position: absolute;
1121-
right: auto;
1122-
vertical-align: middle;
1123-
width: 16px;
1124-
}
1125-
1126-
.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,
1127-
.blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon,
1128-
.blocklyDropDownDiv .goog-option-selected .goog-menuitem-checkbox,
1129-
.blocklyDropDownDiv .goog-option-selected .goog-menuitem-icon {
1130-
/* Client apps may override the URL at which they serve the sprite. */
1131-
background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;
1132-
position: static; /* Scroll with the menu. */
1133-
float: left;
1134-
margin-left: -24px;
1135-
}
1136-
1137-
/* BiDi override for the selected/checked state. */
1138-
/* #noflip */
1139-
.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox,
1140-
.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon,
1141-
.blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-checkbox,
1142-
.blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-icon {
1143-
/* Flip left/right positioning. */
1144-
float: right;
1145-
margin-right: -24px;
1146-
}
1147-
1148-
/* Keyboard shortcut ("accelerator") style. */
1149-
.blocklyWidgetDiv .goog-menuitem-accel, ,
1150-
.blocklyDropDownDiv .goog-menuitem-accel {
1151-
color: #999;
1152-
/* Keyboard shortcuts are untranslated; always left-to-right. */
1153-
/* #noflip */
1154-
direction: ltr;
1155-
left: auto;
1156-
padding: 0 6px;
1157-
position: absolute;
1158-
right: 0;
1159-
text-align: right;
1160-
}
1161-
1162-
/* BiDi override for shortcut style. */
1163-
/* #noflip */
1164-
.blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-accel, ,
1165-
.blocklyDropDownDiv .goog-menuitem-rtl .goog-menuitem-accel {
1166-
/* Flip left/right positioning and text alignment. */
1167-
left: 0;
1168-
right: auto;
1169-
text-align: left;
1170-
}
1171-
1172-
/* Mnemonic styles. */
1173-
.blocklyWidgetDiv .goog-menuitem-mnemonic-hint, ,
1174-
.blocklyDropDownDiv .goog-menuitem-mnemonic-hint {
1175-
text-decoration: underline;
1176-
}
1177-
1178-
.blocklyWidgetDiv .goog-menuitem-mnemonic-separator, ,
1179-
.blocklyDropDownDiv .goog-menuitem-mnemonic-separator {
1180-
color: #999;
1181-
font-size: 12px;
1182-
padding-left: 4px;
992+
.blocklyWidgetDiv .blocklyMenu .blocklyMenuItem:hover {
993+
background: var(--colour-menuHover);
1183994
}
1184995
1185-
/* Copied from: goog/css/menuseparator.css */
1186-
/*
1187-
* Copyright 2009 The Closure Library Authors. All Rights Reserved.
1188-
*
1189-
* Use of this source code is governed by the Apache License, Version 2.0.
1190-
* See the COPYING file for details.
1191-
*/
1192-
1193-
/**
1194-
* Standard styling for menus created by goog.ui.MenuSeparatorRenderer.
1195-
*
1196-
* @author [email protected] (Attila Bodis)
1197-
*/
1198-
1199-
.blocklyWidgetDiv .goog-menuseparator, ,
1200-
.blocklyDropDownDiv .goog-menuseparator {
1201-
border-top: 1px solid #ccc;
1202-
margin: 4px 0;
1203-
padding: 0;
996+
.blocklyWidgetDiv .blocklyMenu .blocklyMenuItemDisabled.blocklyMenuItem:hover {
997+
background: none;
1204998
}
1205999
12061000
.blocklyFlyoutCheckbox {

0 commit comments

Comments
 (0)