Refactor PopularButton component structure for improved layout and responsiveness#2502
Refactor PopularButton component structure for improved layout and responsiveness#2502CkhGueye wants to merge 5 commits intoquran:masterfrom
Conversation
* fix: update share URL path by removing surah prefix (quran#2459) * QF 2876 fix page bookmarks when language is arabic (quran#2458) * fix: initialize bookmarkedPages as empty object in state migration * refactor: move page number localization logic from context menu state to PageInfo component * chore: bump redux persist version * feat: add static props to fetch chapter data on login page (quran#2461) * feat: add static props with chapters data to about, developers and support pages (quran#2462) * feat: add static props with chapters data to about, developers and support pages * add getStaticProps to pages --------- Co-authored-by: Osama Sayed <toto777_90@hotmail.com> * feat: add scroll hook with context menu offset for translation view (quran#2460) * feat: add scroll hook with context menu offset for translation view * Update src/hooks/useScrollWithContextMenuOffset.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/hooks/useScrollWithContextMenuOffset.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: add default context menu height constant for scroll offset calculations --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: improve memory usage of quran reader (quran#2453) * QF-2905 fonts: V4 Update 15-07-25 PAGES 22, 247, 278 (quran#2466) * feat: add page number lookup when navigating to chapters (quran#2452) * refactor: update icons styling and colors to match new design system (quran#2467) * refactor: update icons styling and colors to match new design system * refactor: add size variant to useIsMobile hook and update responsive checks * refactor: standardize icon colors using IconContainer component with grey color preset * simplify imports --------- Co-authored-by: Osama Sayed <toto777_90@hotmail.com> * refactor: implement z-index variants for modals to handle layering and stacking contexts (quran#2464) * QF-2972 fonts: update 18-07-2025 Page 203 (quran#2471) * Update Quranic Calendar's week number calculation (quran#2451) * Fix Quranic calendar week number * small refactor * Update implementation * Update implementation * Update implementation * update 7 days * QF-3051: UX UI Polishing for Quran Reader (quran#2477) * style: improve UI spacing and visual consistency across components * style: adjust bismillah section margin based on reading/translation view mode * refactor: replace --spacing-xlarge with --spacing-medium3-px for consistent spacing units * refactor: standardize spacing variables across SCSS modules using px-based units * sentry: don't capture session replays in prod (quran#2473) * fixed homepage's font scale (quran#2479) * docs: add CLAUDE.md with development guidelines and architecture overview * docs: add opecode guidelines * Update daily ayah (quran#2486) * feat: implement auth system with context and automatic redirects (quran#2485) * feat: implement auth system with context and automatic redirects * refactor: move auth data hook inside AppContent to fix provider context issue * docs: add comprehensive Novu notification settings implementation guide * refactor: consolidate auth system with improved error handling and state management * refactors * refactors --------- Co-authored-by: Osama Sayed <toto777_90@hotmail.com> * Dockerfile: update (quran#2488) * Dockerfile: update * dockerfil: refine install statements * Fix redirection issue * Only redirect when isProfileCompelete=true * readme: minor cleanup (quran#2492) * update redirection logic * Update QR integration * Dockerfile: update (quran#2491) * Update Dockerfile: Fix build, proper dependency installation, and ESLint skip * build(docker): remove env file handling and switch to cmd for startup * build(docker): update environment variables and port configuration * build(docker): simplify build process by removing ESLint ignore config * build(docker): remove unwanted comments from Dockerfile * build(docker): add runtime environment variable handling * build(docker): update port to 80 and simplify build process * Update QR integration (quran#2490) * Update QR integration * handle comments * Update developers page (quran#2494) * QF-3350 (quran#2497) --------- Co-authored-by: Ahmed Hussein <ahmedhussein.developer@gmail.com> Co-authored-by: Osama Sayed <toto777_90@hotmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Osama Sayed <osamasayed@users.noreply.github.com> Co-authored-by: mustafa0x <mustafa.0x@gmail.com> Co-authored-by: Yazan <vwhe@proton.me>
|
@CkhGueye is attempting to deploy a commit to the Quran Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughRefactors PopularButton’s expanded dropdown markup, introducing a header with an inline Close button and a dedicated body section. Updates HomePage hero layout to a two-column grid. SCSS adopts logical properties (inline-size, block-size) and grid placements, with minor syntax/style normalizations. No exported APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant PopularButton
participant UI as Dropdown UI
User->>PopularButton: Click
alt Collapsed
PopularButton->>PopularButton: set isExpanded = true
PopularButton->>UI: Render header (Popular + Close), HR, body
else Expanded
User->>PopularButton: Click Close
PopularButton->>PopularButton: set isExpanded = false
PopularButton-->>UI: Unmount dropdown
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/HomePage/HeroButtons/PopularButton/index.tsx (1)
30-35: Expose expanded state to AT and link trigger to panel.Add aria-expanded and aria-controls to the trigger button.
<Button variant={ButtonVariant.Simplified} className={heroButtonStyles.button} onClick={onClick} size={ButtonSize.Small} + aria-expanded={isExpanded} + aria-controls="popular-dropdown" >As per coding guidelines: Implement proper ARIA attributes, ensure keyboard navigation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
src/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss(1 hunks)src/components/HomePage/HeroButtons/PopularButton/index.tsx(2 hunks)src/components/HomePage/HomePageHero.module.scss(3 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.*
📄 CodeRabbit inference engine (.cursor/rules/bug-handling-with-todo-comments.mdc)
If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.
**/*.*: Utilize Early Returns: Use early returns to avoid nested conditions and improve readability.
Conditional Classes: Prefer conditional classes over ternary operators for class attributes.
**/*.*: Use comments sparingly, and when you do, make them meaningful.
Don't comment on obvious things. Excessive or unclear comments can clutter the codebase and become outdated.
Use comments to convey the 'why' behind specific actions or explain unusual behavior and potential pitfalls.
Provide meaningful information about the function's behavior and explain unusual behavior and potential pitfalls.
**/*.*: Write short functions that only do one thing.
Follow the single responsibility principle (SRP), which means that a function should have one purpose and perform it effectively.
If a function becomes too long or complex, consider breaking it into smaller, more manageable functions.Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.
**/*.*: Always add helpful comments to the code explaining what you are doing.
Never delete old comments, unless they are no longer relevant because the code has been rewritten or deleted.
**/*.*: Choose names for variables, functions, and classes that reflect their purpose and behavior.
A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent.
Use specific names that provide a clearer understanding of what the variables represent and how they are used.
Files:
src/components/HomePage/HomePageHero.module.scsssrc/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scsssrc/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.module.scss
📄 CodeRabbit inference engine (CLAUDE.md)
Use SCSS Modules for component styles (files should be named *.module.scss)
Use SCSS modules for component styling
Files:
src/components/HomePage/HomePageHero.module.scsssrc/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss
**/*.{ts,tsx,scss,json}
📄 CodeRabbit inference engine (AGENTS.md)
Format with Prettier: single quotes, 2-space indentation, 100-character line width, trailing commas
Files:
src/components/HomePage/HomePageHero.module.scsssrc/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scsssrc/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.{ts,tsx,scss}
📄 CodeRabbit inference engine (AGENTS.md)
File names may be kebab-case, camelCase, or PascalCase; co-locate files with related modules
Files:
src/components/HomePage/HomePageHero.module.scsssrc/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scsssrc/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/next-js-conventions.mdc)
**/*.{js,jsx,ts,tsx}: Rely on Next.js Pages Router for state changes.
Minimize 'use client' usage: Prefer server components and Next.js SSR features.
Minimize 'use client' usage: Use 'use client' only for Web API access in small components.
Minimize 'use client' usage: Avoid using 'use client' for data fetching or state management.
**/*.{js,jsx,ts,tsx}: Optimize Web Vitals (LCP, CLS, FID)
Use dynamic loading for non-critical components using @src/components/dls/Spinner/Spinner.tsx
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
src/components/**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react-functional-components.mdc)
src/components/**/*.tsx: Always use React functional components with hooks.
Use React.FC for functional components with props.
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{tsx,jsx}: Use functional components over class components
Keep components small and focused
Extract reusable logic into custom hooks
Use composition over inheritance
Split large components into smaller, focused ones
Follow the Rules of Hooks
Use custom hooks for reusable logic
Use appropriate dependency arrays in useEffect
Implement cleanup in useEffect when needed
Avoid nested hooks
Use useState for local component state
Avoid prop drilling through proper state management
Implement proper memoization (useMemo, useCallback)
Use React.memo for expensive components
Avoid unnecessary re-renders
Implement proper lazy loading
Use proper key props in lists
Profile and optimize render performance
Show appropriate loading and error states
Handle async errors properly
Show user-friendly error messages
Implement proper fallback UI
Log errors appropriately
Handle edge cases gracefully
Use semantic HTML elements
Implement proper ARIA attributes
Ensure keyboard navigation
Handle focus management
Provide proper alt text for images
Use proper imports/exports
Document complex component logicUse React functional components instead of class components
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
Implement proper prop types with TypeScript
**/*.tsx: Prefix interfaces for React props with 'Props' (e.g., ButtonProps)
Implement proper error boundaries
**/*.tsx: Use React functional components only (no class components)
Apply proper memoization for components/selectors (e.g., React.memo, useMemo, useCallback)
Cursor rule: React patterns (functional components, custom hooks, proper state management)
Cursor rule: Performance optimization (proper memoization, lazy loading)
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
Use xstate for complex state logic
Prefer importing via path aliases (@/, @/dls/*) rather than long relative paths
**/*.{ts,tsx}: Order imports: React first, then external, then internal; alphabetize with blank lines between groups
Use camelCase for variables/functions, PascalCase for types/interfaces/components, and UPPER_CASE for constants
Prefer interfaces over type aliases for object shapes
Provide explicit return types for public functions and avoid any
Extract reusable logic into custom hooks
Implement robust error handling: custom error types, async/await best practices, and user-friendly messages
Functions should be under 30 lines, use early returns, follow single-responsibility, and have descriptive names
Cursor rule: TypeScript best practices (interfaces over types, strict mode, proper generics)
Cursor rule: Naming conventions (descriptive, intent-revealing names)
Cursor rule: Clean code (early returns, proper conditionals, function ordering)
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{ts,tsx,d.ts}: Prefer interfaces over types for object definitions
Use type for unions, intersections, and mapped types
Avoid usingany, preferunknownfor unknown types
Leverage TypeScript's built-in utility types
Use generics for reusable type patterns
Use PascalCase for type names and interfaces
Use camelCase for variables and functions
Use UPPER_CASE for constants
Use descriptive names with auxiliary verbs (e.g., isLoading, hasError)
Use explicit return types for public functions
Use arrow functions for callbacks and methods
Implement proper error handling with custom error types
Use function overloads for complex type scenarios
Prefer async/await over Promises
Use readonly for immutable properties
Leverage discriminated unions for type safety
Use type guards for runtime type checking
Implement proper null checking
Avoid type assertions unless necessary
Create custom error types for domain-specific errors
Use Result types for operations that can fail
Use try-catch blocks with typed catch clauses
Handle Promise rejections properly
Files:
src/components/HomePage/HeroButtons/PopularButton/index.tsx
🧠 Learnings (1)
📚 Learning: 2025-09-01T12:38:29.031Z
Learnt from: CR
PR: quran/quran.com-frontend-next#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-01T12:38:29.031Z
Learning: Applies to src/styles/_breakpoints.scss : Define responsive breakpoints in src/styles/_breakpoints.scss
Applied to files:
src/components/HomePage/HomePageHero.module.scsssrc/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss
🔇 Additional comments (1)
src/components/HomePage/HeroButtons/PopularButton/index.tsx (1)
59-66: Icon-only Close button lacks an accessible name.Provide an aria-label (and title) for screen readers and tooltips.
<Button shape={ButtonShape.Circle} variant={ButtonVariant.Ghost} shouldFlipOnRTL={false} onClick={onCloseClicked} + aria-label={t('common:close')} + title={t('common:close')} > <CloseIcon /> </Button>Please verify the existence of the translation key. Run:
src/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss
Show resolved
Hide resolved
src/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss
Show resolved
Hide resolved
src/components/HomePage/HeroButtons/PopularButton/PopularButton.module.scss
Show resolved
Hide resolved
The merge-base changed after approval.
Summary
Fixes #JIRA-TICKET
This PR improve the layout and the responsiveness of the PopularButton Component by centering the Dropdown showed when the button is clicked. Before this change the dropdown block was centered only in the english version of the site because of the structure and some values used weren't relative.
Type of change
Test plan
Manual cross-browser testing.
Checklist
Screenshots or videos
Summary by CodeRabbit
Refactor
Style