refactor(PipConfigPanel): 提取预览区组件
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
import React from "react"
|
||||
import type { PipLayer } from "../types"
|
||||
import { LAYER_COLORS } from "../constants"
|
||||
|
||||
export interface PipPreviewProps {
|
||||
layers: PipLayer[]
|
||||
selectedId: string
|
||||
}
|
||||
|
||||
export const PipPreview: React.FC<PipPreviewProps> = ({ layers, selectedId }) => {
|
||||
return (
|
||||
<div className="pip-preview-box">
|
||||
{layers.map((layer, idx) => (
|
||||
<div
|
||||
key={layer.id}
|
||||
className={`pip-preview-layer${selectedId === layer.id ? " selected" : ""}`}
|
||||
style={{
|
||||
left: `${layer.x}%`,
|
||||
top: `${layer.y}%`,
|
||||
width: `${layer.width}%`,
|
||||
height: `${layer.height}%`,
|
||||
background: LAYER_COLORS[idx % LAYER_COLORS.length],
|
||||
opacity: layer.opacity / 100,
|
||||
borderRadius: `${layer.border_radius}%`,
|
||||
}}
|
||||
>
|
||||
<span className="pip-preview-label">{layer.name}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user