@ecomconsult/consentkit 0.5.10 → 0.5.11
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/README.md +6 -0
- package/npm/internal-stub.mjs +1 -1
- package/package.json +1 -1
- package/src/ck-core.js +1 -1
- package/src/ck-ui.js +81 -21
package/README.md
CHANGED
|
@@ -299,6 +299,12 @@ The card is `#ffffff` in light mode and `#1c1c1e` in dark. A colour the
|
|
|
299
299
|
arithmetic cannot read — a CSS colour name, an `rgb()` string — is left exactly
|
|
300
300
|
as you wrote it rather than being silently replaced.
|
|
301
301
|
|
|
302
|
+
**The preferences panel follows the banner, with no settings of its own**
|
|
303
|
+
(v0.5.11): «Сохранить выбор» is styled as `accept`, the panel's own accept and
|
|
304
|
+
reject as `settings`, and the floating button takes the `accept` button's fill
|
|
305
|
+
(its border colour when `accept` is `outline`), while the category and service
|
|
306
|
+
switches keep `theme.accent`.
|
|
307
|
+
|
|
302
308
|
The same arithmetic is exposed as pure functions on `ConsentKit._contrast`
|
|
303
309
|
(`relativeLuminance`, `contrastRatio`, `ensureContrast`, `stepToContrast`,
|
|
304
310
|
`resolveButtonStyles`, `resolveRadius`, `resolveFont`, `resolveDetails`,
|
package/npm/internal-stub.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export function undecidedState() {
|
|
|
28
28
|
*/
|
|
29
29
|
export function createStub() {
|
|
30
30
|
const stub = {
|
|
31
|
-
version: '0.5.
|
|
31
|
+
version: '0.5.11',
|
|
32
32
|
config: {},
|
|
33
33
|
init: function () { return undecidedState(); },
|
|
34
34
|
allowed: function (cat) { return cat === 'necessary'; },
|
package/package.json
CHANGED
package/src/ck-core.js
CHANGED
package/src/ck-ui.js
CHANGED
|
@@ -420,15 +420,11 @@
|
|
|
420
420
|
'border-color:var(--ck-reject-bd);border-width:var(--ck-reject-bw)}',
|
|
421
421
|
'.ck-btn--settings{background:var(--ck-settings-bg);color:var(--ck-settings-fg);',
|
|
422
422
|
'border-color:var(--ck-settings-bd);border-width:var(--ck-settings-bw)}',
|
|
423
|
-
/*
|
|
423
|
+
/* Unused by the UI since 0.5.11: the preferences panel's footer moved to
|
|
424
|
+
the accept/settings role classes above, so it follows the banner. Kept
|
|
425
|
+
as a compatibility shim for integrator CSS and older inline blocks that
|
|
426
|
+
still name these classes — nothing in this file emits them any more. */
|
|
424
427
|
'.ck-btn--filled{background:var(--ck-accent);border-color:var(--ck-accent);color:var(--ck-on-accent)}',
|
|
425
|
-
/* Live, not a fallback: these paint the preferences panel's own Accept
|
|
426
|
-
all / Reject all. Transparent fill means the LABEL sits on the card, so
|
|
427
|
-
it takes --ck-link like every other accent-coloured text; the BORDER is
|
|
428
|
-
non-text and answers to 3:1, so it keeps the raw accent. The footer's
|
|
429
|
-
background is --ck-soft rather than --ck-bg, but soft is a 5% ink mix of
|
|
430
|
-
the card — the ratio difference is well inside the noise, and a second
|
|
431
|
-
link token per background would break «один код — одни числа». */
|
|
432
428
|
'.ck-btn--outline{background:transparent;border-color:var(--ck-accent);color:var(--ck-link)}',
|
|
433
429
|
'.ck-btn--ghost{min-width:0;border-color:var(--ck-line);color:var(--ck-ink);font-weight:500}',
|
|
434
430
|
|
|
@@ -516,8 +512,12 @@
|
|
|
516
512
|
'.ck-empty{margin:8px 0 0;font-size:13px;color:var(--ck-muted)}',
|
|
517
513
|
|
|
518
514
|
/* ---- floating button ---- */
|
|
515
|
+
/* 0.5.11 — the floating button wears the ACCEPT button's colours, so the
|
|
516
|
+
one control that outlives the banner still reads as the owner's brand.
|
|
517
|
+
Both tokens are resolved once in resolveButtonStyles (`fab`) and only
|
|
518
|
+
read here — «один код — одни числа». */
|
|
519
519
|
'.ck-fab{position:fixed;left:16px;bottom:16px;z-index:2147482999;width:48px;height:48px;',
|
|
520
|
-
'border-radius:50%;border:1px solid var(--ck-line);background:var(--ck-bg);color:var(--ck-
|
|
520
|
+
'border-radius:50%;border:1px solid var(--ck-line);background:var(--ck-fab-bg);color:var(--ck-fab-fg);',
|
|
521
521
|
'display:inline-flex;align-items:center;justify-content:center;padding:0}',
|
|
522
522
|
'.ck-fab svg{width:24px;height:24px;display:block}',
|
|
523
523
|
|
|
@@ -898,7 +898,7 @@
|
|
|
898
898
|
|
|
899
899
|
/* Config values are interpolated into the TEXT of a generated stylesheet, so
|
|
900
900
|
an unvalidated value can close the declaration and open rules of its own
|
|
901
|
-
("10px;}.ck-btn--
|
|
901
|
+
("10px;}.ck-btn--reject{display:none" hides "Reject all"). config.theme is
|
|
902
902
|
not trusted input: in standalone mode it comes straight from the embedding
|
|
903
903
|
page or an integrator's admin panel, with no server-side validation
|
|
904
904
|
anywhere in the path. So every value is matched against a strict grammar
|
|
@@ -1271,9 +1271,10 @@
|
|
|
1271
1271
|
};
|
|
1272
1272
|
|
|
1273
1273
|
/* The accent as TEXT on the card. Same >= 4.5 rule, same function, one
|
|
1274
|
-
number: links,
|
|
1275
|
-
|
|
1276
|
-
|
|
1274
|
+
number: links, «Подробнее» and the cookie-table summary all read the
|
|
1275
|
+
token this produces, so none of them can drift from what the debug
|
|
1276
|
+
panel and the cabinet quote. (The floating button left this token in
|
|
1277
|
+
0.5.11 — it now follows the accept button; see `fab` below.) Note the
|
|
1277
1278
|
measurement is against cardBg — an accent that is fine inside a filled
|
|
1278
1279
|
button can still be unreadable on the card behind it.
|
|
1279
1280
|
|
|
@@ -1414,6 +1415,46 @@
|
|
|
1414
1415
|
}
|
|
1415
1416
|
out.buttons[role] = rec;
|
|
1416
1417
|
}
|
|
1418
|
+
|
|
1419
|
+
/* The floating button (0.5.11). It is a filled circle that outlives the
|
|
1420
|
+
banner, and the owner's rule is that it wears the ACCEPT button's
|
|
1421
|
+
colours — no setting of its own.
|
|
1422
|
+
|
|
1423
|
+
accept FILLED: take its bg/fg verbatim. That inherits the 0.5.10 rule
|
|
1424
|
+
for free — a typed low-contrast fg stays exactly as typed here too, and
|
|
1425
|
+
is reported through `low` rather than corrected.
|
|
1426
|
+
|
|
1427
|
+
accept OUTLINE: there is no fill to borrow, so the button's BORDER
|
|
1428
|
+
colour becomes the circle and the CARD colour becomes the icon — the
|
|
1429
|
+
outline button's two real colours, swapped. Both are derived for the
|
|
1430
|
+
fab (nobody typed "the floating button is this colour"), so the icon
|
|
1431
|
+
goes through the >= 4.5 rule; ensureContrast picks the readable member
|
|
1432
|
+
of the pair, which on a dark border is the card itself and on a pale
|
|
1433
|
+
one steps away from it. When accept's border is itself derived it is
|
|
1434
|
+
already the accent stepped to 3:1, so this is also the accent/on-accent
|
|
1435
|
+
fallback the brief describes. */
|
|
1436
|
+
var acc = out.buttons.accept;
|
|
1437
|
+
if (acc.variant === 'filled') {
|
|
1438
|
+
out.fab = {
|
|
1439
|
+
bg: acc.bg,
|
|
1440
|
+
fg: acc.fg,
|
|
1441
|
+
ratio: acc.ratio,
|
|
1442
|
+
adjusted: acc.adjusted,
|
|
1443
|
+
low: acc.low,
|
|
1444
|
+
against: acc.bg
|
|
1445
|
+
};
|
|
1446
|
+
} else {
|
|
1447
|
+
var fabBg = acc.border;
|
|
1448
|
+
var fabRes = ensureContrast(cardBg, fabBg, 4.5);
|
|
1449
|
+
out.fab = {
|
|
1450
|
+
bg: fabBg,
|
|
1451
|
+
fg: fabRes.color,
|
|
1452
|
+
ratio: fabRes.ratio,
|
|
1453
|
+
adjusted: fabRes.adjusted,
|
|
1454
|
+
low: below(fabRes.ratio, 4.5),
|
|
1455
|
+
against: fabBg
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1417
1458
|
return out;
|
|
1418
1459
|
}
|
|
1419
1460
|
|
|
@@ -1438,6 +1479,12 @@
|
|
|
1438
1479
|
// same way as __buttons: one pass per mode, so the light and dark blocks
|
|
1439
1480
|
// each carry their own contrast-checked link colour.
|
|
1440
1481
|
if (p.__link) d.push('--ck-link:' + p.__link.color);
|
|
1482
|
+
// The floating button's pair, resolved from the accept button in the same
|
|
1483
|
+
// pass, so light and dark each carry their own (0.5.11).
|
|
1484
|
+
if (p.__fab) {
|
|
1485
|
+
d.push('--ck-fab-bg:' + p.__fab.bg);
|
|
1486
|
+
d.push('--ck-fab-fg:' + p.__fab.fg);
|
|
1487
|
+
}
|
|
1441
1488
|
var btns = p.__buttons;
|
|
1442
1489
|
if (btns) {
|
|
1443
1490
|
for (var i = 0; i < BTN_ROLES.length; i++) {
|
|
@@ -1511,17 +1558,20 @@
|
|
|
1511
1558
|
light.__buttons = lightBtn.buttons;
|
|
1512
1559
|
dark.__buttons = darkBtn.buttons;
|
|
1513
1560
|
|
|
1514
|
-
// `--ck-on-accent` paints the text of
|
|
1515
|
-
// banner
|
|
1516
|
-
//
|
|
1517
|
-
//
|
|
1518
|
-
//
|
|
1561
|
+
// `--ck-on-accent` paints the text of the remaining filled surfaces that
|
|
1562
|
+
// are not banner buttons — since 0.5.11 that is the blocked-embed
|
|
1563
|
+
// placeholder's button, the panel foot and the floating button having
|
|
1564
|
+
// moved onto the accept button's own tokens. A derived onAccent still has
|
|
1565
|
+
// to pass the >= 4.5 rule against the accent, or a white accent gets white
|
|
1566
|
+
// text (the owner saw exactly that). Done AFTER the buttons are resolved, so
|
|
1519
1567
|
// the accept button still records `adjusted:true` for the same correction.
|
|
1520
1568
|
// An onAccent the owner set is painted as set — the 0.5.10 rule.
|
|
1521
1569
|
if (!light.onAccentExplicit) light.onAccent = ensureContrast(light.onAccent, light.accent, 4.5).color;
|
|
1522
1570
|
if (!dark.onAccentExplicit) dark.onAccent = ensureContrast(dark.onAccent, dark.accent, 4.5).color;
|
|
1523
1571
|
light.__link = lightBtn.link;
|
|
1524
1572
|
dark.__link = darkBtn.link;
|
|
1573
|
+
light.__fab = lightBtn.fab;
|
|
1574
|
+
dark.__fab = darkBtn.fab;
|
|
1525
1575
|
|
|
1526
1576
|
var mode = theme.mode;
|
|
1527
1577
|
if (mode !== 'light' && mode !== 'dark') mode = 'auto';
|
|
@@ -1997,11 +2047,21 @@
|
|
|
1997
2047
|
p.appendChild(body);
|
|
1998
2048
|
|
|
1999
2049
|
var foot = el('div', 'ck-panel__foot');
|
|
2000
|
-
|
|
2050
|
+
/* 0.5.11 — the panel follows the BANNER's buttons, with no setting of its
|
|
2051
|
+
own: «Сохранить выбор» is the same role as «Принять всё» and wears the
|
|
2052
|
+
accept class, «Принять всё»/«Отклонить всё» here are secondary and wear
|
|
2053
|
+
the settings («Настроить») class. Reusing the role classes means the
|
|
2054
|
+
filled/outline split stays a VALUE change in the tokens — the panel
|
|
2055
|
+
never picks a class from the resolved variant, so a theme.buttons edit
|
|
2056
|
+
is still applyTheme()-only and signature() still need not see buttons.
|
|
2057
|
+
Panel layout is untouched: `.ck-panel__foot .ck-btn{flex:1 1 150px}`
|
|
2058
|
+
(0,2,0) outranks `.ck-btn{flex:1 1 auto}` and the role classes set no
|
|
2059
|
+
flex of their own. */
|
|
2060
|
+
var save = el('button', 'ck-btn ck-btn--accept', T.save);
|
|
2001
2061
|
save.type = 'button';
|
|
2002
|
-
var acc = el('button', 'ck-btn ck-btn--
|
|
2062
|
+
var acc = el('button', 'ck-btn ck-btn--settings', T.acceptAll);
|
|
2003
2063
|
acc.type = 'button';
|
|
2004
|
-
var rej = el('button', 'ck-btn ck-btn--
|
|
2064
|
+
var rej = el('button', 'ck-btn ck-btn--settings', T.rejectAll);
|
|
2005
2065
|
rej.type = 'button';
|
|
2006
2066
|
|
|
2007
2067
|
save.addEventListener('click', function () { doSave(); });
|