scratchblocks-plus 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +193 -0
- package/browser.es.js +8 -0
- package/browser.js +8 -0
- package/build/scratchblocks-plus.min.es.js +12 -0
- package/build/scratchblocks-plus.min.es.js.map +1 -0
- package/build/scratchblocks-plus.min.js +12 -0
- package/build/scratchblocks-plus.min.js.map +1 -0
- package/build/translations-all-es.js +11 -0
- package/build/translations-all-es.js.map +1 -0
- package/build/translations-all.js +11 -0
- package/build/translations-all.js.map +1 -0
- package/build/translations-es.js +11 -0
- package/build/translations-es.js.map +1 -0
- package/build/translations.js +11 -0
- package/build/translations.js.map +1 -0
- package/index.d.ts +297 -0
- package/index.js +229 -0
- package/locales/ab.json +1630 -0
- package/locales/af.json +1630 -0
- package/locales/all.d.ts +108 -0
- package/locales/all.js +161 -0
- package/locales/am.json +1925 -0
- package/locales/an.json +1630 -0
- package/locales/ar.json +1924 -0
- package/locales/ast.json +1630 -0
- package/locales/az.json +1925 -0
- package/locales/be.json +1630 -0
- package/locales/bg.json +1924 -0
- package/locales/bn.json +1630 -0
- package/locales/ca.json +1930 -0
- package/locales/ckb.json +1630 -0
- package/locales/cs.json +1930 -0
- package/locales/cy.json +1929 -0
- package/locales/da.json +1924 -0
- package/locales/de.json +1929 -0
- package/locales/el.json +1931 -0
- package/locales/eo.json +1630 -0
- package/locales/es-419.json +1924 -0
- package/locales/es.json +1929 -0
- package/locales/et.json +1924 -0
- package/locales/eu.json +1924 -0
- package/locales/fa.json +1929 -0
- package/locales/fi.json +1924 -0
- package/locales/fil.json +1631 -0
- package/locales/forums.js +37 -0
- package/locales/fr.json +1929 -0
- package/locales/fy.json +1630 -0
- package/locales/ga.json +1924 -0
- package/locales/gd.json +1929 -0
- package/locales/gl.json +1924 -0
- package/locales/ha.json +1630 -0
- package/locales/he.json +1929 -0
- package/locales/hi.json +1635 -0
- package/locales/hr.json +1929 -0
- package/locales/ht.json +1630 -0
- package/locales/hu.json +1930 -0
- package/locales/hy.json +1630 -0
- package/locales/id.json +1929 -0
- package/locales/is.json +1924 -0
- package/locales/it.json +1929 -0
- package/locales/ja-Hira.json +1637 -0
- package/locales/ja.json +1931 -0
- package/locales/ka.json +1630 -0
- package/locales/kk.json +1632 -0
- package/locales/km.json +1630 -0
- package/locales/ko.json +1924 -0
- package/locales/ku.json +1632 -0
- package/locales/lt.json +1924 -0
- package/locales/lv.json +1924 -0
- package/locales/mi.json +1924 -0
- package/locales/mn.json +1631 -0
- package/locales/nb.json +1929 -0
- package/locales/nl.json +1929 -0
- package/locales/nn.json +1630 -0
- package/locales/nso.json +1630 -0
- package/locales/oc.json +1630 -0
- package/locales/or.json +1631 -0
- package/locales/pl.json +1929 -0
- package/locales/pt-br.json +1924 -0
- package/locales/pt.json +1929 -0
- package/locales/qu.json +1630 -0
- package/locales/rap.json +1632 -0
- package/locales/ro.json +1929 -0
- package/locales/ru.json +1929 -0
- package/locales/sk.json +1924 -0
- package/locales/sl.json +1929 -0
- package/locales/sr.json +1924 -0
- package/locales/sv.json +1924 -0
- package/locales/sw.json +1630 -0
- package/locales/th.json +1924 -0
- package/locales/tn.json +1630 -0
- package/locales/tr.json +1932 -0
- package/locales/uk.json +1924 -0
- package/locales/uz.json +1631 -0
- package/locales/vi.json +1925 -0
- package/locales/xh.json +1630 -0
- package/locales/zh-cn.json +1930 -0
- package/locales/zh-tw.json +1930 -0
- package/locales/zu.json +1918 -0
- package/package.json +81 -0
- package/scratch2/blocks.js +1000 -0
- package/scratch2/draw.js +452 -0
- package/scratch2/filter.js +78 -0
- package/scratch2/index.js +12 -0
- package/scratch2/style.css.js +148 -0
- package/scratch2/style.js +214 -0
- package/scratch3/blocks.js +1134 -0
- package/scratch3/draw.js +334 -0
- package/scratch3/index.js +12 -0
- package/scratch3/style.css.js +280 -0
- package/scratch3/style.js +877 -0
- package/syntax/blocks.js +921 -0
- package/syntax/commands.js +1755 -0
- package/syntax/dropdowns.js +688 -0
- package/syntax/extensions.js +34 -0
- package/syntax/index.js +17 -0
- package/syntax/model.js +566 -0
- package/syntax/syntax.js +1091 -0
package/scratch3/draw.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/* for constructing SVGs */
|
|
2
|
+
|
|
3
|
+
// set by SVG.init
|
|
4
|
+
let document
|
|
5
|
+
let xml
|
|
6
|
+
|
|
7
|
+
const directProps = {
|
|
8
|
+
textContent: true,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class SVG {
|
|
12
|
+
static init(window) {
|
|
13
|
+
document = window.document
|
|
14
|
+
const DOMParser = window.DOMParser
|
|
15
|
+
xml = new DOMParser().parseFromString("<xml></xml>", "application/xml")
|
|
16
|
+
SVG.XMLSerializer = window.XMLSerializer
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static makeCanvas() {
|
|
20
|
+
return document.createElement("canvas")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static cdata(content) {
|
|
24
|
+
return xml.createCDATASection(content)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static el(name, props) {
|
|
28
|
+
const el = document.createElementNS("http://www.w3.org/2000/svg", name)
|
|
29
|
+
return SVG.setProps(el, props)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static setProps(el, props) {
|
|
33
|
+
for (const key in props) {
|
|
34
|
+
const value = String(props[key])
|
|
35
|
+
if (directProps[key]) {
|
|
36
|
+
el[key] = value
|
|
37
|
+
} else if (
|
|
38
|
+
props[key] != null &&
|
|
39
|
+
Object.prototype.hasOwnProperty.call(props, key)
|
|
40
|
+
) {
|
|
41
|
+
el.setAttributeNS(null, key, value)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return el
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static withChildren(el, children) {
|
|
48
|
+
for (const child of children) {
|
|
49
|
+
el.appendChild(child)
|
|
50
|
+
}
|
|
51
|
+
return el
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static group(children) {
|
|
55
|
+
return SVG.withChildren(SVG.el("g"), children)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static newSVG(width, height, scale) {
|
|
59
|
+
return SVG.el("svg", {
|
|
60
|
+
version: "1.1",
|
|
61
|
+
width: width * scale,
|
|
62
|
+
height: height * scale,
|
|
63
|
+
viewBox: `0 0 ${width * scale} ${height * scale}`,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static polygon(props) {
|
|
68
|
+
return SVG.el("polygon", { ...props, points: props.points.join(" ") })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static path(props) {
|
|
72
|
+
return SVG.el("path", { ...props, path: null, d: props.path.join(" ") })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static text(x, y, content, props) {
|
|
76
|
+
const text = SVG.el("text", { ...props, x: x, y: y, textContent: content })
|
|
77
|
+
return text
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static symbol(href) {
|
|
81
|
+
return SVG.el("use", {
|
|
82
|
+
href: href,
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static move(dx, dy, el) {
|
|
87
|
+
SVG.setProps(el, {
|
|
88
|
+
transform: `translate(${dx} ${dy})`,
|
|
89
|
+
})
|
|
90
|
+
return el
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* shapes */
|
|
94
|
+
|
|
95
|
+
static rect(w, h, props) {
|
|
96
|
+
return SVG.el("rect", { ...props, x: 0, y: 0, width: w, height: h })
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static roundRect(w, h, props) {
|
|
100
|
+
return SVG.rect(w, h, { ...props, rx: 4, ry: 4 })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static pillRect(w, h, props) {
|
|
104
|
+
const r = h / 2
|
|
105
|
+
return SVG.rect(w, h, { ...props, rx: r, ry: r })
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static pointedPath(w, h) {
|
|
109
|
+
const r = h / 2
|
|
110
|
+
return [
|
|
111
|
+
`M ${r} 0`,
|
|
112
|
+
`L ${w - r} 0 ${w} ${r}`,
|
|
113
|
+
`L ${w} ${r} ${w - r} ${h}`,
|
|
114
|
+
`L ${r} ${h} 0 ${r}`,
|
|
115
|
+
`L 0 ${r} ${r} 0`,
|
|
116
|
+
"Z",
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static pointedRect(w, h, props) {
|
|
121
|
+
return SVG.path({ ...props, path: SVG.pointedPath(w, h) })
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static topNotch(w, y) {
|
|
125
|
+
return `c 2 0 3 1 4 2
|
|
126
|
+
l 4 4
|
|
127
|
+
c 1 1 2 2 4 2
|
|
128
|
+
h 12
|
|
129
|
+
c 2 0 3 -1 4 -2
|
|
130
|
+
l 4 -4
|
|
131
|
+
c 1 -1 2 -2 4 -2
|
|
132
|
+
L ${w - 4} ${y}
|
|
133
|
+
a 4 4 0 0 1 4 4`
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static getTop(w) {
|
|
137
|
+
return `M 0 4
|
|
138
|
+
A 4 4 0 0 1 4 0
|
|
139
|
+
H 12 ${SVG.topNotch(w, 0)}`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static getRingTop(w) {
|
|
143
|
+
return `M 0 3
|
|
144
|
+
L 3 0
|
|
145
|
+
L 7 0
|
|
146
|
+
L 10 3
|
|
147
|
+
L 16 3
|
|
148
|
+
L 19 0
|
|
149
|
+
L ${w - 3} 0
|
|
150
|
+
L ${w} 3`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static getRightAndBottom(w, y, hasNotch, inset) {
|
|
154
|
+
if (typeof inset === "undefined") {
|
|
155
|
+
inset = 0
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let arr = [`L ${w} ${y - 4}`, `a 4 4 0 0 1 -4 4`]
|
|
159
|
+
|
|
160
|
+
if (hasNotch) {
|
|
161
|
+
arr = arr.concat([
|
|
162
|
+
`L ${inset + 48} ${y}`,
|
|
163
|
+
"c -2 0 -3 1 -4 2",
|
|
164
|
+
"l -4 4",
|
|
165
|
+
"c -1 1 -2 2 -4 2",
|
|
166
|
+
"h -12",
|
|
167
|
+
"c -2 0 -3 -1 -4 -2",
|
|
168
|
+
"l -4 -4",
|
|
169
|
+
"c -1 -1 -2 -2 -4 -2",
|
|
170
|
+
])
|
|
171
|
+
}
|
|
172
|
+
if (inset === 0) {
|
|
173
|
+
arr.push("L", inset + 4, y)
|
|
174
|
+
arr.push("a 4 4 0 0 1 -4 -4")
|
|
175
|
+
} else {
|
|
176
|
+
arr.push("L", inset + 4, y)
|
|
177
|
+
arr.push("a 4 4 0 0 0 -4 4")
|
|
178
|
+
}
|
|
179
|
+
return arr.join(" ")
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static getArm(w, armTop) {
|
|
183
|
+
return `L 16 ${armTop - 4}
|
|
184
|
+
a 4 4 0 0 0 4 4
|
|
185
|
+
L 28 ${armTop} ${SVG.topNotch(w, armTop)}`
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static getArmNoNotch(w, armTop) {
|
|
189
|
+
return `L 16 ${armTop - 4}
|
|
190
|
+
a 4 4 0 0 0 4 4
|
|
191
|
+
L 28 ${armTop} L ${w - 4} ${armTop}
|
|
192
|
+
a 4 4 0 0 1 4 4`
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static stackRect(w, h, props) {
|
|
196
|
+
return SVG.path({
|
|
197
|
+
...props,
|
|
198
|
+
path: [SVG.getTop(w), SVG.getRightAndBottom(w, h, true, 0), "Z"],
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static capPath(w, h) {
|
|
203
|
+
return [SVG.getTop(w), SVG.getRightAndBottom(w, h, false, 0), "Z"]
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static capRect(w, h, props) {
|
|
207
|
+
return SVG.path({ ...props, path: SVG.capPath(w, h) })
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static getHatTop(w) {
|
|
211
|
+
return `M 0 16 c 25,-22 71,-22 96,0 L ${w - 4} 16 a 4 4 0 0 1 4 4`
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
static getCatTop(w) {
|
|
215
|
+
return `M 0 32
|
|
216
|
+
c2.6,-2.3 5.5,-4.3 8.5,-6.2c-1,-12.5 5.3,-23.3 8.4,-24.8c3.7,-1.8 16.5,13.1 18.4,15.4c8.4,-1.3 17,-1.3 25.4,0c1.9,-2.3 14.7,-17.2 18.4,-15.4c3.1,1.5 9.4,12.3 8.4,24.8c3,1.8 5.9,3.9 8.5,6.1
|
|
217
|
+
L ${w - 4} 32
|
|
218
|
+
a 4 4 0 0 1 4 4`
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static hatRect(w, h, props) {
|
|
222
|
+
return SVG.path({
|
|
223
|
+
...props,
|
|
224
|
+
path: [SVG.getHatTop(w), SVG.getRightAndBottom(w, h, true, 0), "Z"],
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static catHat(w, h, props) {
|
|
229
|
+
return SVG.group([
|
|
230
|
+
SVG.path({
|
|
231
|
+
...props,
|
|
232
|
+
path: [SVG.getCatTop(w), SVG.getRightAndBottom(w, h, true, 0), "Z"],
|
|
233
|
+
}),
|
|
234
|
+
SVG.move(
|
|
235
|
+
0,
|
|
236
|
+
32,
|
|
237
|
+
SVG.setProps(
|
|
238
|
+
SVG.group([
|
|
239
|
+
SVG.el("circle", {
|
|
240
|
+
cx: 29.1,
|
|
241
|
+
cy: -3.3,
|
|
242
|
+
r: 3.4,
|
|
243
|
+
}),
|
|
244
|
+
SVG.el("circle", {
|
|
245
|
+
cx: 59.2,
|
|
246
|
+
cy: -3.3,
|
|
247
|
+
r: 3.4,
|
|
248
|
+
}),
|
|
249
|
+
SVG.el("path", {
|
|
250
|
+
d: "M45.6,0.1c-0.9,0-1.7-0.3-2.3-0.9c-0.6,0.6-1.3,0.9-2.2,0.9c-0.9,0-1.8-0.3-2.3-0.9c-1-1.1-1.1-2.6-1.1-2.8c0-0.5,0.5-1,1-1l0,0c0.6,0,1,0.5,1,1c0,0.4,0.1,1.7,1.4,1.7c0.5,0,0.7-0.2,0.8-0.3c0.3-0.3,0.4-1,0.4-1.3c0-0.1,0-0.1,0-0.2c0-0.5,0.5-1,1-1l0,0c0.5,0,1,0.4,1,1c0,0,0,0.1,0,0.2c0,0.3,0.1,0.9,0.4,1.2C44.8-2.2,45-2,45.5-2s0.7-0.2,0.8-0.3c0.3-0.4,0.4-1.1,0.3-1.3c0-0.5,0.4-1,0.9-1.1c0.5,0,1,0.4,1.1,0.9c0,0.2,0.1,1.8-0.8,2.8C47.5-0.4,46.8,0.1,45.6,0.1z",
|
|
251
|
+
}),
|
|
252
|
+
]),
|
|
253
|
+
{
|
|
254
|
+
fill: "#000",
|
|
255
|
+
"fill-opacity": 0.6,
|
|
256
|
+
},
|
|
257
|
+
),
|
|
258
|
+
),
|
|
259
|
+
SVG.move(
|
|
260
|
+
0,
|
|
261
|
+
32,
|
|
262
|
+
SVG.el("path", {
|
|
263
|
+
d: "M73.1-15.6c1.7-4.2,4.5-9.1,5.8-8.5c1.6,0.8,5.4,7.9,5,15.4c0,0.6-0.7,0.7-1.1,0.5c-3-1.6-6.4-2.8-8.6-3.6C72.8-12.3,72.4-13.7,73.1-15.6z",
|
|
264
|
+
fill: "#FFD5E6",
|
|
265
|
+
transform: "translate(0, 32)",
|
|
266
|
+
}),
|
|
267
|
+
),
|
|
268
|
+
SVG.move(
|
|
269
|
+
0,
|
|
270
|
+
32,
|
|
271
|
+
SVG.el("path", {
|
|
272
|
+
d: "M22.4-15.6c-1.7-4.2-4.5-9.1-5.8-8.5c-1.6,0.8-5.4,7.9-5,15.4c0,0.6,0.7,0.7,1.1,0.5c3-1.6,6.4-2.8,8.6-3.6C22.8-12.3,23.2-13.7,22.4-15.6z",
|
|
273
|
+
fill: "#FFD5E6",
|
|
274
|
+
transform: "translate(0, 32)",
|
|
275
|
+
}),
|
|
276
|
+
),
|
|
277
|
+
])
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
static getProcHatTop(w) {
|
|
281
|
+
return `M 0 20 a 20 20 0 0 1 20 -20 L ${w - 20} 0 a 20,20 0 0,1 20,20`
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
static procHatRect(w, h, props) {
|
|
285
|
+
return SVG.path({
|
|
286
|
+
...props,
|
|
287
|
+
path: [SVG.getProcHatTop(w), SVG.getRightAndBottom(w, h, true, 0), "Z"],
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
static mouthRect(w, h, isFinal, lines, props) {
|
|
292
|
+
let y = lines[0].height
|
|
293
|
+
const p = [SVG.getTop(w), SVG.getRightAndBottom(w, y, true, 16)]
|
|
294
|
+
for (let i = 1; i < lines.length; i += 2) {
|
|
295
|
+
const isLast = i + 2 === lines.length
|
|
296
|
+
|
|
297
|
+
const line = lines[i]
|
|
298
|
+
y += line.height - 3
|
|
299
|
+
|
|
300
|
+
if (line.isFinal) {
|
|
301
|
+
p.push(SVG.getArmNoNotch(w, y))
|
|
302
|
+
} else {
|
|
303
|
+
p.push(SVG.getArm(w, y))
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const hasNotch = !(isLast && isFinal)
|
|
307
|
+
const inset = isLast ? 0 : 16
|
|
308
|
+
y += lines[i + 1].height + 3
|
|
309
|
+
p.push(SVG.getRightAndBottom(w, y, hasNotch, inset))
|
|
310
|
+
}
|
|
311
|
+
p.push("Z")
|
|
312
|
+
return SVG.path({ ...props, path: p })
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static commentRect(w, h, props) {
|
|
316
|
+
return SVG.roundRect(w, h, { ...props, class: "sb3-comment" })
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
static commentLine(width, props) {
|
|
320
|
+
return SVG.move(
|
|
321
|
+
-width,
|
|
322
|
+
9,
|
|
323
|
+
SVG.rect(width, 2, { ...props, class: "sb3-comment-line" }),
|
|
324
|
+
)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
static strikethroughLine(w, props) {
|
|
328
|
+
return SVG.path({
|
|
329
|
+
...props,
|
|
330
|
+
path: ["M", 0, 0, "L", w, 0],
|
|
331
|
+
class: "sb3-diff sb3-diff-del",
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import SVG from "./draw.js"
|
|
2
|
+
import { LabelView } from "./blocks.js"
|
|
3
|
+
import style from "./style.js"
|
|
4
|
+
|
|
5
|
+
export function init(window) {
|
|
6
|
+
SVG.init(window)
|
|
7
|
+
|
|
8
|
+
LabelView.measuring = SVG.makeCanvas().getContext("2d")
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const makeStyle = style.makeStyle
|
|
12
|
+
export { newView } from "./blocks.js"
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Processed by Rollup
|
|
2
|
+
|
|
3
|
+
const common = `
|
|
4
|
+
.sb3-label {
|
|
5
|
+
font: 500 12pt Helvetica Neue, Helvetica, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.sb3-literal-number,
|
|
9
|
+
.sb3-literal-string,
|
|
10
|
+
.sb3-literal-number-dropdown,
|
|
11
|
+
.sb3-literal-dropdown {
|
|
12
|
+
word-spacing: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sb3-diff {
|
|
16
|
+
fill: none;
|
|
17
|
+
stroke: #000;
|
|
18
|
+
}
|
|
19
|
+
.sb3-diff-ins {
|
|
20
|
+
stroke-width: 2px;
|
|
21
|
+
}
|
|
22
|
+
.sb3-diff-del {
|
|
23
|
+
stroke-width: 3px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Block highlight styles */
|
|
27
|
+
/* Classic highlight mode (default): yellow fill */
|
|
28
|
+
.sb3-highlight:not(.sb3-blink):not(.sb3-highlight-colorShift) {
|
|
29
|
+
fill: #FBF883 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* ColorShift highlight mode: uses alternate style colors, defined per style in create() */
|
|
33
|
+
|
|
34
|
+
/* Blinking animation for jump-to-block */
|
|
35
|
+
.sb3-blink {
|
|
36
|
+
animation: sb3-blink-animation 0.5s 3;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@keyframes sb3-blink-animation {
|
|
40
|
+
0% {
|
|
41
|
+
fill: #FBF883;
|
|
42
|
+
}
|
|
43
|
+
50% {
|
|
44
|
+
fill: #FBF883;
|
|
45
|
+
animation-timing-function: step-start;
|
|
46
|
+
}
|
|
47
|
+
100% {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
// These override colors defined per style
|
|
53
|
+
const commonOverride = `
|
|
54
|
+
/* Note: comment colors are different from Scratch. */
|
|
55
|
+
|
|
56
|
+
.sb3-comment {
|
|
57
|
+
fill: #ffffa5;
|
|
58
|
+
stroke: #d0d1d2;
|
|
59
|
+
stroke-width: 1;
|
|
60
|
+
}
|
|
61
|
+
.sb3-comment-line {
|
|
62
|
+
fill: #ffff80;
|
|
63
|
+
}
|
|
64
|
+
/* specificity */
|
|
65
|
+
.sb3-comment-label, .sb3-label.sb3-comment-label {
|
|
66
|
+
font: 400 12pt Helvetica Neue, Helvetica, sans-serif;
|
|
67
|
+
fill: #000;
|
|
68
|
+
word-spacing: 0;
|
|
69
|
+
}`
|
|
70
|
+
|
|
71
|
+
const createRule = (category, name, style) => `
|
|
72
|
+
svg${name} .sb3-${category} {
|
|
73
|
+
fill: ${style[category + "Primary"]};
|
|
74
|
+
stroke: ${style[category + "Tertiary"]};
|
|
75
|
+
}
|
|
76
|
+
svg${name} .sb3-${category}-alt {
|
|
77
|
+
fill: ${style[category + "Secondary"]};
|
|
78
|
+
}
|
|
79
|
+
svg${name} .sb3-${category}-dark {
|
|
80
|
+
fill: ${style[category + "Tertiary"]};
|
|
81
|
+
}
|
|
82
|
+
`
|
|
83
|
+
|
|
84
|
+
// Create highlight rule for colorShift mode using the alternate style's colors
|
|
85
|
+
const createHighlightRule = (category, name, alternateStyle) => `
|
|
86
|
+
svg${name} .sb3-highlight.sb3-highlight-colorShift:not(.sb3-blink).sb3-${category} {
|
|
87
|
+
fill: ${alternateStyle[category + "Primary"]} !important;
|
|
88
|
+
stroke: ${alternateStyle[category + "Tertiary"]} !important;
|
|
89
|
+
}
|
|
90
|
+
`
|
|
91
|
+
|
|
92
|
+
const create = (name, style, alternateStyle) => `
|
|
93
|
+
${createRule("motion", name, style)}
|
|
94
|
+
${createRule("looks", name, style)}
|
|
95
|
+
${createRule("sound", name, style)}
|
|
96
|
+
${createRule("control", name, style)}
|
|
97
|
+
${createRule("events", name, style)}
|
|
98
|
+
${createRule("sensing", name, style)}
|
|
99
|
+
${createRule("operators", name, style)}
|
|
100
|
+
${createRule("variables", name, style)}
|
|
101
|
+
${createRule("list", name, style)}
|
|
102
|
+
${createRule("custom", name, style)}
|
|
103
|
+
${createRule("extension", name, style)}
|
|
104
|
+
${createRule("obsolete", name, style)}
|
|
105
|
+
${createRule("grey", name, style)}
|
|
106
|
+
|
|
107
|
+
${createHighlightRule("motion", name, alternateStyle)}
|
|
108
|
+
${createHighlightRule("looks", name, alternateStyle)}
|
|
109
|
+
${createHighlightRule("sound", name, alternateStyle)}
|
|
110
|
+
${createHighlightRule("control", name, alternateStyle)}
|
|
111
|
+
${createHighlightRule("events", name, alternateStyle)}
|
|
112
|
+
${createHighlightRule("sensing", name, alternateStyle)}
|
|
113
|
+
${createHighlightRule("operators", name, alternateStyle)}
|
|
114
|
+
${createHighlightRule("variables", name, alternateStyle)}
|
|
115
|
+
${createHighlightRule("list", name, alternateStyle)}
|
|
116
|
+
${createHighlightRule("custom", name, alternateStyle)}
|
|
117
|
+
${createHighlightRule("extension", name, alternateStyle)}
|
|
118
|
+
${createHighlightRule("obsolete", name, alternateStyle)}
|
|
119
|
+
${createHighlightRule("grey", name, alternateStyle)}
|
|
120
|
+
|
|
121
|
+
svg${name} .sb3-label {
|
|
122
|
+
fill: ${style.label};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
svg${name} .sb3-input-color {
|
|
126
|
+
stroke: ${style.inputColorStroke};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
svg${name} .sb3-input-number,
|
|
130
|
+
svg${name} .sb3-input-string {
|
|
131
|
+
fill: ${style.inputFill};
|
|
132
|
+
}
|
|
133
|
+
svg${name} .sb3-literal-number,
|
|
134
|
+
svg${name} .sb3-literal-string {
|
|
135
|
+
fill: ${style.literal};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
svg${name} .sb3-custom-arg {
|
|
139
|
+
fill: ${style.customPrimary};
|
|
140
|
+
stroke: ${style.customTertiary};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
svg${name} .sb3-extension-line {
|
|
144
|
+
stroke: ${style.extensionSecondary};
|
|
145
|
+
}
|
|
146
|
+
`
|
|
147
|
+
|
|
148
|
+
const originalStyle = {
|
|
149
|
+
label: "#fff",
|
|
150
|
+
inputColorStroke: "#fff",
|
|
151
|
+
inputFill: "#fff",
|
|
152
|
+
/* Blockly color: text */
|
|
153
|
+
literal: "#575e75",
|
|
154
|
+
|
|
155
|
+
motionPrimary: "#4c97ff",
|
|
156
|
+
motionSecondary: "#4280d7",
|
|
157
|
+
motionTertiary: "#3373cc",
|
|
158
|
+
|
|
159
|
+
looksPrimary: "#9966ff",
|
|
160
|
+
looksSecondary: "#855cd6",
|
|
161
|
+
looksTertiary: "#774dcb",
|
|
162
|
+
|
|
163
|
+
soundPrimary: "#cf63cf",
|
|
164
|
+
soundSecondary: "#c94fc9",
|
|
165
|
+
soundTertiary: "#bd42bd",
|
|
166
|
+
|
|
167
|
+
controlPrimary: "#ffab19",
|
|
168
|
+
controlSecondary: "#ec9c13",
|
|
169
|
+
controlTertiary: "#cf8b17",
|
|
170
|
+
|
|
171
|
+
eventsPrimary: "#ffbf00",
|
|
172
|
+
eventsSecondary: "#e6ac00",
|
|
173
|
+
eventsTertiary: "#cc9900",
|
|
174
|
+
|
|
175
|
+
sensingPrimary: "#5cb1d6",
|
|
176
|
+
sensingSecondary: "#47a8d1",
|
|
177
|
+
sensingTertiary: "#2e8eb8",
|
|
178
|
+
|
|
179
|
+
operatorsPrimary: "#59c059",
|
|
180
|
+
operatorsSecondary: "#46b946",
|
|
181
|
+
operatorsTertiary: "#389438",
|
|
182
|
+
|
|
183
|
+
variablesPrimary: "#ff8c1a",
|
|
184
|
+
variablesSecondary: "#ff8000",
|
|
185
|
+
variablesTertiary: "#db6e00",
|
|
186
|
+
|
|
187
|
+
listPrimary: "#ff661a",
|
|
188
|
+
listSecondary: "#ff5500",
|
|
189
|
+
listTertiary: "#e64d00",
|
|
190
|
+
|
|
191
|
+
customPrimary: "#ff6680",
|
|
192
|
+
customSecondary: "#ff4d6a",
|
|
193
|
+
customTertiary: "#ff3355",
|
|
194
|
+
|
|
195
|
+
extensionPrimary: "#0fbd8c",
|
|
196
|
+
extensionSecondary: "#0da57a",
|
|
197
|
+
extensionTertiary: "#0b8e69",
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Custom color types. Not defined by Scratch.
|
|
201
|
+
*/
|
|
202
|
+
obsoletePrimary: "#ed4242",
|
|
203
|
+
obsoleteSecondary: "#db3333",
|
|
204
|
+
obsoleteTertiary: "#ca2b2b",
|
|
205
|
+
|
|
206
|
+
/* From early prototype colors */
|
|
207
|
+
greyPrimary: "#bfbfbf",
|
|
208
|
+
greySecondary: "#b2b2b2",
|
|
209
|
+
greyTertiary: "#909090",
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const highContrastStyle = {
|
|
213
|
+
label: "#000",
|
|
214
|
+
inputColorStroke: "#fff",
|
|
215
|
+
inputFill: "#fff",
|
|
216
|
+
literal: "#000",
|
|
217
|
+
|
|
218
|
+
motionPrimary: "#80b5ff",
|
|
219
|
+
motionSecondary: "#b3d2ff",
|
|
220
|
+
motionTertiary: "#3373cc",
|
|
221
|
+
|
|
222
|
+
looksPrimary: "#ccb3ff",
|
|
223
|
+
looksSecondary: "#ddccff",
|
|
224
|
+
looksTertiary: "#774dcb",
|
|
225
|
+
|
|
226
|
+
soundPrimary: "#e19de1",
|
|
227
|
+
soundSecondary: "#ffb3ff",
|
|
228
|
+
soundTertiary: "#bd42bd",
|
|
229
|
+
|
|
230
|
+
controlPrimary: "#ffbe4c",
|
|
231
|
+
controlSecondary: "#ffda99",
|
|
232
|
+
controlTertiary: "#cf8b17",
|
|
233
|
+
|
|
234
|
+
eventsPrimary: "#ffd966",
|
|
235
|
+
eventsSecondary: "#ffecb3",
|
|
236
|
+
eventsTertiary: "#cc9900",
|
|
237
|
+
|
|
238
|
+
sensingPrimary: "#85c4e0",
|
|
239
|
+
sensingSecondary: "#aed8ea",
|
|
240
|
+
sensingTertiary: "#2e8eb8",
|
|
241
|
+
|
|
242
|
+
operatorsPrimary: "#7ece7e",
|
|
243
|
+
operatorsSecondary: "#b5e3b5",
|
|
244
|
+
operatorsTertiary: "#389438",
|
|
245
|
+
|
|
246
|
+
variablesPrimary: "#ffa54c",
|
|
247
|
+
variablesSecondary: "#ffcc99",
|
|
248
|
+
variablesTertiary: "#db6e00",
|
|
249
|
+
|
|
250
|
+
listPrimary: "#ff9966",
|
|
251
|
+
listSecondary: "#ffcab0",
|
|
252
|
+
listTertiary: "#e64d00",
|
|
253
|
+
|
|
254
|
+
customPrimary: "#ff99aa",
|
|
255
|
+
customSecondary: "#ffccd5",
|
|
256
|
+
customTertiary: "#ff3355",
|
|
257
|
+
|
|
258
|
+
extensionPrimary: "#13ecaf",
|
|
259
|
+
extensionSecondary: "#75f0cd",
|
|
260
|
+
extensionTertiary: "#0b8e69",
|
|
261
|
+
|
|
262
|
+
/* Manually picked to be readable on black text */
|
|
263
|
+
obsoletePrimary: "#fc6666",
|
|
264
|
+
obsoleteSecondary: "#fcb0b0",
|
|
265
|
+
obsoleteTertiary: "#d32121",
|
|
266
|
+
|
|
267
|
+
greyPrimary: "#bfbfbf",
|
|
268
|
+
greySecondary: "#b2b2b2",
|
|
269
|
+
/* Changed to be AAA against #000000, was AA */
|
|
270
|
+
greyTertiary: "#959595",
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export default common +
|
|
274
|
+
create("", originalStyle, highContrastStyle) +
|
|
275
|
+
create(
|
|
276
|
+
".scratchblocks-style-scratch3-high-contrast",
|
|
277
|
+
highContrastStyle,
|
|
278
|
+
originalStyle,
|
|
279
|
+
) +
|
|
280
|
+
commonOverride
|