styleproof 1.7.0 → 1.7.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.7.1]
11
+
12
+ ### Fixed
13
+
14
+ - A colour bullet no longer repeats a role word that matches its token name
15
+ (`text \`text\` (#bfe9f5)` becomes `` `text` (`#bfe9f5`) ``).
16
+ - When several same-label elements fold but share no change, the line names the
17
+ most common changes (`e.g. … _(vary)_`) instead of an uninformative
18
+ `restyled _(details vary)_`.
19
+
10
20
  ## [1.7.0]
11
21
 
12
22
  Colour changes are named by their theme token, shown as hex with a live swatch,
package/dist/describe.js CHANGED
@@ -198,6 +198,8 @@ const colorRule = (m, mark, ctx) => {
198
198
  ['border-color', 'border colour'],
199
199
  ];
200
200
  const sh = (c) => shift(c.before, c.after, ctx.tokensBefore, ctx.tokensAfter);
201
+ // Collapse a role word that just repeats the token name: `text \`text\`` → `\`text\``.
202
+ const deRole = (s) => s.replace(/([\w-]+) (`\1`)/g, '$2');
201
203
  const present = fields.map(([p, w]) => [m.get(p), w]).filter(([c]) => c);
202
204
  if (!present.length)
203
205
  return [];
@@ -205,8 +207,8 @@ const colorRule = (m, mark, ctx) => {
205
207
  const same = present.length > 1 && present.every(([c]) => c.before === first[0].before && c.after === first[0].after);
206
208
  fields.forEach(([p]) => m.has(p) && mark(p));
207
209
  if (same)
208
- return [`recoloured ${sh(first[0])}`];
209
- return present.map(([c, w]) => `${w} ${sh(c)}`);
210
+ return [deRole(`recoloured ${sh(first[0])}`)];
211
+ return present.map(([c, w]) => deRole(`${w} ${sh(c)}`));
210
212
  };
211
213
  const fillRule = (m, mark) => {
212
214
  const bgi = m.get('background-image');
@@ -306,14 +308,25 @@ function domVerbLines(els) {
306
308
  return Object.entries(verbs).map(([verb, n]) => `**${n}** element${n === 1 ? '' : 's'} ${verb}`);
307
309
  }
308
310
  const sig = (phrases) => phrases.join(', ');
309
- /** One line for a same-label group: the shared phrases (or the single line),
310
- * flagged `(details vary)` when members aren't identical. */
311
+ /** One line for a same-label group. Identical members their line. Otherwise the
312
+ * phrases shared by ALL (`details vary`); and if they share none, the most common
313
+ * phrases (`e.g. … vary`) so the line still tells you what to look for. */
311
314
  function foldedLine(group, ctx) {
312
315
  const lists = group.map((el) => phrasesFor(el.props, ctx));
313
316
  if (lists.every((l) => sig(l) === sig(lists[0])))
314
317
  return sig(lists[0]);
315
318
  const common = lists[0].filter((p) => lists.every((l) => l.includes(p)));
316
- return common.length ? `${common.join(', ')} _(details vary)_` : 'restyled _(details vary)_';
319
+ if (common.length)
320
+ return `${common.join(', ')} _(details vary)_`;
321
+ const freq = new Map();
322
+ for (const l of lists)
323
+ for (const p of new Set(l))
324
+ freq.set(p, (freq.get(p) ?? 0) + 1);
325
+ const top = [...freq.entries()]
326
+ .sort((a, b) => b[1] - a[1])
327
+ .slice(0, 3)
328
+ .map(([p]) => p);
329
+ return top.length ? `e.g. ${top.join(', ')} _(vary)_` : 'restyled _(vary)_';
317
330
  }
318
331
  /** Restyle phrases, folded by element label (so two near-identical `span.led`s
319
332
  * become one `×2` line with their shared changes), then deduped across labels (so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styleproof",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Catch every CSS change before it ships — review PRs and certify refactors by the browser's computed styles, not pixels. Works with any styling system.",
5
5
  "keywords": [
6
6
  "playwright",