mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 21:04:59 +00:00
feat(webui): make RulerSlider responsive on mobile and remove bottom bar reset button
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **viewer**: Redesign the 3D turntable ruler slider with an enclosed capsule track, encapsulated ±15° step buttons, vertically centered ticks, and a full-height center red indicator
|
- **viewer**: Redesign the 3D turntable ruler slider with an enclosed capsule track, encapsulated ±15° step buttons, vertically centered ticks, a center red indicator, and a responsive mobile layout with the bottom bar reset button removed
|
||||||
|
|
||||||
## [0.5.1] - 2026-10-06
|
## [0.5.1] - 2026-10-06
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Play, Pause, RotateCcw, Maximize, Minimize, Minus, Plus, Download } from 'lucide-react'
|
import { Play, Pause, Maximize, Minimize, Minus, Plus, Download } from 'lucide-react'
|
||||||
import { cn } from '@/ui/lib/utils'
|
import { cn } from '@/ui/lib/utils'
|
||||||
import { RulerSlider } from './ruler-slider'
|
import { RulerSlider } from './ruler-slider'
|
||||||
|
|
||||||
@@ -13,7 +13,6 @@ export interface ModelControlBarProps {
|
|||||||
fileName?: string
|
fileName?: string
|
||||||
togglePlay: () => void
|
togglePlay: () => void
|
||||||
onSeekDegree: (degree: number) => void
|
onSeekDegree: (degree: number) => void
|
||||||
onResetRotation: () => void
|
|
||||||
onZoomChange: (zoom: number) => void
|
onZoomChange: (zoom: number) => void
|
||||||
onZoomReset: () => void
|
onZoomReset: () => void
|
||||||
toggleFullScreen: () => void
|
toggleFullScreen: () => void
|
||||||
@@ -29,7 +28,6 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|||||||
fileName,
|
fileName,
|
||||||
togglePlay,
|
togglePlay,
|
||||||
onSeekDegree,
|
onSeekDegree,
|
||||||
onResetRotation,
|
|
||||||
onZoomChange,
|
onZoomChange,
|
||||||
onZoomReset,
|
onZoomReset,
|
||||||
toggleFullScreen,
|
toggleFullScreen,
|
||||||
@@ -49,56 +47,46 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|||||||
className={cn(
|
className={cn(
|
||||||
'transition-all duration-300 ease-in-out z-20 text-foreground',
|
'transition-all duration-300 ease-in-out z-20 text-foreground',
|
||||||
isFullScreen
|
isFullScreen
|
||||||
? 'absolute bottom-0 left-0 right-0 px-4 py-2.5 bg-card/90 backdrop-blur-md border-t border-border'
|
? 'absolute bottom-0 left-0 right-0 px-2 py-2 sm:px-4 sm:py-2.5 bg-card/90 backdrop-blur-md border-t border-border'
|
||||||
: 'relative w-full bg-card border-t border-border px-4 py-2.5 z-10 transition-colors duration-200',
|
: 'relative w-full bg-card border-t border-border px-2 py-2 sm:px-4 sm:py-2.5 z-10 transition-colors duration-200',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* Unified Single Row Controls */}
|
{/* Unified Single Row Controls */}
|
||||||
<div className="flex items-center justify-between text-foreground gap-4">
|
<div className="flex items-center justify-between text-foreground gap-1.5 sm:gap-3 md:gap-4">
|
||||||
{/* Left Side: Play/Pause, Degree Readout, Reset Rotation */}
|
{/* Left Side: Play/Pause, Degree Readout */}
|
||||||
<div className="flex items-center gap-3 justify-start min-w-0 flex-1">
|
<div className="flex items-center gap-1.5 sm:gap-3 justify-start min-w-0 flex-1">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={togglePlay}
|
onClick={togglePlay}
|
||||||
aria-label={isPlaying ? 'Pause' : 'Play'}
|
aria-label={isPlaying ? 'Pause' : 'Play'}
|
||||||
className="hover:text-primary transition-colors shrink-0"
|
className="hover:text-primary transition-colors shrink-0 p-0.5 sm:p-1"
|
||||||
data-testid="play-toggle"
|
data-testid="play-toggle"
|
||||||
data-playing={isPlaying}
|
data-playing={isPlaying}
|
||||||
>
|
>
|
||||||
{isPlaying ? (
|
{isPlaying ? (
|
||||||
<Pause className="w-5 h-5 fill-current" />
|
<Pause className="w-4 h-4 sm:w-5 sm:h-5 fill-current" />
|
||||||
) : (
|
) : (
|
||||||
<Play className="w-5 h-5 fill-current" />
|
<Play className="w-4 h-4 sm:w-5 sm:h-5 fill-current" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="flex items-center text-sm font-medium tabular-nums select-none shrink-0"
|
className="flex items-center text-xs sm:text-sm font-medium tabular-nums select-none shrink-0"
|
||||||
data-testid="degree-readout"
|
data-testid="degree-readout"
|
||||||
>
|
>
|
||||||
<span className="text-muted-foreground font-mono">{currentDegree}° / 360°</span>
|
<span className="text-muted-foreground font-mono">{currentDegree}° / 360°</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={onResetRotation}
|
|
||||||
title="Reset to 0°"
|
|
||||||
aria-label="Reset rotation to 0°"
|
|
||||||
className="p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
|
||||||
>
|
|
||||||
<RotateCcw className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Center: RulerSlider with encapsulated minus & plus buttons */}
|
{/* Center: RulerSlider with encapsulated minus & plus buttons */}
|
||||||
<div className="flex items-center w-full max-w-[340px] justify-center mx-auto shrink-0">
|
<div className="flex items-center w-full max-w-[130px] sm:max-w-[220px] md:max-w-[320px] justify-center mx-auto shrink min-w-0">
|
||||||
<RulerSlider currentDegree={currentDegree} onChange={onSeekDegree} className="w-full" />
|
<RulerSlider currentDegree={currentDegree} onChange={onSeekDegree} className="w-full" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right Side: Zoom controls, Download, Fullscreen */}
|
{/* Right Side: Zoom controls, Download, Fullscreen */}
|
||||||
<div className="flex items-center gap-2 justify-end min-w-0 flex-1">
|
<div className="flex items-center gap-1 sm:gap-2 justify-end min-w-0 flex-1">
|
||||||
{/* Zoom controls */}
|
{/* Zoom controls */}
|
||||||
<div className="flex items-center gap-1 bg-muted/60 rounded-lg p-0.5 border border-border/40 shrink-0">
|
<div className="flex items-center gap-0.5 sm:gap-1 bg-muted/60 rounded-lg p-0.5 border border-border/40 shrink-0">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onZoomChange(Math.max(0.2, zoom - 0.2))}
|
onClick={() => onZoomChange(Math.max(0.2, zoom - 0.2))}
|
||||||
@@ -111,7 +99,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onZoomReset}
|
onClick={onZoomReset}
|
||||||
aria-label="Reset zoom"
|
aria-label="Reset zoom"
|
||||||
className="px-1.5 py-0.5 text-[11px] font-mono text-muted-foreground hover:text-foreground transition-colors"
|
className="px-1 sm:px-1.5 py-0.5 text-[10px] sm:text-[11px] font-mono text-muted-foreground hover:text-foreground transition-colors"
|
||||||
>
|
>
|
||||||
{Math.round(zoom * 100)}%
|
{Math.round(zoom * 100)}%
|
||||||
</button>
|
</button>
|
||||||
@@ -132,7 +120,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|||||||
onClick={handleDownload}
|
onClick={handleDownload}
|
||||||
title="Download asset"
|
title="Download asset"
|
||||||
aria-label="Download asset"
|
aria-label="Download asset"
|
||||||
className="p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
className="p-1 sm:p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
||||||
>
|
>
|
||||||
<Download className="w-4 h-4" />
|
<Download className="w-4 h-4" />
|
||||||
</button>
|
</button>
|
||||||
@@ -144,7 +132,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
|||||||
onClick={toggleFullScreen}
|
onClick={toggleFullScreen}
|
||||||
title={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
title={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
||||||
aria-label={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
aria-label={isFullScreen ? 'Exit fullscreen' : 'Fullscreen'}
|
||||||
className="p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
className="p-1 sm:p-1.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors shrink-0"
|
||||||
>
|
>
|
||||||
{isFullScreen ? <Minimize className="w-4 h-4" /> : <Maximize className="w-4 h-4" />}
|
{isFullScreen ? <Minimize className="w-4 h-4" /> : <Maximize className="w-4 h-4" />}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -157,18 +157,6 @@ describe('ModelViewer', () => {
|
|||||||
expect(ref.current?.getCurrentTime?.()).toBeDefined()
|
expect(ref.current?.getCurrentTime?.()).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('resets rotation to 0° when reset button is clicked', () => {
|
|
||||||
const onTimeUpdate = vi.fn()
|
|
||||||
const { getByRole } = render(
|
|
||||||
<ModelViewer file={mockAsset} startTime={1} onTimeUpdate={onTimeUpdate} />,
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reset rotation button has aria-label 'Reset rotation to 0°'
|
|
||||||
const resetBtn = getByRole('button', { name: /Reset rotation/i })
|
|
||||||
fireEvent.click(resetBtn)
|
|
||||||
expect(onTimeUpdate).toHaveBeenCalledWith(0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('renders children alongside viewer surface when provided', () => {
|
it('renders children alongside viewer surface when provided', () => {
|
||||||
const { getByTestId } = render(
|
const { getByTestId } = render(
|
||||||
<ModelViewer file={mockAsset}>
|
<ModelViewer file={mockAsset}>
|
||||||
|
|||||||
@@ -386,7 +386,6 @@ export const ModelViewer = React.forwardRef<MediaController, FileViewerProps>(
|
|||||||
fileName={data.name}
|
fileName={data.name}
|
||||||
togglePlay={togglePlay}
|
togglePlay={togglePlay}
|
||||||
onSeekDegree={seekToDegree}
|
onSeekDegree={seekToDegree}
|
||||||
onResetRotation={() => seekToDegree(0)}
|
|
||||||
onZoomChange={handleZoomChange}
|
onZoomChange={handleZoomChange}
|
||||||
onZoomReset={handleZoomReset}
|
onZoomReset={handleZoomReset}
|
||||||
toggleFullScreen={toggleFullScreen}
|
toggleFullScreen={toggleFullScreen}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative select-none flex items-center gap-2.5 w-full min-w-[160px]',
|
'relative select-none flex items-center gap-1 sm:gap-2.5 w-full min-w-0 sm:min-w-[140px]',
|
||||||
disabled && 'opacity-50',
|
disabled && 'opacity-50',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
@@ -139,7 +139,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
|||||||
title="Decrease 15°"
|
title="Decrease 15°"
|
||||||
aria-label="Decrease 15°"
|
aria-label="Decrease 15°"
|
||||||
data-testid="ruler-step-minus"
|
data-testid="ruler-step-minus"
|
||||||
className="p-1 rounded text-muted-foreground hover:text-foreground transition-colors shrink-0 disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
className="p-0.5 sm:p-1 rounded text-muted-foreground hover:text-foreground transition-colors shrink-0 disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||||
>
|
>
|
||||||
<Minus className="w-3.5 h-3.5" />
|
<Minus className="w-3.5 h-3.5" />
|
||||||
</button>
|
</button>
|
||||||
@@ -218,7 +218,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
|||||||
title="Increase 15°"
|
title="Increase 15°"
|
||||||
aria-label="Increase 15°"
|
aria-label="Increase 15°"
|
||||||
data-testid="ruler-step-plus"
|
data-testid="ruler-step-plus"
|
||||||
className="p-1 rounded text-muted-foreground hover:text-foreground transition-colors shrink-0 disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
className="p-0.5 sm:p-1 rounded text-muted-foreground hover:text-foreground transition-colors shrink-0 disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||||
>
|
>
|
||||||
<Plus className="w-3.5 h-3.5" />
|
<Plus className="w-3.5 h-3.5" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user