返回 oh-my-ppt
AppearanceInspector.tsx
根目录 / src / renderer / src / components / session-detail / element-inspector / AppearanceInspector.tsx
1 import { Palette } from 'lucide-react'
2 import { Input } from '../../ui/Input'
3 import { ColorPicker } from '../../ui/ColorPicker'
4 import { InspectorSection } from './InspectorSection'
5 import type { ElementEditorProps } from './types'
6 import { useT } from '@renderer/i18n'
7
8 export function AppearanceInspector({
9 selection,
10 draft,
11 onDraftChange
12 }: ElementEditorProps): React.JSX.Element {
13 const t = useT()
14 const isVideo = selection.elementTag === 'video'
15 const colorLabel = selection.snapshot?.computed.svgPaintColor
16 ? t('sessionDetail.visualColor')
17 : t('sessionDetail.backgroundColor')
18 return (
19 <InspectorSection
20 title={t('sessionDetail.appearance')}
21 icon={<Palette className="h-3.5 w-3.5 text-[#7a875f]" />}
22 >
23 <div className="space-y-2.5">
24 <label className="block space-y-1.5">
25 <span className="text-[11px] font-medium text-[#7a875f]">
26 {t('sessionDetail.opacity')}
27 </span>
28 <Input
29 type="number"
30 min={0}
31 max={1}
32 step={0.05}
33 value={draft.opacity}
34 onChange={(event) => onDraftChange({ ...draft, opacity: event.target.value })}
35 onBlur={(event) =>
36 onDraftChange(
37 { ...draft, opacity: event.target.value },
38 { commit: true, fields: ['opacity'] }
39 )
40 }
41 className="h-8 rounded-full border border-[#ded2bd]/72 bg-[#fffdf8]/88 px-2.5 text-xs text-[#3f4b35] shadow-[inset_0_1px_2px_rgba(74,59,42,0.05)] focus-visible:border-[#9bb98a] focus-visible:ring-0 focus-visible:ring-offset-0"
42 />
43 </label>
44 {!isVideo && (
45 <label className="block space-y-1.5">
46 <span className="text-[11px] font-medium text-[#7a875f]">
47 {colorLabel}
48 </span>
49 <div className="flex items-center gap-2">
50 <ColorPicker
51 value={draft.backgroundColor || '#ffffff'}
52 onChange={(v) => onDraftChange({ ...draft, backgroundColor: v })}
53 onCommit={(v) =>
54 onDraftChange(
55 { ...draft, backgroundColor: v },
56 { commit: true, fields: ['backgroundColor'] }
57 )
58 }
59 />
60 <Input
61 value={draft.backgroundColor}
62 onChange={(event) =>
63 onDraftChange({ ...draft, backgroundColor: event.target.value })
64 }
65 onBlur={(event) =>
66 onDraftChange(
67 { ...draft, backgroundColor: event.target.value },
68 { commit: true, fields: ['backgroundColor'] }
69 )
70 }
71 className="h-8 rounded-full border border-[#ded2bd]/72 bg-[#fffdf8]/88 px-2.5 text-xs text-[#3f4b35] shadow-[inset_0_1px_2px_rgba(74,59,42,0.05)] focus-visible:border-[#9bb98a] focus-visible:ring-0 focus-visible:ring-offset-0"
72 />
73 </div>
74 </label>
75 )}
76 </div>
77 </InspectorSection>
78 )
79 }
80
80 lines Plain Text