try-new-editor-button.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { useCallback } from 'react'
  2. import OLButton from '../../shared/components/ol/ol-button'
  3. import { useTranslation } from 'react-i18next'
  4. import { useSwitchEnableNewEditorState } from '../ide-redesign/hooks/use-switch-enable-new-editor-state'
  5. import MaterialIcon from '@/shared/components/material-icon'
  6. import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
  7. const TryNewEditorButton = () => {
  8. const { t } = useTranslation()
  9. const { loading, setEditorRedesignStatus } = useSwitchEnableNewEditorState()
  10. const { sendEvent } = useEditorAnalytics()
  11. const onClick = useCallback(() => {
  12. sendEvent('switch-to-new-editor', {
  13. location: 'toolbar',
  14. })
  15. setEditorRedesignStatus(true)
  16. }, [setEditorRedesignStatus, sendEvent])
  17. return (
  18. <div className="d-flex align-items-center">
  19. <OLButton
  20. className="toolbar-experiment-button try-new-editor-button"
  21. onClick={onClick}
  22. size="sm"
  23. variant="secondary"
  24. isLoading={loading}
  25. >
  26. <MaterialIcon type="fiber_new" />
  27. {t('try_the_new_editor_design')}
  28. </OLButton>
  29. </div>
  30. )
  31. }
  32. export default TryNewEditorButton