feat(ext/generator): colorize live password preview

This commit is contained in:
adlee-was-taken
2026-05-02 18:49:56 -04:00
parent 3e4312ca6f
commit f45c275566

View File

@@ -6,6 +6,7 @@
import { sendMessage } from '../../shared/state'; import { sendMessage } from '../../shared/state';
import type { GeneratorRequest, VaultSettings } from '../../shared/types'; import type { GeneratorRequest, VaultSettings } from '../../shared/types';
import { colorizePassword } from '../../shared/password-coloring';
interface UiKnobs { interface UiKnobs {
kind: 'random' | 'bip39'; kind: 'random' | 'bip39';
@@ -138,7 +139,10 @@ export function openGeneratorPanel(opts: OpenPanelOpts): void {
const d = resp.data as { password?: string; passphrase?: string }; const d = resp.data as { password?: string; passphrase?: string };
currentPreview = d.password ?? d.passphrase ?? ''; currentPreview = d.password ?? d.passphrase ?? '';
const el = host.querySelector('.preview__value'); const el = host.querySelector('.preview__value');
if (el) el.textContent = currentPreview; if (el) {
el.textContent = '';
el.appendChild(colorizePassword(currentPreview));
}
updateValidation(); updateValidation();
} }
}, 150); }, 150);