Skip to content

Sticky button#27

Merged
LindseyB merged 1 commit into
mainfrom
sticky-start
Aug 29, 2025
Merged

Sticky button#27
LindseyB merged 1 commit into
mainfrom
sticky-start

Conversation

@LindseyB

@LindseyB LindseyB commented Aug 29, 2025

Copy link
Copy Markdown
Owner

What does this PR do?

This pull request introduces a "sticky" Start/Pause button that appears at the bottom of the screen when the main control button is not visible, improving usability for users on long or scrollable pages. The implementation uses an Intersection Observer to track the visibility of the main button and conditionally renders the sticky version as needed.

Closes #23

Type of change

  • Bug fix
  • New breathing technique
  • UI/UX improvement
  • Documentation update
  • Other (please specify):

Testing

  • I have tested these changes locally
  • The app runs without errors
  • All breathing techniques work as expected

Screenshots (if applicable)

firefox_dnxvFWC8qp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a sticky Start/Pause button that appears at the bottom of the screen when the main control button scrolls out of view, enhancing user experience on long or scrollable pages. The implementation uses an Intersection Observer to track the main button's visibility and conditionally renders the sticky version.

Key Changes

  • Added Intersection Observer to track main Start/Pause button visibility
  • Implemented conditional rendering of a sticky button when the main button is not visible
  • Added CSS styling for the fixed-position sticky button

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/App.tsx Added state management, ref, and Intersection Observer logic for button visibility tracking, plus conditional sticky button rendering
src/App.css Added CSS styles for the sticky button positioning and appearance

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/App.tsx
{
root: null,
rootMargin: '0px',
threshold: 0.9 // Button is considered visible if 90% is visible

Copilot AI Aug 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 0.9 should be extracted to a named constant (e.g., BUTTON_VISIBILITY_THRESHOLD = 0.9) to improve code readability and make it easier to adjust this threshold value if needed.

Copilot uses AI. Check for mistakes.
Comment thread src/App.tsx
Comment on lines +1016 to +1025
{!isStartButtonVisible && (
<div className="sticky-controls">
<button
className={`control-btn ${isActive ? 'stop' : 'start'}`}
onClick={handleStartStop}
>
{isActive ? 'Pause' : 'Start'}
</button>
</div>
)}

Copilot AI Aug 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sticky button duplicates the exact same logic as the main button (className and text content). Consider extracting this into a reusable component or helper function to reduce code duplication and ensure consistency.

Copilot uses AI. Check for mistakes.
@LindseyB LindseyB merged commit 4c4534c into main Aug 29, 2025
1 of 2 checks passed
@LindseyB LindseyB deleted the sticky-start branch August 29, 2025 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If start button is not in viewport make it sticky

2 participants