Skip to content

Commit 2b92932

Browse files
authored
refactor: Make FieldColour inherit from FieldGridDropdown. (#2559)
* refactor: Make FieldColour a subclass of FieldGridDropdown. * fix: Fix the FieldColour tests. * chore: Assauge the linter. * fix: Fix FieldColourHsvSliders styling. * fix: fix FieldColourHsvSliders tests.
1 parent 4259cd3 commit 2b92932

File tree

9 files changed

+1283
-504
lines changed

9 files changed

+1283
-504
lines changed

plugins/field-colour-hsv-sliders/package-lock.json

Lines changed: 542 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/field-colour-hsv-sliders/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"devDependencies": {
4747
"@blockly/dev-scripts": "^4.0.9",
4848
"@blockly/dev-tools": "^9.0.1",
49+
"jsdom": "^26.1.0",
50+
"jsdom-global": "^3.0.2",
4951
"typescript": "^5.4.5"
5052
},
5153
"peerDependencies": {

plugins/field-colour-hsv-sliders/src/field_colour_hsv_sliders.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ Blockly.fieldRegistry.register(
618618
Blockly.Css.register(`
619619
.fieldColourSliderContainer {
620620
padding: 4px;
621+
font-family: Roboto, Arial, sans-serif;
622+
color: #5c5c5c;
621623
}
622624
.fieldColourSliderContainer hr {
623625
border: none;

plugins/field-colour-hsv-sliders/test/field_colour_hsv_sliders_test.mocha.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ const {
2020
} = testHelpers;
2121

2222
suite('FieldColourHsvSliders', function () {
23+
setup(function () {
24+
this.jsdomCleanup = require('jsdom-global')(
25+
'<!DOCTYPE html><div id="blocklyDiv"></div>',
26+
);
27+
this.field = new FieldColourHsvSliders();
28+
});
29+
30+
teardown(function () {
31+
this.jsdomCleanup();
32+
});
33+
2334
/**
2435
* Configuration for field tests with invalid values.
2536
* @type {Array<FieldCreationTestCase>}
@@ -112,9 +123,6 @@ suite('FieldColourHsvSliders', function () {
112123

113124
suite('setValue', function () {
114125
suite('Empty -> New Value', function () {
115-
setup(function () {
116-
this.field = new FieldColourHsvSliders();
117-
});
118126
runSetValueTests(
119127
validValueTestCases,
120128
invalidValueTestCases,
@@ -123,9 +131,6 @@ suite('FieldColourHsvSliders', function () {
123131
);
124132
});
125133
suite('Value -> New Value', function () {
126-
setup(function () {
127-
this.field = new FieldColourHsvSliders(1);
128-
});
129134
runSetValueTests(
130135
validValueTestCases,
131136
invalidValueTestCases,

0 commit comments

Comments
 (0)