Remove CTA button from mobile

This commit is contained in:
2026-05-07 07:57:52 +12:00
parent ad9df7578a
commit 32ccd49d78
8 changed files with 74 additions and 19 deletions
+13 -2
View File
@@ -3,6 +3,7 @@
import { afterNavigate } from '$app/navigation';
import { page } from '$app/stores';
import Icon from '$lib/components/Icon.svelte';
import { isMobileCtaButtonEnabled } from '$lib/feature-flags';
/*
* Sticky bottom CTA shown on mobile only.
@@ -20,6 +21,8 @@
* to book while they're already on the form).
*/
const mobileCtaButtonEnabled = isMobileCtaButtonEnabled();
$: pathname = $page.url.pathname;
$: hidden = pathname === '/contact-us' || pathname === '/booking';
@@ -41,7 +44,7 @@
}
async function setupObservers() {
if (typeof window === 'undefined') {
if (!mobileCtaButtonEnabled || typeof window === 'undefined') {
return;
}
@@ -84,6 +87,10 @@
}
afterNavigate(() => {
if (!mobileCtaButtonEnabled) {
return;
}
visible = false;
triggerPassed = false;
bookingInView = false;
@@ -91,6 +98,10 @@
});
onMount(() => {
if (!mobileCtaButtonEnabled) {
return;
}
void setupObservers();
return () => {
@@ -99,7 +110,7 @@
});
</script>
{#if !hidden}
{#if mobileCtaButtonEnabled && !hidden}
<div
class="mobile-book-bar"
class:mobile-book-bar-visible={visible}
+30
View File
@@ -0,0 +1,30 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
describe('feature flags', () => {
afterEach(() => {
vi.unstubAllEnvs();
vi.resetModules();
});
it('defaults the mobile CTA button to disabled', async () => {
const { isMobileCtaButtonEnabled } = await import('./feature-flags');
expect(isMobileCtaButtonEnabled()).toBe(false);
});
it('enables the mobile CTA button when the public env flag is truthy', async () => {
vi.stubEnv('PUBLIC_ENABLE_MOBILE_CTA_BUTTON', 'enabled');
const { isMobileCtaButtonEnabled } = await import('./feature-flags');
expect(isMobileCtaButtonEnabled()).toBe(true);
});
it('treats explicit false values as disabled', async () => {
vi.stubEnv('PUBLIC_ENABLE_MOBILE_CTA_BUTTON', 'off');
const { isMobileCtaButtonEnabled } = await import('./feature-flags');
expect(isMobileCtaButtonEnabled()).toBe(false);
});
});
+21
View File
@@ -0,0 +1,21 @@
export function parseBooleanFlag(value: string | undefined, defaultValue = false) {
if (value == null) {
return defaultValue;
}
const normalized = value.trim().toLowerCase();
if (['1', 'true', 'yes', 'on', 'enabled'].includes(normalized)) {
return true;
}
if (['0', 'false', 'no', 'off', 'disabled'].includes(normalized)) {
return false;
}
return defaultValue;
}
export function isMobileCtaButtonEnabled() {
return parseBooleanFlag(import.meta.env.PUBLIC_ENABLE_MOBILE_CTA_BUTTON, false);
}
+1 -17
View File
@@ -1,20 +1,4 @@
function parseBooleanFlag(value: string | undefined, defaultValue = false) {
if (value == null) {
return defaultValue;
}
const normalized = value.trim().toLowerCase();
if (['1', 'true', 'yes', 'on', 'enabled'].includes(normalized)) {
return true;
}
if (['0', 'false', 'no', 'off', 'disabled'].includes(normalized)) {
return false;
}
return defaultValue;
}
import { parseBooleanFlag } from '$lib/feature-flags';
export function isGeneralEnquiryEnabled() {
return parseBooleanFlag(process.env.ENABLE_GENERAL_ENQUIRIES, false);