<af-calculator-open-component>
Adjust amounts to see validation & link updates. Open the disclosures modal to emit disclosure-open.
disclosure-open.loanAmount presence triggers layout="additional" (legacy two-field); absence keeps layout="standard".Second instance seeded with different parameters (Roofing scenario).
Add the following CSS (theme stylesheet or a Customizer Additional CSS block) to reserve the correct height up front and prevent layout shift. These custom properties map layout + viewport combinations to fixed pixel heights.
:root {
--calc-standard-desktop:306px;
--calc-standard-mobile:398px;
--calc-additional-desktop:319px;
--calc-additional-mobile:414px;
--calc-fallback:398px; /* majority: mobile standard */
}
af-calculator-open-component,
af-calculator-open-component[loading] { display:block; min-height:var(--calc-fallback); }
af-calculator-open-component[layout="standard"],
af-calculator-open-component[layout="standard"][loading] { min-height:var(--calc-standard-desktop); }
af-calculator-open-component[layout="additional"],
af-calculator-open-component[layout="additional"][loading] { min-height:var(--calc-additional-desktop); }
@media (max-width:640px) {
af-calculator-open-component[layout="standard"],
af-calculator-open-component[layout="standard"][loading] { min-height:var(--calc-standard-mobile); }
af-calculator-open-component[layout="additional"],
af-calculator-open-component[layout="additional"][loading] { min-height:var(--calc-additional-mobile); }
}
Early Layout Attribute (Optional but Recommended): Insert this small inline script before the component tag (or in the header) to set layout early based on URL params so the correct height is chosen before the component upgrades:
<script>(function(){
const hasLoanAmount = new URLSearchParams(location.search).has('loanAmount');
function setLayout(){
const el = document.querySelector('af-calculator-open-component');
if(!el){ requestAnimationFrame(setLayout); return; }
if(!el.hasAttribute('layout')){
el.setAttribute('layout', hasLoanAmount ? 'additional' : 'standard');
}
}
setLayout();
})();</script>
[loading] selector) so spinner/content swap does not shift layout.layout attribute./wp-content/themes/<theme>/assets/af-calculator-open-component.js) or use the existing QA URL.<script type="module" src="https://qa.your.acornfinance.com/widgets/calculator-open/src/af-calculator-open-component.js"></script>
<af-calculator-open-component
loanAmount="15000"
d="WP-KITCHEN"
subPurpose="Kitchen Cabinets"
cname="Your Contractor Name"
pcid="1234"
processEnv="PROD">
</af-calculator-open-component>
?loanAmount=22000&d=WP-KITCHEN) – the component will auto‑parse them overriding attributes.script, allowlist module scripts or enqueue via theme:
// functions.php
function af_calc_enqueue() {
wp_enqueue_script(
'af-open-calculator',
'https://qa.your.acornfinance.com/widgets/calculator-open/src/af-calculator-open-component.js',
[],
null,
true
);
}
add_action('wp_enqueue_scripts','af_calc_enqueue');
Then only place the HTML tag in the editor.
--font-open-sans, --font-bitter).public/index.html (Quasar CLI) or src/index.template.html (Vite):
<script type="module" src="https://qa.your.acornfinance.com/widgets/calculator-open/src/af-calculator-open-component.js"></script>
<template>
<q-page padding>
<h2>Financing Calculator</h2>
<af-calculator-open-component
loanAmount="18000"
d="QSR-001"
subPurpose="Roofing"
cname="Quasar Demo Contractor"
pcid="5555"
processEnv="QA">
</af-calculator-open-component>
</q-page>
</template>
// quasar.config.js (Vite)
build: {
vueOptions: {
compilerOptions: {
isCustomElement: tag => tag === 'af-calculator-open-component'
}
}
}
(Or register a set if adding more web components.)
onMounted(() => {
const el = document.querySelector('af-calculator-open-component');
el.addEventListener('validity-change', e => {
console.log('Valid?', e.detail.isValid);
});
});
el.requiredAmount = '25,000'; el.requestUpdate();
?loanAmount=) will not auto‑reinitialize unless the page reloads; call a re-parse method if you add one later or reload intentionally.<client-only> or check process.env.CLIENT).Prefer explicit attributes for stable embeds; use URL params when generating marketing campaign links so tracking values flow automatically.
<script type="module" src="https://qa.your.acornfinance.com/widgets/calculator-open/src/af-calculator-open-component.js"></script>
<af-calculator-open-component loanAmount="10000"></af-calculator-open-component>