From 08f2643dcde78c5e39005e69878c7542754016b0 Mon Sep 17 00:00:00 2001 From: Wanjohi Date: Fri, 27 Dec 2024 13:01:13 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Use=20howlerJS=20for=20audi?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/www/package.json | 2 ++ apps/www/src/routes/pricing/index.tsx | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/www/package.json b/apps/www/package.json index b4d9828e..5ffec96c 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -41,6 +41,7 @@ "@nestri/typescript-config": "*", "@nestri/ui": "*", "@types/eslint": "8.56.10", + "@types/howler": "^2.2.12", "@types/node": "^22.5.1", "@types/react": "^18.2.28", "@types/react-dom": "^18.2.13", @@ -48,6 +49,7 @@ "@typescript-eslint/parser": "7.16.1", "eslint": "8.57.0", "eslint-plugin-qwik": "^1.8.0", + "howler": "^2.2.4", "prettier": "3.3.3", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/apps/www/src/routes/pricing/index.tsx b/apps/www/src/routes/pricing/index.tsx index 250fd618..76c6a1f2 100644 --- a/apps/www/src/routes/pricing/index.tsx +++ b/apps/www/src/routes/pricing/index.tsx @@ -1,7 +1,9 @@ -import { component$, useSignal, useVisibleTask$ } from "@builder.io/qwik"; +import { $, component$, noSerialize, NoSerialize, useSignal, useVisibleTask$ } from "@builder.io/qwik"; import { TitleSection, MotionComponent, transition } from "@nestri/ui/react"; import { NavBar, Footer, Book } from "@nestri/ui" import { cn } from "@nestri/ui/design"; +import { Howl, Howler } from 'howler'; + //FIXME: Add a FAQ section // FIXME: Takes too long for the price input radio input to become responsive const w = 280 @@ -62,13 +64,14 @@ const convertToTitle = (value: any) => { export default component$(() => { const priceValue = useSignal(3) - const audioUrl = new URL('./cash.mp3', import.meta.url).href - const audio = useSignal() - const buttonRef = useSignal() const bookRef = useSignal() + const audio = useSignal | undefined>() useVisibleTask$(() => { + audio.value = noSerialize(new Howl({ src: ["/audio/cash.mp3"] })) + audio.value?.volume(0.5) + buttonRef.value?.addEventListener("mouseenter", () => { bookRef.value?.classList.add('flip') }) @@ -85,6 +88,11 @@ export default component$(() => { } }) + const onClick = $((v: any) => { + priceValue.value = Number(v.target?.value) as number; + audio.value?.play() + }) + return ( <> @@ -306,11 +314,10 @@ export default component$(() => { class="absolute transition-all duration-200 pointer-events-none w-full -top-1 z-20 right-0 left-[--left] "> -