Files
Jimmy Domagala-Tang 560b7a209a Transition optimized images to project-level toggle (#36093)
* feat: transitioning optimized images from a compile mode to a project level toggle. We still persist it for the proect and between users, and ensure that draft mode does not interact with it (silently disabled while draft mode is on)

* feat: cleaning up unused var, tests, and locales

* feat: updating copy

GitOrigin-RevId: 8010edfab164980f14125739e481d8b512f6b3df
2026-09-17 11:47:49 +00:00

47 lines
1.3 KiB
TypeScript

import { useTranslation } from 'react-i18next'
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
import { useCallback, useMemo } from 'react'
import DropdownSetting from '../dropdown-setting'
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
type CompileMode = 'normal' | 'fast_draft'
export default function DraftSetting() {
const { draft, setDraft } = useCompileContext()
const { t } = useTranslation()
const { sendEvent } = useEditorAnalytics()
const mode: CompileMode = draft ? 'fast_draft' : 'normal'
const changeMode = useCallback(
(value: CompileMode) => {
sendEvent('recompile-setting-changed', {
setting: 'compile-mode',
settingVal: value,
})
setDraft(value === 'fast_draft')
},
[sendEvent, setDraft]
)
const options = useMemo(
() => [
{ label: t('normal'), value: 'normal' as const },
{ label: t('fast_draft'), value: 'fast_draft' as const },
],
[t]
)
return (
<DropdownSetting
id="draft"
label={t('compile_mode')}
options={options}
description={t('switch_compile_mode_for_faster_draft_compilation')}
value={mode}
onChange={changeMode}
width="default"
/>
)
}