| 1 | import { Layers } from 'lucide-react' |
| 2 | import { Input } from '../../ui/Input' |
| 3 | import { InspectorSection } from './InspectorSection' |
| 4 | import type { ElementEditorProps } from './types' |
| 5 | import { useT } from '@renderer/i18n' |
| 6 | |
| 7 | const MIN_Z_INDEX = -999 |
| 8 | const MAX_Z_INDEX = 9999 |
| 9 | |
| 10 | export function LayerInspector({ draft, onDraftChange }: ElementEditorProps): React.JSX.Element { |
| 11 | const t = useT() |
| 12 | return ( |
| 13 | <InspectorSection |
| 14 | title={t('sessionDetail.zIndex')} |
| 15 | icon={<Layers className="h-3.5 w-3.5 text-[#7a875f]" />} |
| 16 | > |
| 17 | <div className="flex items-center gap-2"> |
| 18 | <button |
| 19 | type="button" |
| 20 | className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-[#d7cbb7]/40 bg-[#f5efe4]/40 text-[13px] font-medium text-[#59664b] transition-colors hover:bg-[#d4e4c1]/60" |
| 21 | onClick={() => { |
| 22 | const current = parseInt(draft.layoutZIndex || '0', 10) || 0 |
| 23 | onDraftChange( |
| 24 | { ...draft, layoutZIndex: String(Math.max(MIN_Z_INDEX, current - 1)) }, |
| 25 | { commit: true, fields: ['layoutZIndex'] } |
| 26 | ) |
| 27 | }} |
| 28 | aria-label={t('sessionDetail.decrease')} |
| 29 | > |
| 30 | - |
| 31 | </button> |
| 32 | <Input |
| 33 | type="number" |
| 34 | min={MIN_Z_INDEX} |
| 35 | max={MAX_Z_INDEX} |
| 36 | value={draft.layoutZIndex} |
| 37 | onChange={(event) => onDraftChange({ ...draft, layoutZIndex: event.target.value })} |
| 38 | onBlur={(event) => |
| 39 | onDraftChange( |
| 40 | { ...draft, layoutZIndex: event.target.value }, |
| 41 | { commit: true, fields: ['layoutZIndex'] } |
| 42 | ) |
| 43 | } |
| 44 | className="h-8 flex-1 rounded-full border border-[#ded2bd]/72 bg-[#fffdf8]/88 px-2.5 text-center 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" |
| 45 | /> |
| 46 | <button |
| 47 | type="button" |
| 48 | className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-[#d7cbb7]/40 bg-[#f5efe4]/40 text-[13px] font-medium text-[#59664b] transition-colors hover:bg-[#d4e4c1]/60" |
| 49 | onClick={() => { |
| 50 | const current = parseInt(draft.layoutZIndex || '0', 10) || 0 |
| 51 | onDraftChange( |
| 52 | { ...draft, layoutZIndex: String(Math.min(MAX_Z_INDEX, current + 1)) }, |
| 53 | { commit: true, fields: ['layoutZIndex'] } |
| 54 | ) |
| 55 | }} |
| 56 | aria-label={t('sessionDetail.increase')} |
| 57 | > |
| 58 | + |
| 59 | </button> |
| 60 | </div> |
| 61 | <p className="mt-1.5 text-[10px] leading-4 text-[#8a806d]"> |
| 62 | {t('sessionDetail.zIndexNegativeHint')} |
| 63 | </p> |
| 64 | </InspectorSection> |
| 65 | ) |
| 66 | } |
| 67 |