Skip to content

Commit 4f97982

Browse files
authored
fix: modernize and reenable the colour slider field (#42)
* fix: modernize and reenable the colour slider field * refactor: clean up FieldColourSlider * refactor: extend the FieldColour Blockly plugin * refactor: remove redundant setting of colour on source block
1 parent 300a1ce commit 4f97982

File tree

7 files changed

+341
-338
lines changed

7 files changed

+341
-338
lines changed

blocks_common/colour.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@
2222
* @fileoverview Colour blocks for Blockly.
2323
* @author [email protected] (Neil Fraser)
2424
*/
25-
'use strict';
26-
27-
goog.provide('Blockly.Blocks.colour');
28-
29-
goog.require('Blockly.Blocks');
30-
31-
goog.require('Blockly.constants');
25+
import * as Blockly from 'blockly';
26+
import * as Constants from '../src/constants.js';
3227

3328
/**
3429
* Pick a random colour.
@@ -54,7 +49,7 @@ Blockly.Blocks['colour_picker'] = {
5449
"colour": randomColour()
5550
}
5651
],
57-
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
52+
"outputShape": Constants.OUTPUT_SHAPE_ROUND,
5853
"output": "Colour"
5954
});
6055
}

core/css.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,10 @@ const styles = `
881881
cursor: pointer;
882882
}
883883
884+
.scratchColourPicker {
885+
width: min-content;
886+
}
887+
884888
.scratchColourPickerLabel {
885889
font-family: "Helvetica Neue", Helvetica, sans-serif;
886890
font-size: 0.65rem;
@@ -896,6 +900,36 @@ const styles = `
896900
margin-left: 10px;
897901
}
898902
903+
.scratchColourSlider {
904+
appearance: none;
905+
margin: 8px;
906+
height: 22px;
907+
width: 150px;
908+
position: relative;
909+
outline: none;
910+
border-radius: 11px;
911+
margin-bottom: 20px;
912+
}
913+
914+
/* Combining this and the -moz equivalent below with a comma break the webkit version */
915+
.scratchColourSlider::-webkit-slider-thumb {
916+
appearance: none;
917+
background-color: #fff;
918+
height: 26px;
919+
width: 26px;
920+
border-radius: 100%;
921+
box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.15);
922+
}
923+
924+
.scratchColourSlider::-moz-range-thumb {
925+
appearance: none;
926+
background-color: #fff;
927+
height: 26px;
928+
width: 26px;
929+
border-radius: 100%;
930+
box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.15);
931+
}
932+
899933
.scratchMatrixButtonDiv {
900934
width: 50%;
901935
text-align: center;

0 commit comments

Comments
 (0)