Hyvä templates and Tailwind
What it does
Change EasyQuote's storefront markup in a Hyvä theme, and make sure the Tailwind classes it uses end up in your theme's CSS. On Hyvä, the Hyva_MageMeEasyQuote companion replaces the base module's Luma templates with Alpine.js and Tailwind versions.
Before you start
- A Hyvä child theme under
app/design/frontend/<vendor>/<theme>, with its Tailwind build working (web/tailwind,npm run build). - The companion
mageme/module-easyquote-hyvainstalled, see Hyvä, Hyvä Checkout and Breeze. Companion 1.4.11 needs EasyQuote 1.7.5 or later, and EasyQuote 1.7.5 needs companion 1.4.10 or later, so update both together. - Shell access to run
bin/magentoandnpmon the store.
Steps
Know which template renders
The companion registers itself in Hyvä's compatibility registry (Hyva\CompatModuleFallback\Model\CompatModuleRegistry, in etc/frontend/di.xml) as the compat module of MageMe_EasyQuote. On a Hyvä theme, a template named MageMe_EasyQuote::… is looked up in this order:
- Your theme:
app/design/frontend/<vendor>/<theme>/MageMe_EasyQuote/templates/… - The companion:
Hyva_MageMeEasyQuote/view/frontend/templates/… - The base module:
MageMe_EasyQuote/view/frontend/templates/…
The companion ships its own copy of these templates:
| Area | Templates |
|---|---|
| Cart and mini cart | cart/cart_button.phtml, cart/minicart_button.phtml, cart/button_init.phtml, cart/quote_number.phtml, cart/minicart_quote_number.phtml, cart/cart_drawer_extend_script.phtml |
| Request form | request/form.phtml, request/form/field/*.phtml, request/form/custom_field/*.phtml, request/form/script.phtml, request/form/submit.phtml, request/form/validation.phtml, request/success.phtml |
| Customer account | customer/account/quotes.phtml, view.phtml, items.phtml, totals.phtml, decline.phtml, quote_status.phtml, quote_date.phtml, quote_view_buttons.phtml |
| Quote lines and orders | quote/item/renderer/default.phtml, quote/item/qty/tier.phtml, order/view/comments.phtml |
| Page script | init.phtml |
The companion also adds its own layouts:
| Layout | What it does |
|---|---|
default_hyva.xml | In the cart drawer (cart-drawer.totals.before) adds eq-quote-number (cart/minicart_quote_number.phtml) and hyva-minicart.mm.easyquote.request.button (the base module's cart/minicart_button.phtml, which falls back to the companion copy). In before.body.end adds mm.easyquote.quote.cart.number.script (cart/cart_drawer_extend_script.phtml) when the mini cart is shown. |
hyva_easyquote_quote_index.xml, hyva_easyquote_quote_view.xml | Remove the Luma css/quote.css. |
easyquote_cart_quote_number.xml | Adds additional.product.info with mm.easyquote.quote.cart.number and mm.easyquote.quote.cart.comment to the cart page. A companion observer adds this handle on Hyvä themes on checkout_cart_index. |
easyquote_quote_view_title.xml | Puts quote.status, quote.date and easyquote.quote.info.buttons inside easyquote.quote.view, instead of the page title. A companion observer adds this handle on Hyvä themes for the quote and decline pages. |
- Find the template in the companion first. Only templates the companion doesn't ship fall back to the base module.
- Copy it to
app/design/frontend/<vendor>/<theme>/MageMe_EasyQuote/templates/under the same relative path. Use theMageMe_EasyQuotefolder name, notHyva_MageMeEasyQuote, except for the few templates namedHyva_MageMeEasyQuote::…, see Limits. - Change the copy.
- Rebuild the Tailwind CSS of your theme, as described below.
- Run
bin/magento cache:clean layout block_html full_page.
Keep Tailwind in step
Tailwind only generates the classes it finds in the files it scans. The companion lists itself in app/etc/hyva-themes.json, so Hyvä's build tools add it to your theme's sources:
| Theme build | How the companion's classes get in |
|---|---|
Tailwind 4 (Hyvä 1.4 themes, tailwind-source.css) | npm run build runs hyva-sources first, which writes @source "…/Hyva/MageMeEasyQuote"; into web/tailwind/generated/hyva-source.css. The whole companion folder is scanned. |
Tailwind 3 (tailwind.config.js) | The companion's view/frontend/tailwind/tailwind.config.js is merged into your config. It scans ../templates/**/*.phtml and ../layout/**/*.xml and has a safelist of the default form classes plus a pattern for mb-, mt-, p-, text-, bg-, border-, rounded-, focus-, ring-, w- and h- classes. |
- After each companion update, rebuild your theme's CSS: in
app/design/frontend/<vendor>/<theme>/web/tailwind, runnpm run build. The release notes of 1.4.7 and 1.4.9 ask for this. - If you enter classes in the Hyvä Theme Developer settings, add them to your theme's sources too. Those values live in the database, where Tailwind can't see them. On Tailwind 4, list them with
@source inline("…")intailwind-source.css. On Tailwind 3, add them tosafelist. - Run
bin/magento cache:clean full_page.
The Hyvä Theme Developer settings set the classes of the request form fields: Field Block CSS Class, Field Label CSS Class, Field Comment CSS Class, Text Input CSS Class, Message Textarea CSS Class, Dropdown CSS Class, Radio Button CSS Class, Radio Label CSS Class, Checkbox CSS Class, Checkbox Label CSS Class and Validation Message CSS Class.
What you should see
The storefront page shows your markup, and the Tailwind classes in it are styled. If a class from your template has no effect, it is missing from the built styles.css.
Limits
- A template named
MageMe_EasyQuote::…is overridden only from theMageMe_EasyQuotefolder in your theme. AHyva_MageMeEasyQuotefolder in the theme has no effect on it. The companion names a few templates with its own module:cart/minicart_quote_number.phtml,cart/button_init.phtml,request/form/validation.phtmlandinit.phtml. Those are overridden from aHyva_MageMeEasyQuotefolder in your theme, and a copy inMageMe_EasyQuotehas no effect on them. - The class values you type in Hyvä Theme Developer are not scanned by any Tailwind build.
- The companion's
tailwind.config.jsis a Tailwind 3 file. A Tailwind 4 build doesn't read itssafelist:hyva-sourcesadds the companion folder with@sourceonly, and Tailwind 4 loads a JavaScript config only through@config. - The Request a Quote buttons use the theme's secondary button style as long as Custom Button CSS Classes is empty or has its default value. Once you enter your own classes, the cart page button gets the theme's primary button classes plus yours, and the mini cart button gets only yours.
Troubleshooting
- The request form fields have no styling. Rebuild the theme CSS with
npm run buildand check thatgenerated/hyva-source.csslists the companion folder. - Your template copy has no effect. Check that the copy sits under
MageMe_EasyQuote/templates/in the theme the store view uses, then clean theblock_htmlandfull_pagecaches. - Styling broke after an EasyQuote update. The companion's templates may use new classes. Rebuild the theme CSS.
What's next
- Template and layout overrides (Luma): the layout handles and the request form popup.
- Hyvä, Hyvä Checkout and Breeze: what the companion changes for store owners.