@openbooknetwork/hesap 0.3.2 → 0.3.3
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/package.json +1 -1
- package/src/client.css +108 -1
- package/src/families/counters/add-figures.js +66 -0
- package/src/families/counters/add-goals.js +30 -2
- package/src/families/counters/add-model.js +60 -10
- package/src/families/counters/add.js +269 -33
- package/src/families/counters/add.mjs +85 -11
- package/src/families/counters/bar-goals.js +107 -0
- package/src/families/counters/bar-model.js +38 -0
- package/src/families/counters/bar.js +412 -0
- package/src/families/counters/bar.mjs +79 -0
- package/src/families/counters/client.css +99 -0
- package/src/families/counters/client.js +2 -1
- package/src/families/counters/counter.js +13 -0
- package/src/families/counters/facts.js +73 -0
- package/src/families/counters/i18n/en.yaml +64 -0
- package/src/families/counters/i18n/tr.yaml +64 -0
- package/src/families/counters/index.mjs +9 -7
- package/src/families/line/i18n/en.yaml +2 -0
- package/src/families/line/i18n/tr.yaml +3 -0
- package/src/families/line/index.mjs +34 -5
- package/src/families/line/line.js +34 -12
- package/src/families/line/model.js +50 -16
- package/src/i18n/en.yaml +67 -0
- package/src/i18n/tr.yaml +68 -0
- package/src/kit/goal.js +8 -1
- package/src/kit/i18n/en.yaml +1 -0
- package/src/kit/i18n/tr.yaml +1 -0
- package/src/kit/kit.css +9 -1
- package/src/kit/written.js +35 -2
|
@@ -46,7 +46,8 @@ export function opening(spec) {
|
|
|
46
46
|
// A page with start counts its jumps from the start, and its point takes the start when the page leaves it out.
|
|
47
47
|
const at = spec.point === false ? null : markOf(spec, spec.point ?? spec.start ?? spec.from);
|
|
48
48
|
return { at, base: spec.start != null ? markOf(spec, spec.start) : at, second: spec.second == null ? null : markOf(spec, spec.second), step: spec.step, checked: false, open: null,
|
|
49
|
-
cards: cardsOf(spec), placed: [], middle: spec.middle === true, find: 0, shown: false, estimate: spec.estimate ?? null, offs: offsetsOf(spec)
|
|
49
|
+
cards: cardsOf(spec), placed: [], middle: spec.middle === true, find: 0, shown: false, estimate: spec.estimate ?? null, offs: offsetsOf(spec),
|
|
50
|
+
size: spec.size ?? 1, undo: !!spec.undo, first: 0, back: false };
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
// A page with moved opens with some marks off their places. offs holds each such mark's offset, in gaps, and a mark
|
|
@@ -86,18 +87,37 @@ export function sides(s, k) {
|
|
|
86
87
|
return Math.abs(left - right) <= 2 * SETTLE + 1e-9 ? 'mark-even' : left > right ? 'mark-left' : 'mark-right';
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
// The jumps run from base to the point, one arc over
|
|
90
|
-
// takes it back.
|
|
91
|
-
|
|
92
|
-
export const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
// The jumps run from base to the point, each one arc over size gaps, all in one direction: a press against the last
|
|
91
|
+
// jump takes it back. On an undo page first is the direction of the first jump, or 0 before it, and back says the
|
|
92
|
+
// jump back is made: two arcs at most, the second from the end of the first back to base.
|
|
93
|
+
export const jumpsOf = s => s.undo ? arcsOf(s).length : s.at === null ? 0 : Math.abs(s.at - s.base) / (s.size ?? 1);
|
|
94
|
+
export function arcsOf(s) {
|
|
95
|
+
const size = s.size ?? 1;
|
|
96
|
+
if (s.undo) {
|
|
97
|
+
if (!s.first) return [];
|
|
98
|
+
const turn = s.base + s.first * size, out = [{ from: s.base, to: turn, dir: s.first }];
|
|
99
|
+
return s.back ? [...out, { from: turn, to: s.base, dir: -s.first }] : out;
|
|
100
|
+
}
|
|
101
|
+
return Array.from({ length: jumpsOf(s) }, (_, i) => {
|
|
102
|
+
const dir = Math.sign(s.at - s.base), from = s.base + i * dir * size;
|
|
103
|
+
return { from, to: from + dir * size, dir };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// jump moves the point one jump, dir 1 to the right and -1 to the left, and gives null where the jump would leave the
|
|
107
|
+
// line. On an undo page the button of the first jump's direction rests until the jump back is made, and a press after
|
|
108
|
+
// the jump back makes a new first jump from base.
|
|
97
109
|
export function jump(spec, s, dir) {
|
|
98
|
-
const
|
|
99
|
-
|
|
110
|
+
const size = s.size ?? 1, fits = k => k >= 0 && k <= gapsOf(spec), moved = { checked: false, shown: false };
|
|
111
|
+
if (s.undo) {
|
|
112
|
+
if (s.first && !s.back) return dir === s.first ? null : { ...s, ...moved, at: s.base, back: true };
|
|
113
|
+
const at = s.base + dir * size;
|
|
114
|
+
return fits(at) ? { ...s, ...moved, at, first: dir, back: false } : null;
|
|
115
|
+
}
|
|
116
|
+
const at = s.at + dir * size;
|
|
117
|
+
return fits(at) ? { ...s, ...moved, at } : null;
|
|
100
118
|
}
|
|
119
|
+
// resize sets the size of a jump, which clears the jumps and puts the point on base.
|
|
120
|
+
export const resize = (s, size) => ({ ...s, size, at: s.base, first: 0, back: false, checked: false });
|
|
101
121
|
// place puts a point on mark k after a drag. A drag of the point starts the jumps again from its new mark.
|
|
102
122
|
export const place = (s, who, k) => who === 'second' ? { ...s, second: k } : { ...s, at: k, base: k, checked: false, shown: false };
|
|
103
123
|
// show reveals where the number to find is, and next moves to the next number of the list, back to the first after
|
|
@@ -120,7 +140,9 @@ export const estimate = (s, n) => ({ ...s, estimate: n, shown: false });
|
|
|
120
140
|
// moveStart moves the start to mark k and carries the point and its arcs along, so the jumps keep their number and
|
|
121
141
|
// their direction. The start stops where the point would leave the line.
|
|
122
142
|
// On a page that counts on to the second point, the start also stops one mark left of the second point.
|
|
143
|
+
// On an undo page the start clears both jumps and takes the point along.
|
|
123
144
|
export function moveStart(spec, s, k) {
|
|
145
|
+
if (s.undo) { const base = Math.max(0, Math.min(gapsOf(spec), k)); return { ...s, base, at: base, first: 0, back: false, checked: false }; }
|
|
124
146
|
const n = gapsOf(spec), d = s.at - s.base, lo = Math.max(0, -d), hi = Math.min(n, n - d, keepsRight(spec) ? s.second - 1 : n), base = Math.max(lo, Math.min(hi, k));
|
|
125
147
|
return { ...s, base, at: base + d, checked: false };
|
|
126
148
|
}
|
|
@@ -141,7 +163,16 @@ export function writtenOf(spec, s) {
|
|
|
141
163
|
// The second point stands right of the start, so the line reads the second point minus the start.
|
|
142
164
|
return { a: numberAt(spec, s.second, s.step), sign: MINUS, b: start, open: s.at !== s.second, ids: { a: 'second', b: 'start', c: 'jumps' } };
|
|
143
165
|
}
|
|
144
|
-
|
|
166
|
+
// An undo page writes its first jump once it is made, and the number between the signs is the size of a jump.
|
|
167
|
+
if (spec.undo) return s.first ? { a: start, sign: s.first > 0 ? PLUS : MINUS, b: s.size, ids: { a: 'start', b: 'size' } } : null;
|
|
168
|
+
// Jumps of a size write the gaps they cover, which no link reads.
|
|
169
|
+
return { a: start, sign: at >= start ? PLUS : MINUS, b: Math.abs(at - start), ids: { a: 'start', b: s.size > 1 ? null : 'jumps', c: 'point' } };
|
|
170
|
+
}
|
|
171
|
+
// backOf gives the line of the jump back on an undo page once it is made, from the end of the first jump back to the
|
|
172
|
+
// start, or null.
|
|
173
|
+
export function backOf(spec, s) {
|
|
174
|
+
if (!spec.undo || !s.back) return null;
|
|
175
|
+
return { a: numberAt(spec, s.base + s.first * s.size, s.step), sign: s.first > 0 ? MINUS : PLUS, b: s.size, ids: { b: 'size', c: 'start' } };
|
|
145
176
|
}
|
|
146
177
|
// pick changes the step. Every label changes, and the point and its jumps keep their marks.
|
|
147
178
|
export const pick = (s, step) => ({ ...s, step });
|
|
@@ -171,18 +202,21 @@ export function measuresOf(spec) {
|
|
|
171
202
|
// A page that asks the reader to place a number reads out no number at the point.
|
|
172
203
|
// An unmarked line, and an estimate page, read out no number at the point either.
|
|
173
204
|
const has = spec.point !== false && spec.find == null && !isFree(spec) && spec.estimate == null;
|
|
174
|
-
|
|
205
|
+
// An undo page offers the lines of both jumps and no count of jumps, since the loop ends where it began.
|
|
206
|
+
return [...(has ? ['point'] : []), ...(spec.start != null ? ['start'] : []), ...(spec.sized ? ['size'] : []), ...(spec.written ? ['written', 'reading'] : []), ...(spec.undo ? BACK : []), ...(spec.moved ? ['gaps'] : []), ...(spec.find != null ? ['find'] : []), ...(spec.estimate != null ? ['estimate'] : []), ...(spec.middle ? ['middle'] : []), ...(spec.second != null ? ['second'] : []), ...(spec.reading ? ['reading'] : []), ...(spec.jump && !spec.undo ? ['jumps'] : []),
|
|
175
207
|
...(spec.bracket ? ['ten-before', 'ten-after'] : []), ...(spec.cards ? ['placed'] : []), 'step', 'from', 'to'];
|
|
176
208
|
}
|
|
177
|
-
|
|
178
|
-
|
|
209
|
+
export const BACK = ['written-back', 'reading-back'];
|
|
210
|
+
// The written line and its words take a readout. The words of two points and of the gaps take none, nor the line of
|
|
211
|
+
// the jump back, which the figure writes under the first.
|
|
212
|
+
export const readoutsOf = spec => measuresOf(spec).filter(id => (id !== 'reading' || spec.written) && id !== 'gaps' && !BACK.includes(id));
|
|
179
213
|
|
|
180
214
|
// counts gives every value a page can read out, as the page stands. The right end follows the step, and the ten
|
|
181
215
|
// before and the ten after read null while the point is on a ten.
|
|
182
216
|
export function counts(spec, s) {
|
|
183
217
|
const at = s.at === null ? null : numberAt(spec, s.at, s.step), tens = spec.bracket && at !== null ? tensOf(spec, s) : null;
|
|
184
218
|
return { point: at, second: s.second == null ? null : numberAt(spec, s.second, s.step), jumps: jumpsOf(s), step: s.step, from: spec.from, to: numberAt(spec, gapsOf(spec), s.step),
|
|
185
|
-
'ten-before': tens?.before ?? null, 'ten-after': tens?.after ?? null, placed: s.placed.length,
|
|
219
|
+
'ten-before': tens?.before ?? null, 'ten-after': tens?.after ?? null, placed: s.placed.length, size: s.size,
|
|
186
220
|
start: s.base === null ? null : numberAt(spec, s.base, s.step), find: findsOf(spec)[s.find] ?? null, estimate: s.estimate, middle: spec.middle ? middleOf(spec, s.step) : null };
|
|
187
221
|
}
|
|
188
222
|
|
package/src/i18n/en.yaml
CHANGED
|
@@ -20,6 +20,7 @@ hesap_written-plus: "{a} plus {b} is equal to {c}"
|
|
|
20
20
|
hesap_written-minus: "{a} minus {b} is equal to {c}"
|
|
21
21
|
hesap_written-plus-open: "{a} plus {b}"
|
|
22
22
|
hesap_written-minus-open: "{a} minus {b}"
|
|
23
|
+
hesap_facts: Facts of the family
|
|
23
24
|
counters_lead: "Tap or drag the counters and watch the numbers change."
|
|
24
25
|
counters_whole: Whole
|
|
25
26
|
counters_first: First part
|
|
@@ -218,6 +219,70 @@ counters_hint-steps-to-ten-minus: "First work out how many to take away to bring
|
|
|
218
219
|
counters_add-take-to-ten: Down to ten
|
|
219
220
|
counters_goal-steps-to-ten-minus: "Split the {second} in {calc} into the part that takes {first} down to ten and the rest, then press Check."
|
|
220
221
|
counters_add-shelf-left: Left
|
|
222
|
+
counters_add-family-first: First part
|
|
223
|
+
counters_add-family-second: Second part
|
|
224
|
+
counters_add-family-whole: Whole
|
|
225
|
+
counters_add-domino-first: First half
|
|
226
|
+
counters_add-domino-second: Second half
|
|
227
|
+
counters_add-domino-whole: Whole
|
|
228
|
+
counters_add-domino-cover: "Cover the half that shows {x}"
|
|
229
|
+
counters_add-domino-lift: Lift the card
|
|
230
|
+
counters_add-whole-whole: Whole
|
|
231
|
+
counters_add-whole-first: Known part
|
|
232
|
+
counters_add-whole-missing: Missing part
|
|
233
|
+
counters_add-whole-second: Counters put in
|
|
234
|
+
counters_add-claim: Sum
|
|
235
|
+
counters_add-claim-right: "The check gives back {first}, so the sum is right."
|
|
236
|
+
counters_add-claim-wrong: "{back} is not {first}, so the sum is wrong."
|
|
237
|
+
counters_add-squad-whole: Squad
|
|
238
|
+
counters_add-squad-first: On the pitch
|
|
239
|
+
counters_add-squad-missing: Bench seats
|
|
240
|
+
counters_add-squad-second: On the bench
|
|
241
|
+
counters_add-undo-back: Taken back
|
|
242
|
+
counters_add-undo-left: Left
|
|
243
|
+
counters_add-whole-put: Put a counter in the next place
|
|
244
|
+
counters_add-put: Put in a counter
|
|
245
|
+
counters_add-squad-put: Seat the next player on the bench
|
|
246
|
+
counters_add-squad-player: "Player {x} on the pitch"
|
|
247
|
+
counters_add-squad-bench: "Player {x} on the bench"
|
|
248
|
+
counters_add-whole-out: "Counter {x}. Take out the last counter."
|
|
249
|
+
counters_add-out: Take out the last counter
|
|
250
|
+
counters_goal-missing-part: "Put in the part that {calc} asks for, then press Check."
|
|
251
|
+
counters_goal-missing-part-done: "{line}, since {part} and {missing} make {whole}."
|
|
252
|
+
counters_note-missing-part-more: "{part} and {put} make {made}, more than {whole}."
|
|
253
|
+
counters_note-missing-part-less: "{part} and {put} make {made}, less than {whole}."
|
|
254
|
+
counters_hint-missing-part: "{calc} asks: {part} and what make {whole}? Count on from {part} to {whole} and put in a counter for each number you say."
|
|
255
|
+
counters_bar-first: First part
|
|
256
|
+
counters_bar-second: Second part
|
|
257
|
+
counters_bar-whole: Whole
|
|
258
|
+
counters_bar-chocolate-first: First piece
|
|
259
|
+
counters_bar-chocolate-second: Second piece
|
|
260
|
+
counters_bar-chocolate-whole: Squares
|
|
261
|
+
counters_bar-split: Split
|
|
262
|
+
counters_bar-end: End
|
|
263
|
+
counters_bar-cover-whole: Cover the whole
|
|
264
|
+
counters_bar-cover-first: Cover the first part
|
|
265
|
+
counters_bar-cover-second: Cover the second part
|
|
266
|
+
counters_bar-lift: Lift the card
|
|
267
|
+
counters_goal-bar-for-fact: "Set the bar model of the family of {fact}, then press Check."
|
|
268
|
+
counters_goal-bar-for-fact-done: "{whole} is the whole, and {first} and {second} are its parts."
|
|
269
|
+
counters_note-bar-for-fact-longer: "The bar is longer than the whole of {fact}."
|
|
270
|
+
counters_note-bar-for-fact-shorter: "The bar is shorter than the whole of {fact}."
|
|
271
|
+
counters_bar-use: Use them as
|
|
272
|
+
counters_bar-use-parts: the two parts
|
|
273
|
+
counters_bar-use-whole: the whole and a part
|
|
274
|
+
counters_bar-third: Third number
|
|
275
|
+
counters_note-bar-for-fact-right: "The whole is right, and the split is too far to the left for the parts of {fact}. Drag it to the right."
|
|
276
|
+
counters_note-bar-for-fact-left: "The whole is right, and the split is too far to the right for the parts of {fact}. Drag it to the left."
|
|
277
|
+
counters_hint-bar-for-fact-plus: "In {fact}, the whole comes after the = sign. Drag the end to the whole, then split it into the two parts."
|
|
278
|
+
counters_hint-bar-for-fact-minus: "In {fact}, the whole comes first. Drag the end to the whole, then split it into the other two numbers."
|
|
279
|
+
counters_goal-bar-for-two: "Find a third number that makes a family with {greater} and {less}, then press Check."
|
|
280
|
+
counters_goal-bar-for-two-done: "The family of {greater}, {less} and {mine} holds both numbers. So does the family of {greater}, {less} and {other}."
|
|
281
|
+
counters_note-bar-for-two-parts-over: "{greater} and {less} make less than {n}."
|
|
282
|
+
counters_note-bar-for-two-parts-under: "{greater} and {less} make more than {n}."
|
|
283
|
+
counters_note-bar-for-two-whole-over: "{less} and {n} make more than {greater}."
|
|
284
|
+
counters_note-bar-for-two-whole-under: "{less} and {n} make less than {greater}."
|
|
285
|
+
counters_hint-bar-for-two: "A family holds a whole and two parts. Use {greater} and {less} as the two parts and add them, or use {greater} as the whole and {less} as a part and find the missing part."
|
|
221
286
|
line_lead: "Move the point along the line and read the number at its mark."
|
|
222
287
|
line_jump-left: Jump left
|
|
223
288
|
line_jump-right: Jump right
|
|
@@ -279,3 +344,5 @@ line_hint-jump-minus-one: "Start at {start}. Press Jump left once and say the nu
|
|
|
279
344
|
line_note-jump-way-plus: "{calc} is an addition, so the jumps go to the right from {start}."
|
|
280
345
|
line_note-jump-way-minus: "{calc} is a subtraction, so the jumps go to the left from {start}."
|
|
281
346
|
line_note-jump-few-none: "The point is still on {start}. Make the jumps for {calc} from there."
|
|
347
|
+
line_size: Size of a jump
|
|
348
|
+
line_size-short: Size
|
package/src/i18n/tr.yaml
CHANGED
|
@@ -20,6 +20,7 @@ hesap_written-plus: "{a} artı {b} eşittir {c}"
|
|
|
20
20
|
hesap_written-minus: "{a} eksi {b} eşittir {c}"
|
|
21
21
|
hesap_written-plus-open: "{a} artı {b}"
|
|
22
22
|
hesap_written-minus-open: "{a} eksi {b}"
|
|
23
|
+
# hesap_facts waits for the word of "fact family (calculations)" in the book's i18n/terms/tr.yaml, and reads English until then.
|
|
23
24
|
counters_lead: "Sayaçlara dokunun, onları sürükleyin ve sayıların onları nasıl izlediğine bakın."
|
|
24
25
|
counters_whole: Bütün
|
|
25
26
|
counters_first: Birinci parça
|
|
@@ -218,6 +219,70 @@ counters_hint-steps-to-ten-minus: "Ona kadar, {first} sayısının dolu onluğun
|
|
|
218
219
|
counters_add-take-to-ten: Ona kadar
|
|
219
220
|
counters_goal-steps-to-ten-minus: "{calc} için Ona kadar ve Diğer parça düğmelerini ayarlayın, sonra Kontrol et düğmesine basın."
|
|
220
221
|
counters_add-shelf-left: Kalan
|
|
222
|
+
counters_add-family-first: Birinci parça
|
|
223
|
+
counters_add-family-second: İkinci parça
|
|
224
|
+
counters_add-family-whole: Bütün
|
|
225
|
+
counters_add-domino-first: Birinci yarı
|
|
226
|
+
counters_add-domino-second: İkinci yarı
|
|
227
|
+
counters_add-domino-whole: Bütün
|
|
228
|
+
counters_add-domino-cover: "{x} gösteren yarıyı kapat"
|
|
229
|
+
counters_add-domino-lift: Kartı kaldır
|
|
230
|
+
counters_add-whole-whole: Bütün
|
|
231
|
+
counters_add-whole-first: Bilinen parça
|
|
232
|
+
counters_add-whole-missing: Bilinmeyen parça
|
|
233
|
+
counters_add-whole-second: Konan sayaçlar
|
|
234
|
+
counters_add-claim: Toplam
|
|
235
|
+
counters_add-claim-right: "Çıkarma işlemi {first} sayısını geri veriyor, yani toplam doğru."
|
|
236
|
+
counters_add-claim-wrong: "{back}, {first} sayısına eşit değil, yani toplam yanlış."
|
|
237
|
+
counters_add-squad-whole: Kadro
|
|
238
|
+
counters_add-squad-first: Sahada
|
|
239
|
+
counters_add-squad-missing: Kulübedeki yerler
|
|
240
|
+
counters_add-squad-second: Kulübede
|
|
241
|
+
counters_add-undo-back: Geri alınan
|
|
242
|
+
counters_add-undo-left: Kalan
|
|
243
|
+
counters_add-whole-put: Sonraki yere bir sayaç koy
|
|
244
|
+
counters_add-put: Bir sayaç koy
|
|
245
|
+
counters_add-squad-put: Sıradaki oyuncuyu kulübeye oturt
|
|
246
|
+
counters_add-squad-player: "Sahadaki {x} numaralı oyuncu"
|
|
247
|
+
counters_add-squad-bench: "Kulübedeki {x} numaralı oyuncu"
|
|
248
|
+
counters_add-whole-out: "{x} numaralı sayaç. Son sayacı geri al."
|
|
249
|
+
counters_add-out: Son sayacı geri al
|
|
250
|
+
counters_goal-missing-part: "{calc} işleminin sorduğu parçayı koyun, sonra Kontrol et düğmesine basın."
|
|
251
|
+
counters_goal-missing-part-done: "{line}, çünkü {part} ile {missing}, {whole} eder."
|
|
252
|
+
counters_note-missing-part-more: "{part} ile {put}, {made} eder. Bu, {whole} sayısından büyük."
|
|
253
|
+
counters_note-missing-part-less: "{part} ile {put}, {made} eder. Bu, {whole} sayısından küçük."
|
|
254
|
+
counters_hint-missing-part: "{calc} şunu sorar: {part} ile kaç, {whole} eder? {part} sayısından {whole} sayısına kadar ileri sayın ve söylediğiniz her sayı için bir sayaç koyun."
|
|
255
|
+
counters_bar-first: Birinci parça
|
|
256
|
+
counters_bar-second: İkinci parça
|
|
257
|
+
counters_bar-whole: Bütün
|
|
258
|
+
counters_bar-chocolate-first: Birinci parça
|
|
259
|
+
counters_bar-chocolate-second: İkinci parça
|
|
260
|
+
counters_bar-chocolate-whole: Kareler
|
|
261
|
+
counters_bar-cover-whole: Bütünü kapat
|
|
262
|
+
counters_bar-cover-first: Birinci parçayı kapat
|
|
263
|
+
counters_bar-cover-second: İkinci parçayı kapat
|
|
264
|
+
counters_bar-lift: Kartı kaldır
|
|
265
|
+
counters_goal-bar-for-fact-done: "Bütün {whole}, parçaları {first} ve {second}."
|
|
266
|
+
# waits: counters_bar-split, for "split (bar model)" in the book's i18n/terms/tr.yaml
|
|
267
|
+
# waits: counters_bar-end, for "end (bar model)"
|
|
268
|
+
# waits: counters_goal-bar-for-fact, for "bar model (figure)" and "fact family (calculations)"
|
|
269
|
+
# waits: counters_note-bar-for-fact-longer, for "bar model (figure)"
|
|
270
|
+
# waits: counters_note-bar-for-fact-shorter, for "bar model (figure)"
|
|
271
|
+
counters_bar-use: Sayılar
|
|
272
|
+
counters_bar-use-parts: iki parça
|
|
273
|
+
counters_bar-use-whole: bütün ve bir parça
|
|
274
|
+
counters_bar-third: Üçüncü sayı
|
|
275
|
+
# waits: counters_note-bar-for-fact-right, for "split (bar model)"
|
|
276
|
+
# waits: counters_note-bar-for-fact-left, for "split (bar model)"
|
|
277
|
+
# waits: counters_hint-bar-for-fact-plus, for "end (bar model)" and "split (bar model)"
|
|
278
|
+
# waits: counters_hint-bar-for-fact-minus, for "end (bar model)" and "split (bar model)"
|
|
279
|
+
counters_note-bar-for-two-parts-over: "{greater} ile {less}, {n} sayısından küçük bir sayı eder."
|
|
280
|
+
counters_note-bar-for-two-parts-under: "{greater} ile {less}, {n} sayısından büyük bir sayı eder."
|
|
281
|
+
counters_note-bar-for-two-whole-over: "{less} ile {n}, {greater} sayısından büyük bir sayı eder."
|
|
282
|
+
counters_note-bar-for-two-whole-under: "{less} ile {n}, {greater} sayısından küçük bir sayı eder."
|
|
283
|
+
# waits: counters_goal-bar-for-two, for "fact family (calculations)"
|
|
284
|
+
# waits: counters_goal-bar-for-two-done, for "fact family (calculations)"
|
|
285
|
+
# waits: counters_hint-bar-for-two, for "fact family (calculations)"
|
|
221
286
|
line_lead: "Noktayı doğru boyunca hareket ettirin ve çizgisindeki sayıyı okuyun."
|
|
222
287
|
line_jump-left: Sola zıpla
|
|
223
288
|
line_jump-right: Sağa zıpla
|
|
@@ -279,3 +344,6 @@ line_hint-jump-minus-one: "Başlangıçtaki sayıyı söyleyin, sonra her zıpla
|
|
|
279
344
|
line_note-jump-way-plus: Nokta yanlış yöne zıpladı.
|
|
280
345
|
line_note-jump-way-minus: Nokta yanlış yöne zıpladı.
|
|
281
346
|
line_note-jump-few-none: Zıplamalar az.
|
|
347
|
+
# The Turkish words wait for the term "jump (number line)", which the book's i18n/terms/tr.yaml has not sourced yet.
|
|
348
|
+
line_size: Size of a jump
|
|
349
|
+
line_size-short: Size
|
package/src/kit/goal.js
CHANGED
|
@@ -10,6 +10,10 @@ export function goalRow({ T, hint, another, motion, actions = [], quiet = false
|
|
|
10
10
|
const text = h('p', { class: 'hesap-goal-text' }), state = h('span', { class: 'hesap-goal-state', role: 'status' });
|
|
11
11
|
const hintText = h('p', { class: 'hesap-hint', hidden: true });
|
|
12
12
|
let done = false, hinted = false;
|
|
13
|
+
// hold keeps the goal line and the status at the tallest they have been on this page, so the panel keeps its
|
|
14
|
+
// height as the goal line, a note and the done line take turns, and the figure above does not rebuild.
|
|
15
|
+
const tallest = new Map();
|
|
16
|
+
const hold = node => { node.style.minHeight = ''; const h = Math.max(node.offsetHeight, tallest.get(node) ?? 0); tallest.set(node, h); if (h) node.style.minHeight = `${h}px`; };
|
|
13
17
|
// A hint is words, or an element the family built, such as a formula. kept says the hint opens again after a
|
|
14
18
|
// change of language, so the family shows it without marking it as new.
|
|
15
19
|
const toggle = kept => {
|
|
@@ -23,13 +27,14 @@ export function goalRow({ T, hint, another, motion, actions = [], quiet = false
|
|
|
23
27
|
return {
|
|
24
28
|
el, text, hintText,
|
|
25
29
|
// say writes the goal. A family that sets formulas in the goal writes into text itself.
|
|
26
|
-
say(words) { if (words instanceof Node) text.replaceChildren(words); else if (text.textContent !== (words ?? '')) text.textContent = words ?? ''; },
|
|
30
|
+
say(words) { if (words instanceof Node) text.replaceChildren(words); else if (text.textContent !== (words ?? '')) text.textContent = words ?? ''; hold(text); },
|
|
27
31
|
// show says whether the goal is reached. note is a line of progress for a goal not reached yet. It returns true
|
|
28
32
|
// the first time the goal is reached, when the family cheers.
|
|
29
33
|
show(reached, note) {
|
|
30
34
|
const words = reached ? T('solved') : note ?? (quiet ? '' : T('not-yet'));
|
|
31
35
|
if (state.dataset.words !== words) { state.dataset.words = words; state.replaceChildren(...(reached ? [icon('tick'), h('b', {}, words)] : [words])); }
|
|
32
36
|
el.classList.toggle('solved', reached);
|
|
37
|
+
hold(state);
|
|
33
38
|
const first = reached && !done; done = reached;
|
|
34
39
|
if (first) motion?.pop(state);
|
|
35
40
|
return first;
|
|
@@ -43,6 +48,8 @@ export function goalRow({ T, hint, another, motion, actions = [], quiet = false
|
|
|
43
48
|
done = old.reached();
|
|
44
49
|
if (old.hinted() && hintBtn && !hinted) toggle(true);
|
|
45
50
|
},
|
|
51
|
+
// closeHint closes an open hint, for a family whose figure needs the room once the goal is reached.
|
|
52
|
+
closeHint() { if (hinted) toggle(false); },
|
|
46
53
|
// reset closes the hint and forgets the last result, for another target.
|
|
47
54
|
reset() { done = false; hinted = false; hintBtn?.setAttribute('aria-expanded', 'false'); hintText.hidden = true; },
|
|
48
55
|
};
|
package/src/kit/i18n/en.yaml
CHANGED
package/src/kit/i18n/tr.yaml
CHANGED
|
@@ -20,3 +20,4 @@ hesap_written-plus: "{a} artı {b} eşittir {c}"
|
|
|
20
20
|
hesap_written-minus: "{a} eksi {b} eşittir {c}"
|
|
21
21
|
hesap_written-plus-open: "{a} artı {b}"
|
|
22
22
|
hesap_written-minus-open: "{a} eksi {b}"
|
|
23
|
+
# hesap_facts waits for the word of "fact family (calculations)" in the book's i18n/terms/tr.yaml, and reads English until then.
|
package/src/kit/kit.css
CHANGED
|
@@ -59,7 +59,7 @@ button.hesap-chip{cursor:pointer;min-height:36px;align-items:center}
|
|
|
59
59
|
/* A challenge's line holds the goal, whether it is reached, another target and a hint. The goal takes a line of its
|
|
60
60
|
own, so a longer status keeps the panel's height. */
|
|
61
61
|
.hesap-goal{display:flex;flex-wrap:wrap;align-items:center;gap:.286rem .571rem}
|
|
62
|
-
.hesap-goal-text{margin:0;flex-basis:100%;font-weight:600}
|
|
62
|
+
.hesap-goal-text{margin:0;flex-basis:100%;font-weight:600;line-height:1.4}
|
|
63
63
|
.hesap-goal-state{display:inline-flex;align-items:center;gap:.286rem;color:var(--ink-2);flex:1;min-width:0}
|
|
64
64
|
.hesap-goal.solved .hesap-goal-state{color:var(--accent)}
|
|
65
65
|
.hesap-goal-state svg{width:20px;height:20px}
|
|
@@ -79,6 +79,10 @@ aside.story .place[data-formula] .katex-display>.katex{text-align:start}
|
|
|
79
79
|
.hesap-btn,.hesap-seg button,.hesap-step button{min-height:42px}
|
|
80
80
|
.hesap-chip{padding:.214rem .643rem}
|
|
81
81
|
.hesap-chip small{font-size:.786rem}
|
|
82
|
+
/* On a phone the goal line and the status keep room for two lines each, and the status takes a line of its own,
|
|
83
|
+
so a note or the done line leaves the panel's height as it was. */
|
|
84
|
+
.hesap-goal-text{min-height:2.8em}
|
|
85
|
+
.hesap-goal-state{flex-basis:100%;min-height:2.8em;line-height:1.4}
|
|
82
86
|
.hesap-long{display:none}
|
|
83
87
|
.hesap-short{display:inline}
|
|
84
88
|
/* A compact button shows its glyph alone. */
|
|
@@ -96,3 +100,7 @@ aside.story .place[data-formula] .katex-display>.katex{text-align:start}
|
|
|
96
100
|
.hesap .hesap-written [data-ref]{stroke:none}
|
|
97
101
|
.hesap .hesap-written .hesap-written-num{fill:var(--c,var(--ink))}
|
|
98
102
|
.hesap .hesap-written .hesap-written-hot,.hesap .hesap-written.hesap-written-hot{text-decoration:underline}
|
|
103
|
+
|
|
104
|
+
/* A number sentence or a calculation written in the text, marked up as code: it stays on one line and stands out from
|
|
105
|
+
the words around it, in the text's own font, in the text and on the folded card. */
|
|
106
|
+
:is(aside.story,.peek) code{font:inherit;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;padding:.071rem .357rem;border-radius:4px;background:color-mix(in srgb,var(--accent) 14%,transparent)}
|
package/src/kit/written.js
CHANGED
|
@@ -5,8 +5,8 @@ import { svg as el } from './dom.js';
|
|
|
5
5
|
|
|
6
6
|
export const PLUS = '+', MINUS = '−';
|
|
7
7
|
// A line is { a, sign, b }, the number before the sign, the sign and the number after it. A line with open: true
|
|
8
|
-
// leaves out its answer.
|
|
9
|
-
export const answerOf = line => line.sign === PLUS ? line.a + line.b : line.a - line.b;
|
|
8
|
+
// leaves out its answer, and a line with c writes c as its answer, such as a sum a reader claims.
|
|
9
|
+
export const answerOf = line => line.c ?? (line.sign === PLUS ? line.a + line.b : line.a - line.b);
|
|
10
10
|
|
|
11
11
|
// parts gives the pieces of a line in order. A number carries its role: a and b for the numbers either side of the
|
|
12
12
|
// sign, and c for the answer.
|
|
@@ -23,6 +23,39 @@ export const readingKey = line => `written-${line.sign === PLUS ? 'plus' : 'minu
|
|
|
23
23
|
// hesap_, as a family's T does in the browser.
|
|
24
24
|
export const reading = (line, int, T) => T(readingKey(line), { a: int(line.a), b: int(line.b), c: int(answerOf(line)) });
|
|
25
25
|
|
|
26
|
+
// The facts of a family: a whole and its two parts give the two parts added in either order and either part
|
|
27
|
+
// subtracted from the whole. FACTS are their link ids in the order a figure writes them, the additions first.
|
|
28
|
+
export const FACTS = ['written', 'written-swap', 'written-minus-second', 'written-minus-first'];
|
|
29
|
+
// The reading of a fact takes the id of the fact with reading for written, such as reading-swap.
|
|
30
|
+
export const readingOf = id => id.replace(/^written/, 'reading');
|
|
31
|
+
export const writtenOf = id => id.replace(/^reading/, 'written');
|
|
32
|
+
// FACT_IDS are the eight links a page that writes the facts offers.
|
|
33
|
+
export const FACT_IDS = [...FACTS, ...FACTS.map(readingOf)];
|
|
34
|
+
// The link id of each number of a fact, by its role in the line.
|
|
35
|
+
const REFS = { written: { a: 'first', b: 'second', c: 'whole' }, 'written-swap': { a: 'second', b: 'first', c: 'whole' },
|
|
36
|
+
'written-minus-second': { a: 'whole', b: 'second', c: 'first' }, 'written-minus-first': { a: 'whole', b: 'first', c: 'second' } };
|
|
37
|
+
// factsOf gives the four facts of a first part and a second part as lines, each carrying the link ids of its numbers.
|
|
38
|
+
export function factsOf(first, second) {
|
|
39
|
+
const whole = first + second;
|
|
40
|
+
return { written: { a: first, sign: PLUS, b: second, refs: REFS.written }, 'written-swap': { a: second, sign: PLUS, b: first, refs: REFS['written-swap'] },
|
|
41
|
+
'written-minus-second': { a: whole, sign: MINUS, b: second, refs: REFS['written-minus-second'] }, 'written-minus-first': { a: whole, sign: MINUS, b: first, refs: REFS['written-minus-first'] } };
|
|
42
|
+
}
|
|
43
|
+
// factLine gives the line of a fact id or of its reading.
|
|
44
|
+
export const factLine = (id, first, second) => factsOf(first, second)[writtenOf(id)];
|
|
45
|
+
// sameFact gives the fact that shows for an id. Two equal parts give two facts, so the swap is the first addition and
|
|
46
|
+
// the whole minus the first part is the whole minus the second.
|
|
47
|
+
export const sameFact = (id, first, second) => first !== second ? writtenOf(id) : writtenOf(id) === 'written-swap' ? 'written' : writtenOf(id) === 'written-minus-first' ? 'written-minus-second' : writtenOf(id);
|
|
48
|
+
// shownFacts gives the facts a figure writes out of the ones a page lists, each once.
|
|
49
|
+
export const shownFacts = (first, second, listed = FACTS) => FACTS.filter(id => listed.includes(id) && sameFact(id, first, second) === id);
|
|
50
|
+
// takenBy gives the part a subtraction takes away from the whole, and null for an addition.
|
|
51
|
+
export const takenBy = id => ({ 'written-minus-second': 'second', 'written-minus-first': 'first' })[writtenOf(id)] ?? null;
|
|
52
|
+
// finding gives the calculation that finds a covered number: the first part plus the second part for the whole, and
|
|
53
|
+
// the whole minus the other part for a part. open leaves out its answer while the number is covered.
|
|
54
|
+
export function finding(first, second, covered, open) {
|
|
55
|
+
const id = covered === 'whole' ? 'written' : covered === 'first' ? 'written-minus-second' : 'written-minus-first';
|
|
56
|
+
return { ...factsOf(first, second)[id], open };
|
|
57
|
+
}
|
|
58
|
+
|
|
26
59
|
// The size of a written line in a figure's units, the size of the numbers of the line of two numbers in counters/match.
|
|
27
60
|
export const SIZE = 34;
|
|
28
61
|
// The size of a step line.
|