@cognitiv-traits/traitos-ui 0.0.0-stage → 0.2.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/src/theme.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Shared styles. Everything is driven by CSS custom properties, so a page themes the components from outside the shadow DOM:
3
+ *
4
+ * traitos-softphone { --traitos-accent: #0a7; --traitos-radius: 4px; }
5
+ *
6
+ * Dark mode follows `prefers-color-scheme`; force it with `theme="dark"` or `theme="light"` on an element. Any `--traitos-*`
7
+ * variable you set still wins over the built-in palette in either mode.
8
+ */
9
+ export const baseCss = `
10
+ :host { display: block; font: var(--traitos-font, 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif); color: var(--traitos-text, var(--_text));
11
+ --_text: #1b1f24; --_accent: var(--traitos-accent, #4f46e5); --_bg: var(--traitos-bg, #fff); --_alt: var(--traitos-key-bg, #f4f6f8); --_muted: var(--traitos-muted, #5b6470); --_line: var(--traitos-line, #d8dde3);
12
+ --_ok: var(--traitos-ok, #137a3d); --_warn: var(--traitos-warn, #a15c00); --_bad: var(--traitos-danger, #b3261e); --_r: var(--traitos-radius, 10px); --_wa: var(--traitos-whatsapp, #137a3d); --_ph: var(--traitos-phone, #0b6bb5);
13
+ --_accfill: var(--traitos-accent, #4f46e5); --_okfill: var(--traitos-ok, #137a3d); --_badfill: var(--traitos-danger, #b3261e); }
14
+ @media (prefers-color-scheme: dark) { :host(:not([theme=light])) { --_text: #e8ebef; --_accent: var(--traitos-accent, #8b87ff); --_bg: var(--traitos-bg, #181b20); --_alt: var(--traitos-key-bg, #232830); --_muted: var(--traitos-muted, #a4adb9); --_line: var(--traitos-line, #343b45);
15
+ --_ok: var(--traitos-ok, #4cc57e); --_warn: var(--traitos-warn, #e0a23a); --_bad: var(--traitos-danger, #ff7a70); --_wa: var(--traitos-whatsapp, #1f8a4d); --_ph: var(--traitos-phone, #2b7fc9);
16
+ --_accfill: var(--traitos-accent, #5b57d6); --_okfill: var(--traitos-ok, #1b7f45); --_badfill: var(--traitos-danger, #c9372c); } }
17
+ :host([theme=dark]) { --_text: #e8ebef; --_accent: var(--traitos-accent, #8b87ff); --_bg: var(--traitos-bg, #181b20); --_alt: var(--traitos-key-bg, #232830); --_muted: var(--traitos-muted, #a4adb9); --_line: var(--traitos-line, #343b45);
18
+ --_ok: var(--traitos-ok, #4cc57e); --_warn: var(--traitos-warn, #e0a23a); --_bad: var(--traitos-danger, #ff7a70); --_wa: var(--traitos-whatsapp, #1f8a4d); --_ph: var(--traitos-phone, #2b7fc9);
19
+ --_accfill: var(--traitos-accent, #5b57d6); --_okfill: var(--traitos-ok, #1b7f45); --_badfill: var(--traitos-danger, #c9372c); }
20
+ * { box-sizing: border-box; }
21
+ .card { background: var(--_bg); border: 1px solid var(--_line); border-radius: var(--_r); padding: 16px; }
22
+ h2 { font-size: 15px; margin: 0 0 4px; } h3 { font-size: 13px; margin: 16px 0 6px; color: var(--_muted); text-transform: uppercase; letter-spacing: .04em; }
23
+ p.hint, .hint { color: var(--_muted); font-size: 12.5px; margin: 2px 0 8px; }
24
+ label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
25
+ input, select, textarea { width: 100%; font: inherit; color: inherit; background: var(--_bg); border: 1px solid var(--_line); border-radius: calc(var(--_r) - 4px); padding: 7px 9px; }
26
+ input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--_accent); outline-offset: 2px; }
27
+ input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--_bad); }
28
+ input[type=checkbox], input[type=radio] { width: auto; margin-right: 6px; }
29
+ .row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; } .row > * { flex: 1 1 120px; } .row > .fixed { flex: 0 0 auto; }
30
+ button { font: inherit; cursor: pointer; border-radius: calc(var(--_r) - 4px); border: 1px solid var(--_line); background: var(--_bg); color: inherit; padding: 7px 12px; }
31
+ button.primary { background: var(--_accfill); border-color: var(--_accfill); color: #fff; }
32
+ button.danger { background: var(--_badfill); border-color: var(--_badfill); color: #fff; }
33
+ button.ok { background: var(--_okfill); border-color: var(--_okfill); color: #fff; }
34
+ button:disabled { opacity: .5; cursor: not-allowed; }
35
+ @media (pointer: coarse) { button, select, input:not([type=checkbox]):not([type=radio]) { min-height: 44px; } }
36
+ .err { color: var(--_bad); font-size: 12.5px; margin: 3px 0 0; }
37
+ .status { padding: 8px 10px; border-radius: calc(var(--_r) - 4px); background: color-mix(in srgb, var(--_accent) 8%, transparent); }
38
+ .status.bad { background: color-mix(in srgb, var(--_bad) 10%, transparent); color: var(--_bad); }
39
+ .status.ok { background: color-mix(in srgb, var(--_ok) 10%, transparent); color: var(--_ok); }
40
+ .pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--_line); color: var(--_muted); }
41
+ .bar { height: 8px; border-radius: 99px; background: var(--_line); overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--_accent); }
42
+ .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
43
+ .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
44
+ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
45
+ `;
46
+
47
+ /** Keypad and call-control styles shared by the softphone, the widget and <traitos-keypad>. Touch targets are at least 44px. */
48
+ export const keypadCss = `
49
+ .kp { display: flex; flex-direction: column; gap: 8px; }
50
+ .kp-row { display: flex; align-items: center; gap: 6px; }
51
+ .kp-num { flex: 1; min-width: 0; font-size: 18px; letter-spacing: .5px; text-align: center; min-height: 44px; }
52
+ .kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
53
+ .kp-key { min-height: 52px; min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; background: var(--_alt); border-radius: var(--_r); touch-action: manipulation; }
54
+ .kp-key b { font-size: 20px; font-weight: 600; } .kp-key i { font-style: normal; font-size: 9px; letter-spacing: 1px; color: var(--_muted); min-height: 10px; }
55
+ .kp-back { min-width: 44px; min-height: 44px; }
56
+ .kp-calls { display: flex; gap: 6px; } .kp-call { flex: 1; min-height: 46px; color: #fff; font-weight: 600; border: 0; }
57
+ .kp-call[data-channel=whatsapp] { background: var(--_wa); } .kp-call[data-channel=phone] { background: var(--_ph); }
58
+ .kp-note { font-size: 12px; text-align: center; color: var(--_muted); margin: 0; } .kp-note.warn { color: var(--_warn); }
59
+ .btns { display: flex; gap: 8px; margin-top: 12px; } .btns button { flex: 1; min-height: 44px; padding: 10px; }
60
+ .who { font-size: 18px; font-weight: 600; margin: 10px 0 2px; overflow-wrap: anywhere; } .timer { font-variant-numeric: tabular-nums; color: var(--_muted); }
61
+ .recent-list { list-style: none; margin: 6px 0 0; padding: 0; } .recent-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--_line); }
62
+ .recent-list button { min-height: 44px; flex: 1; text-align: left; border: 0; background: none; padding: 4px 2px; } .recent-list .miss { color: var(--_bad); }
63
+ `;