Sanitized mirror from private repository - 2026-04-19 08:18:25 UTC
This commit is contained in:
96
hosts/physical/concord-nuc/homeassistant/www/assist-fix.js
Normal file
96
hosts/physical/concord-nuc/homeassistant/www/assist-fix.js
Normal file
@@ -0,0 +1,96 @@
|
||||
// Assist dialog input-field readability patch
|
||||
// Targets ha-voice-command-dialog's text input and forces theme-driven colors,
|
||||
// since HA's own theme variables don't reach the nested mwc-textfield shadow root.
|
||||
(function () {
|
||||
if (window.__assistFixLoaded) return;
|
||||
window.__assistFixLoaded = true;
|
||||
|
||||
const css = `
|
||||
:host .mdc-text-field,
|
||||
:host .mdc-text-field--filled,
|
||||
.mdc-text-field,
|
||||
.mdc-text-field--filled {
|
||||
background-color: var(--card-background-color, rgba(22, 24, 40, 0.92)) !important;
|
||||
border-radius: 8px !important;
|
||||
}
|
||||
:host .mdc-text-field__input,
|
||||
.mdc-text-field__input,
|
||||
:host input,
|
||||
input {
|
||||
color: var(--primary-text-color, #e7e9f4) !important;
|
||||
caret-color: var(--primary-text-color, #e7e9f4) !important;
|
||||
}
|
||||
:host .mdc-floating-label,
|
||||
.mdc-floating-label,
|
||||
:host .mdc-text-field__affix,
|
||||
.mdc-text-field__affix {
|
||||
color: var(--secondary-text-color, #9a9cb8) !important;
|
||||
}
|
||||
:host .mdc-line-ripple::before,
|
||||
.mdc-line-ripple::before {
|
||||
border-bottom-color: var(--divider-color, rgba(255, 255, 255, 0.18)) !important;
|
||||
}
|
||||
`;
|
||||
|
||||
function walkShadow(root, depth = 0) {
|
||||
if (!root || depth > 8) return [];
|
||||
const found = [];
|
||||
try {
|
||||
root.querySelectorAll('ha-textfield, ha-textarea, mwc-textfield, mwc-textarea').forEach(el => found.push(el));
|
||||
root.querySelectorAll('*').forEach(el => {
|
||||
if (el.shadowRoot) found.push(...walkShadow(el.shadowRoot, depth + 1));
|
||||
});
|
||||
} catch (e) {}
|
||||
return found;
|
||||
}
|
||||
|
||||
function injectInto(textfield) {
|
||||
if (!textfield || textfield.__assistFixDone) return;
|
||||
textfield.__assistFixDone = true;
|
||||
const sr = textfield.shadowRoot;
|
||||
if (!sr) return;
|
||||
const style = document.createElement('style');
|
||||
style.textContent = css;
|
||||
sr.appendChild(style);
|
||||
// Also patch the nested mwc-textfield if present
|
||||
walkShadow(sr).forEach(tf => {
|
||||
if (tf !== textfield && !tf.__assistFixDone && tf.shadowRoot) {
|
||||
tf.__assistFixDone = true;
|
||||
const s = document.createElement('style');
|
||||
s.textContent = css;
|
||||
tf.shadowRoot.appendChild(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scan() {
|
||||
// Look for any Assist dialog in the DOM
|
||||
const dialogs = document.querySelectorAll(
|
||||
'ha-voice-command-dialog, dialog-voice-command-dialog, ha-conversation-dialog'
|
||||
);
|
||||
dialogs.forEach(d => {
|
||||
if (d.shadowRoot) walkShadow(d.shadowRoot).forEach(injectInto);
|
||||
});
|
||||
// Also scan root-level more-info dialogs that might host textfields
|
||||
if (document.body) {
|
||||
walkShadow(document.body).forEach(injectInto);
|
||||
}
|
||||
}
|
||||
|
||||
// Run on mutations (dialog opens / closes)
|
||||
const obs = new MutationObserver(() => scan());
|
||||
obs.observe(document.body || document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
|
||||
// Initial pass + periodic sweep for first 30s (covers page-load races)
|
||||
let passes = 0;
|
||||
const interval = setInterval(() => {
|
||||
scan();
|
||||
if (++passes > 30) clearInterval(interval);
|
||||
}, 1000);
|
||||
scan();
|
||||
|
||||
console.log('[assist-fix] loaded');
|
||||
})();
|
||||
18
hosts/physical/concord-nuc/homeassistant/www/fonts-loader.js
Normal file
18
hosts/physical/concord-nuc/homeassistant/www/fonts-loader.js
Normal file
@@ -0,0 +1,18 @@
|
||||
(function() {
|
||||
if (document.getElementById('vish-themed-fonts')) return;
|
||||
var link = document.createElement('link');
|
||||
link.id = 'vish-themed-fonts';
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://fonts.googleapis.com/css2?' +
|
||||
'family=Exo+2:wght@300;400;500;600;700&' +
|
||||
'family=Rajdhani:wght@400;500;600;700&' +
|
||||
'family=Orbitron:wght@500;600;700;900&' +
|
||||
'family=Share+Tech+Mono&' +
|
||||
'family=Cormorant+Garamond:wght@400;500;600;700&' +
|
||||
'family=Playfair+Display:wght@500;600;700&' +
|
||||
'family=Crimson+Text:wght@400;600&' +
|
||||
'family=Noto+Serif+JP:wght@400;500;700&' +
|
||||
'family=Shippori+Mincho:wght@500;600;700&' +
|
||||
'family=Sawarabi+Mincho&display=swap';
|
||||
document.head.appendChild(link);
|
||||
})();
|
||||
Reference in New Issue
Block a user