editor-theme-setting.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { useProjectSettingsContext } from '@/features/editor-left-menu/context/project-settings-context'
  2. import DropdownSetting from '../dropdown-setting'
  3. import { useTranslation } from 'react-i18next'
  4. import { useEditorThemesOptionGroups } from '@/features/editor-left-menu/hooks/use-editor-theme-option-groups'
  5. import { isIEEEBranded } from '@/utils/is-ieee-branded'
  6. export default function EditorThemeSetting() {
  7. const {
  8. editorTheme,
  9. setEditorTheme,
  10. editorLightTheme,
  11. setEditorLightTheme,
  12. editorDarkTheme,
  13. setEditorDarkTheme,
  14. overallTheme,
  15. } = useProjectSettingsContext()
  16. const { t } = useTranslation()
  17. const optGroups = useEditorThemesOptionGroups()
  18. if (overallTheme === 'system' && !isIEEEBranded()) {
  19. return (
  20. <>
  21. <DropdownSetting
  22. id="editorLightTheme"
  23. label={t('editor_theme_light')}
  24. description={t('the_code_editor_color_scheme_light_mode')}
  25. optgroups={optGroups}
  26. onChange={setEditorLightTheme}
  27. value={editorLightTheme}
  28. translateOptions="no"
  29. width="wide"
  30. />
  31. <DropdownSetting
  32. id="editorDarkTheme"
  33. label={t('editor_theme_dark')}
  34. description={t('the_code_editor_color_scheme_dark_mode')}
  35. optgroups={optGroups}
  36. onChange={setEditorDarkTheme}
  37. value={editorDarkTheme}
  38. translateOptions="no"
  39. width="wide"
  40. />
  41. </>
  42. )
  43. }
  44. return (
  45. <DropdownSetting
  46. id="editorTheme"
  47. label={t('editor_theme')}
  48. description={t('the_code_editor_color_scheme')}
  49. optgroups={optGroups}
  50. onChange={setEditorTheme}
  51. value={editorTheme}
  52. translateOptions="no"
  53. width="wide"
  54. />
  55. )
  56. }