From 18f3da5536dcbc03074cfb38e008dee1a8a9e4a3 Mon Sep 17 00:00:00 2001 From: sina_sajjadi Date: Tue, 24 Dec 2024 20:05:11 +0330 Subject: [PATCH] feat: add logo component, update mobile header, implement sticky components and audio controls --- next.config.ts | 3 + public/assets/images/Ellipse 441.svg | 3 + public/assets/images/GraySetting.svg | 4 + src/components/context/audio-conext.tsx | 139 ++++++++++++++++ src/components/context/ui.context.tsx | 34 +++- src/components/layout/header.tsx | 16 +- src/components/layout/mobile-header.tsx | 9 +- src/components/layout/mobile-navigation.tsx | 108 ++++++++----- src/components/mobile-header/hamburger.tsx | 5 +- .../mobile-header/mobile-setting.tsx | 27 +++- src/components/modals/modal-manager.tsx | 5 +- src/components/modals/reciters.tsx | 119 ++++++++++++++ src/components/modals/setting.tsx | 46 ++++-- .../sticky-components/audio-controls.tsx | 151 ++++++++++++++++++ .../download-app.tsx | 6 +- .../sticky-components/sticky-components.tsx | 14 ++ src/components/ui/logo.tsx | 12 ++ src/pages/_app.tsx | 39 ++--- src/pages/duas/[slug].tsx | 67 ++++---- 19 files changed, 673 insertions(+), 134 deletions(-) create mode 100644 public/assets/images/Ellipse 441.svg create mode 100644 public/assets/images/GraySetting.svg create mode 100644 src/components/context/audio-conext.tsx create mode 100644 src/components/modals/reciters.tsx create mode 100644 src/components/sticky-components/audio-controls.tsx rename src/components/{ui => sticky-components}/download-app.tsx (77%) create mode 100644 src/components/sticky-components/sticky-components.tsx create mode 100644 src/components/ui/logo.tsx diff --git a/next.config.ts b/next.config.ts index 9d0da29..392e6cb 100644 --- a/next.config.ts +++ b/next.config.ts @@ -4,6 +4,9 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { reactStrictMode: true, + images: { + domains: ["habibapp.com"], // Add the domain for image hosting + }, // Add other Next.js config options here as needed }; diff --git a/public/assets/images/Ellipse 441.svg b/public/assets/images/Ellipse 441.svg new file mode 100644 index 0000000..75056b7 --- /dev/null +++ b/public/assets/images/Ellipse 441.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/assets/images/GraySetting.svg b/public/assets/images/GraySetting.svg new file mode 100644 index 0000000..501aef4 --- /dev/null +++ b/public/assets/images/GraySetting.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/context/audio-conext.tsx b/src/components/context/audio-conext.tsx new file mode 100644 index 0000000..bc3aff6 --- /dev/null +++ b/src/components/context/audio-conext.tsx @@ -0,0 +1,139 @@ +import http from "@/api/http"; +import React, { + createContext, + useContext, + useState, + ReactNode, + useRef, + useEffect, +} from "react"; + +interface Dua { + id: number; + text: string; + description: string; + local_alpha: string; + translation: string; +} + +interface AudioSyncData { + id: number; + duration: [number, number][]; +} + +interface Audio { + audio: string; + audio_sync_data: AudioSyncData[]; + reciter?: { + id: string; + name: string; + }; +} + +interface AudiosResponse { + results: Audio[]; +} + +interface AudioContextType { + audioRef: React.RefObject; + audio: Audio | null; // Store a single audio object + getAudio: (id: number) => Promise; + selectedReciter?: string; + setSelectedReciter: React.Dispatch>; +} + +const AudioContext = createContext(undefined); + +export const AudioProvider: React.FC<{ children: ReactNode }> = ({ + children, +}) => { + const audioRef = useRef(null); + const partRefs = useRef<(HTMLDivElement | null)[]>([]); + + const [audios, setAudios] = useState