New KMU Page with Statamic

New KMU Page with Statamic

The goal is to recreate the new Colocation Homepage in / with Statamic exactly as it is given in Zeplin: https://zpl.io/ez1Gkyl

Here it was also most of the same with the order and the things i did. Here same as before i started with the Statamic part first, where i firstly figured out what i need which was the offers (webhosting, which already exist), the vserver offers and the managed hosting offers.

For the other offers i created a new collection for each of them (vServer Offers & Managed Hosting Offers) same as i did with the Webhosting offers (which are just called Offers as at that point in time i didn’t know that different types of offers will come to existence). For the blueprint i also mostly used the same one as i did for the Webhosting offers with the exception of the Quote (the small text under the price) and the discount part. The reason why i decided to not include the discount feature is mainly to the fact that there wasn’t an example given in the Zeplin template and that i have no confirmation on what or how exactly it should look like. On top of that it would also be reasonably easy to add even at a later date (hopefully at least) since there is a plausible chance that your able to use the existing discount feature of the webhosting offers.
After i was done with the different Offers i created the blueprint for the KMU page inside the Google Ads collection. Then the final steps are to fill in the content for the offers and after the KMU page. For the KMU page at least during the filling of the content of the page i notice bits and pieces that could be optimised or at times completely missing.

One thing to note which is special about this page is that there are 3 different offer types you can choose from so i decided to make a selector so you can choose which offers you want which we will be able to utilize in the code later.

After that it was time to create the necessary folders & files again. Same as before a KMU folder in the google ads folder and in the sections folder also. And inside there the different sets i created in Statamic. Now asides from 2 things there aren’t much of any noteworthy elements or parts that i did since a lot of them are just repetition or only some more minor adjustments & tweaks. The 2 parts or well more eloquently put they are 2 sub parts of the same section which is the offers. So the first part is the display of the different offers. Now in Zeplin they are displayed one after another but since it has a small navigation or selector above its rather obvious that it’s intended that it only displays the selected type of offers (Webhosting, vServer & Managed Hosting).

This first part is for checking which type is selected and displaying the corresponding offers so only one of them and the correct one is shown.
It contains three tab buttons: Webhosting, vServer, and Managed Hosting. Each button has a data-kmu-tab value, for each corresponding offers. Now parts of the code shown bellow are used for the second part which is for the background but more on that later. This is more so a notice so one doesn’t get confused.

The script first finds every offer section using:

JavaScript
document.querySelectorAll('[data-kmu-offers]')

This makes the code reusable, because it would still work if there were multiple KMU offer sections on the page.

Inside each section, it collects:

JavaScript
const tabs = section.querySelectorAll('[data-kmu-tab]');
const panels = section.querySelectorAll('[data-kmu-panel]');

The tabs are the clickable buttons. The panels are the content areas for each offer variant. Each panel has a matching value like:

JavaScript
data-kmu-panel="webhosting"
data-kmu-panel="vserver"
data-kmu-panel="mh"

The script also finds the main page wrapper:

JavaScript
const pageShell = section.closest('main')?.querySelector('[data-kmu-page-shell]');

This wrapper is important because it controls the large dark background behind the offers. When a user switches tabs, the page needs to resize the dark background because each offer variant has a different height.

The main function is:

JavaScript
const selectVariant = (variant) => {
    pageShell?.setAttribute('data-kmu-offer-background', variant);

    tabs.forEach((button) => {
        button.dataset.active = button.dataset.kmuTab === variant ? 'true' : 'false';
    });

    panels.forEach((panel) => {
        panel.classList.toggle('hidden', panel.dataset.kmuPanel !== variant);
    });
};

When a tab is clicked, this function receives the selected variant, such as vserver. It then updates the page shell attribute:

JavaScript
data-kmu-offer-background="vserver"

That attribute is used by the CSS in kmu.antlers.html to change CSS variables like page height, background height, and curve position (more on this later).

The script also updates the active tab styling:

JavaScript
button.dataset.active = button.dataset.kmuTab === variant ? 'true' : 'false';

In the HTML, the buttons use Tailwind’s data attribute styling:

JavaScript
data-[active=true]:bg-white
data-[active=true]:text-[#111118]

So when data-active=”true”, the selected tab gets a white background and dark text.

Finally, the script shows the selected panel and hides the others:

JavaScript
panel.classList.toggle('hidden', panel.dataset.kmuPanel !== variant);

If the panel does not match the selected variant, it receives the hidden class. If it does match, the hidden class is removed.

This part is for the background, since to make the curve possible i had to make the background absolute to fix the positions of the 2 different elements. Now after testing the first part if the elements are correctly displayed according to what’s selected i noticed that the background doesn’t match the offers as its supposed to especially so on mobile (since they stack and the vserver offers are therefor a lot longer) i decided to try and make that also adjust according to the selected offers and of course also with the @media query from css to make it responsive.

Now since i already had the javascript which checks which offers are selected i was able to just adjust the code of that a bit and add the necessary css & adjust the html.

The CSS in kmu.antlers.html is mainly responsible for controlling the large dark background area behind the KMU landing page content.

The page shell starts like this:

The important part is:

CSS
data-kmu-page-shell
data-kmu-offer-background="webhosting"

This element acts as the main visual container for the top part of the page. By default, it uses the webhosting layout.

The CSS defines custom properties:

CSS
--kmu-page-min-height
--kmu-background-height
--kmu-curve-top

These variables are then used later in the HTML:

HTML
min-h-[var(--kmu-page-min-height)]
h-[var(--kmu-background-height)]
top-[var(--kmu-curve-top)]

So instead of hardcoding the height in many different places, the template defines the values once and reuses them.

The reason there are different values for webhosting, vserver, and mh is that each offer tab has a different amount of content. For example, the vserver section is taller than mh, so the dark background needs to stay visible
for longer.

The JavaScript changes this attribute:

JavaScript
data-kmu-offer-background="vserver"

Then this CSS selector becomes active:

CSS
[data-kmu-page-shell][data-kmu-offer-background="vserver"]

That updates the CSS variables, which automatically changes the page height, background height, and curve position.

There are also media queries:

CSS
@media (min-width: 768px) { … }
@media (min-width: 1024px) { … }

These define different height values for tablet and desktop screen sizes. This is needed because the offer cards change layout responsively. On mobile, cards stack vertically and need more height. On desktop, they sit in columns and need less vertical space.

The background itself is built from absolute-positioned elements:
The first div creates the main dark rectangular background. The second div creates a large rounded oval shape, which makes the bottom edge look curved instead of straight.

The selected_offers.antlers.html file renders the offer tabs and all offer panels. Only the selected panel is visible. The JavaScript listens for tab clicks, updates the active tab, hides inactive panels, and changes the page
shell’s data-kmu-offer-background attribute.

The kmu.antlers.html file reacts to that attribute with CSS. It changes the page height, dark background height, and curved background position depending on whether the user selected Webhosting, vServer, or Managed Hosting.
This keeps the visual background aligned with the currently visible offer content.

As mentioned above the rest was just more or less the same as before.

Tags: