Skip to content

Commit 46e92fb

Browse files
author
Andy O'Neill
committed
feat: rename color properties for input text and text
1 parent 5258e78 commit 46e92fb

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

core/colours.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ Blockly.Colours = {
8282
"secondary": "#FF4D6A",
8383
"tertiary": "#FF3355"
8484
},
85-
"text": "#575E75",
86-
"blockText": "#FFFFFF",
85+
"text": "#FFFFFF",
8786
"workspace": "#F9F9F9",
8887
"toolboxHover": "#4C97FF",
8988
"toolboxSelected": "#e9eef2",
@@ -93,6 +92,7 @@ Blockly.Colours = {
9392
"scrollbar": "#CECDCE",
9493
"scrollbarHover": '#CECDCE',
9594
"textField": "#FFFFFF",
95+
"textFieldText": "#575E75",
9696
"insertionMarker": "#000000",
9797
"insertionMarkerOpacity": 0.2,
9898
"dragShadowOpacity": 0.3,

core/css.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ Blockly.Css.inject = function(hasCss, pathToMedia) {
9393
text = text.replace(/<<<PATH>>>/g, Blockly.Css.mediaPath_);
9494
// Dynamically replace colours in the CSS text, in case they have
9595
// been set at run-time injection.
96-
for (var colourProperty in Blockly.Colours) {
97-
if (Blockly.Colours.hasOwnProperty(colourProperty)) {
98-
// Replace all
99-
text = text.replace(
100-
new RegExp('\\$colour\\_' + colourProperty, 'g'),
101-
Blockly.Colours[colourProperty]
102-
);
103-
}
96+
// Process longer colour properties first to handle common prefixes.
97+
var compareByLength = function(a, b) { return b.length - a.length; };
98+
var colourProperties = Object.keys(Blockly.Colours).sort(compareByLength);
99+
for (var i = 0, colourProperty; colourProperty = colourProperties[i]; i++) {
100+
// Replace all
101+
text = text.replace(
102+
new RegExp('\\$colour\\_' + colourProperty, 'g'),
103+
Blockly.Colours[colourProperty]
104+
);
104105
}
105106

106107
// Inject CSS tag at start of head.
@@ -459,7 +460,7 @@ Blockly.Css.CONTENT = [
459460
'}',
460461

461462
'.blocklyText {',
462-
'fill: $colour_blockText;',
463+
'fill: $colour_text;',
463464
'font-family: "Helvetica Neue", Helvetica, sans-serif;',
464465
'font-size: 12pt;',
465466
'font-weight: 500;',
@@ -474,19 +475,19 @@ Blockly.Css.CONTENT = [
474475
'}',
475476
'.blocklyNonEditableText>text,',
476477
'.blocklyEditableText>text {',
477-
'fill: $colour_text;',
478+
'fill: $colour_textFieldText;',
478479
'}',
479480

480481
'.blocklyEditableText>.blocklyEditableLabel {',
481482
'fill: #fff;',
482483
'}',
483484

484485
'.blocklyDropdownText {',
485-
'fill: #fff !important;',
486+
'fill: $colour_text !important;',
486487
'}',
487488

488489
'.blocklyBubbleText {',
489-
'fill: $colour_text;',
490+
'fill: $colour_textFieldText;',
490491
'}',
491492
'.blocklyFlyout {',
492493
'position: absolute;',
@@ -502,7 +503,7 @@ Blockly.Css.CONTENT = [
502503
'}',
503504

504505
'.blocklyFlyoutButton .blocklyText {',
505-
'fill: $colour_text;',
506+
'fill: $colour_textFieldText;',
506507
'}',
507508

508509
'.blocklyFlyoutButtonShadow {',
@@ -720,7 +721,7 @@ Blockly.Css.CONTENT = [
720721
'box-sizing: border-box;',
721722
'width: 100%;',
722723
'text-align: center;',
723-
'color: $colour_text;',
724+
'color: $colour_textFieldText;',
724725
'font-weight: 500;',
725726
'}',
726727

@@ -1014,7 +1015,7 @@ Blockly.Css.CONTENT = [
10141015
'.scratchNotePickerKeyLabel {',
10151016
'font-family: "Helvetica Neue", Helvetica, sans-serif;',
10161017
'font-size: 0.75rem;',
1017-
'fill: $colour_text;',
1018+
'fill: $colour_textFieldText;',
10181019
'pointer-events: none;',
10191020
'}',
10201021

@@ -1095,7 +1096,7 @@ Blockly.Css.CONTENT = [
10951096
'}',
10961097

10971098
'.blocklyDropDownDiv .goog-menuitem {',
1098-
'color: #fff;',
1099+
'color: $colour_text;',
10991100
'font: normal 13px "Helvetica Neue", Helvetica, sans-serif;',
11001101
'font-weight: bold;',
11011102
'list-style: none;',

0 commit comments

Comments
 (0)