mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 02:46:57 +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
|
||||
|
||||
- **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
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { RulerSlider } from './ruler-slider'
|
||||
|
||||
@@ -13,7 +13,6 @@ export interface ModelControlBarProps {
|
||||
fileName?: string
|
||||
togglePlay: () => void
|
||||
onSeekDegree: (degree: number) => void
|
||||
onResetRotation: () => void
|
||||
onZoomChange: (zoom: number) => void
|
||||
onZoomReset: () => void
|
||||
toggleFullScreen: () => void
|
||||
@@ -29,7 +28,6 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
||||
fileName,
|
||||
togglePlay,
|
||||
onSeekDegree,
|
||||
onResetRotation,
|
||||
onZoomChange,
|
||||
onZoomReset,
|
||||
toggleFullScreen,
|
||||
@@ -49,56 +47,46 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
||||
className={cn(
|
||||
'transition-all duration-300 ease-in-out z-20 text-foreground',
|
||||
isFullScreen
|
||||
? 'absolute bottom-0 left-0 right-0 px-4 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',
|
||||
? '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-2 py-2 sm:px-4 sm:py-2.5 z-10 transition-colors duration-200',
|
||||
)}
|
||||
>
|
||||
{/* Unified Single Row Controls */}
|
||||
<div className="flex items-center justify-between text-foreground gap-4">
|
||||
{/* Left Side: Play/Pause, Degree Readout, Reset Rotation */}
|
||||
<div className="flex items-center gap-3 justify-start min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between text-foreground gap-1.5 sm:gap-3 md:gap-4">
|
||||
{/* Left Side: Play/Pause, Degree Readout */}
|
||||
<div className="flex items-center gap-1.5 sm:gap-3 justify-start min-w-0 flex-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={togglePlay}
|
||||
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-playing={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>
|
||||
|
||||
<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"
|
||||
>
|
||||
<span className="text-muted-foreground font-mono">{currentDegree}° / 360°</span>
|
||||
</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>
|
||||
|
||||
{/* 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" />
|
||||
</div>
|
||||
|
||||
{/* 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 */}
|
||||
<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
|
||||
type="button"
|
||||
onClick={() => onZoomChange(Math.max(0.2, zoom - 0.2))}
|
||||
@@ -111,7 +99,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
||||
type="button"
|
||||
onClick={onZoomReset}
|
||||
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)}%
|
||||
</button>
|
||||
@@ -132,7 +120,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
||||
onClick={handleDownload}
|
||||
title="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" />
|
||||
</button>
|
||||
@@ -144,7 +132,7 @@ export const ModelControlBar: React.FC<ModelControlBarProps> = ({
|
||||
onClick={toggleFullScreen}
|
||||
title={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" />}
|
||||
</button>
|
||||
|
||||
@@ -157,18 +157,6 @@ describe('ModelViewer', () => {
|
||||
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', () => {
|
||||
const { getByTestId } = render(
|
||||
<ModelViewer file={mockAsset}>
|
||||
|
||||
@@ -386,7 +386,6 @@ export const ModelViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
fileName={data.name}
|
||||
togglePlay={togglePlay}
|
||||
onSeekDegree={seekToDegree}
|
||||
onResetRotation={() => seekToDegree(0)}
|
||||
onZoomChange={handleZoomChange}
|
||||
onZoomReset={handleZoomReset}
|
||||
toggleFullScreen={toggleFullScreen}
|
||||
|
||||
@@ -126,7 +126,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
||||
return (
|
||||
<div
|
||||
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',
|
||||
className,
|
||||
)}
|
||||
@@ -139,7 +139,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
||||
title="Decrease 15°"
|
||||
aria-label="Decrease 15°"
|
||||
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" />
|
||||
</button>
|
||||
@@ -218,7 +218,7 @@ export const RulerSlider: React.FC<RulerSliderProps> = ({
|
||||
title="Increase 15°"
|
||||
aria-label="Increase 15°"
|
||||
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" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user