import { BaseControl } from '@wordpress/components'; import { sprintf, __ } from '@wordpress/i18n'; import { Attributes } from '../../types'; import { Headlights } from './headers/Headlights'; import { HeadlightsMuted } from './headers/HeadlightsMuted'; import { HeadlightsMutedAlt } from './headers/HeadlightsMutedAlt'; import { PillString } from './headers/PillString'; import { SimpleString } from './headers/SimpleString'; import { StringSmall } from './headers/StringSmall'; import { UnsupportedTheme } from './misc/Unsupported'; type HeaderSelectProps = { attributes: Attributes; onClick: (slug: string) => void; }; const unsupportedWithCssVars = ['headlightsMutedAlt']; export const HeaderSelect = ({ attributes, onClick }: HeaderSelectProps) => { const { headerType, ...attributesWithoutHeaderType }: Attributes = attributes; const { bgColor } = attributes; const types = { none: __('None', 'code-block-pro'), headlights: __('Headlights', 'code-block-pro'), headlightsMuted: __('Headlights muted', 'code-block-pro'), headlightsMutedAlt: __('Headlights muted alt', 'code-block-pro'), simpleString: __('Simple string', 'code-block-pro'), stringSmall: __('String muted', 'code-block-pro'), pillString: __('Pill string', 'code-block-pro'), }; const isUnsupported = bgColor?.startsWith('var('); return (
{Object.entries(types).map(([slug, type]) => ( {isUnsupported && unsupportedWithCssVars.includes(slug) && ( )} ))}
); }; export const HeaderType = (attributes: Attributes) => { const { headerType, bgColor } = attributes; const isACustomTheme = bgColor?.startsWith('var('); if (isACustomTheme && unsupportedWithCssVars.includes(headerType ?? '')) { return null; } if (headerType === 'headlights') { return ; } if (headerType === 'headlightsMuted') { return ; } if (headerType === 'headlightsMutedAlt') { return ; } if (headerType === 'simpleString') { return ; } if (headerType === 'stringSmall') { return ; } if (headerType === 'pillString') { return ; } return null; };