Skip to content

feat: add range orientation to react components#30

Merged
luwes merged 1 commit intomainfrom
react-range-orientation
Sep 26, 2025
Merged

feat: add range orientation to react components#30
luwes merged 1 commit intomainfrom
react-range-orientation

Conversation

@luwes
Copy link
Copy Markdown
Collaborator

@luwes luwes commented Sep 26, 2025

Adds the orientation feature to the React range components.
Cleaned up the types as well.

This works differently than in Media Chrome where one would use a CSS rotate transform.
Here you set the orientation prop and then change the width and height on the root and track element.

@luwes luwes requested a review from Copilot September 26, 2025 22:51
@luwes luwes self-assigned this Sep 26, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds orientation support to React range components (TimeRange and VolumeRange), allowing them to be rendered vertically or horizontally. The implementation differs from Media Chrome's CSS transform approach by using data attributes and dynamic styling based on the orientation prop.

  • Adds orientation prop ('horizontal' | 'vertical') to range components with horizontal as default
  • Updates styling to handle both orientations using CSS attribute selectors and dynamic property assignment
  • Improves type definitions by replacing generic types with more specific React component prop types

Reviewed Changes

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

Show a summary per file
File Description
packages/react/react/src/skins/default/styles.ts Updates CSS classes to support orientation-specific dimensions using data attribute selectors
packages/react/react/src/skins/default/MediaSkinDefault.tsx Sets VolumeRange to use vertical orientation
packages/react/react/src/components/VolumeRange.tsx Adds orientation support with proper type definitions and dynamic styling
packages/react/react/src/components/TimeRange.tsx Adds orientation support with proper type definitions and dynamic styling
packages/core/core/src/components/range.ts Adjusts coordinate calculation for vertical range handling

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

{ x: rect.left, y: rect.top },
{ x: rect.right, y: rect.bottom }
{ x: rect.left, y: rect.bottom },
{ x: rect.right, y: rect.top }
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The coordinate swap appears incorrect for vertical orientation. For a vertical slider, the start point should typically be at the bottom (rect.bottom) and end at the top (rect.top), but the x-coordinates should remain the same (rect.left for both points), not rect.left to rect.right.

Suggested change
{ x: rect.right, y: rect.top }
{ x: rect.left, y: rect.top }

Copilot uses AI. Check for mistakes.
insetInlineStart: 'var(--slider-fill)',
[context.orientation === 'horizontal' ? 'insetInlineStart' : 'insetBlockEnd']: 'var(--slider-fill)',
[context.orientation === 'horizontal' ? 'top' : 'left']: '50%',
translate: context.orientation === 'horizontal' ? '-50% -50%' : '-50% 50%',
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The vertical translate value '50%' moves the thumb in the wrong direction. For vertical sliders, the thumb should be centered and translated negatively on both axes. The correct value should be '-50% -50%' for both orientations.

Suggested change
translate: context.orientation === 'horizontal' ? '-50% -50%' : '-50% 50%',
translate: '-50% -50%',

Copilot uses AI. Check for mistakes.
insetInlineStart: 'var(--slider-fill)',
[context.orientation === 'horizontal' ? 'insetInlineStart' : 'insetBlockEnd']: 'var(--slider-fill)',
[context.orientation === 'horizontal' ? 'top' : 'left']: '50%',
translate: context.orientation === 'horizontal' ? '-50% -50%' : '-50% 50%',
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The vertical translate value '50%' moves the thumb in the wrong direction. For vertical sliders, the thumb should be centered and translated negatively on both axes. The correct value should be '-50% -50%' for both orientations.

Suggested change
translate: context.orientation === 'horizontal' ? '-50% -50%' : '-50% 50%',
translate: context.orientation === 'horizontal' ? '-50% -50%' : '-50% -50%',

Copilot uses AI. Check for mistakes.
@luwes
Copy link
Copy Markdown
Collaborator Author

luwes commented Sep 26, 2025

I think Copilot didn't account for the inversion we do for vertical. We stick the progress to the bottom for example.
It's working on my end so pretty sure AI screwed up.

@luwes luwes merged commit 5e3cb8a into main Sep 26, 2025
@luwes luwes deleted the react-range-orientation branch September 26, 2025 22:57
@github-actions github-actions bot mentioned this pull request Oct 24, 2025
@github-actions github-actions bot mentioned this pull request Feb 26, 2026
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.

2 participants