| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { useMemo } from 'react'
- import { useTranslation } from 'react-i18next'
- import { useLayoutContext } from '../../../../shared/context/layout-context'
- import getMeta from '../../../../utils/meta'
- import SettingsMenuSelect, { Option } from './settings-menu-select'
- import { useProjectSettingsContext } from '../../context/project-settings-context'
- import type { OverallThemeMeta } from '../../../../../../types/project-settings'
- import type { OverallTheme } from '../../../source-editor/extensions/theme'
- import { ExposedSettings } from '../../../../../../types/exposed-settings'
- export default function SettingsOverallTheme() {
- const { t } = useTranslation()
- const overallThemes = getMeta('ol-overallThemes') as
- | OverallThemeMeta[]
- | undefined
- const { loadingStyleSheet } = useLayoutContext()
- const { overallTheme, setOverallTheme } = useProjectSettingsContext()
- const options: Array<Option<OverallTheme>> = useMemo(
- () =>
- overallThemes?.map(({ name, val }) => ({
- value: val,
- label: name,
- })) ?? [],
- [overallThemes]
- )
- const brandVariation = getMeta('ol-brandVariation') as any
- const { ieeeBrandId } = getMeta('ol-ExposedSettings') as ExposedSettings
- const isIEEEBranded = brandVariation?.brand_id === ieeeBrandId
- if (!overallThemes || isIEEEBranded) {
- return null
- }
- return (
- <SettingsMenuSelect<OverallTheme>
- onChange={setOverallTheme}
- value={overallTheme}
- options={options}
- loading={loadingStyleSheet}
- label={t('overall_theme')}
- name="overallTheme"
- />
- )
- }
|