import React, { createContext, useContext } from 'react' import type { ContentTree } from '@financial-times/content-tree' import classnames from 'classnames' import type scrollytelling from '@financial-times/n-scrollytelling-image/server' import { ParagraphContext } from '../Paragraph' import { ContentProps } from '../../types' export const ScrollyIDContext = createContext(null) interface ScrollyBlockProps extends ContentProps {} export const ScrollyBlock: React.FC< React.PropsWithChildren > = ({ content: { theme }, children, parentIndex }) => (
{React.Children.map(children, (child, index) => ( {child} ))}
) type ScrollySectionOptions = Pick< ContentTree.ScrollySection, 'display' | 'noBox' | 'position' | 'transition' > const ScrollySectionOptionsContext = createContext(null) interface ScrollySectionProps extends ContentProps {} export const ScrollySection: React.FC< React.PropsWithChildren > = ({ content: { display, noBox, position, transition }, children }) => ( <>{children} ) type ScrollytellingDisplaySuffix = scrollytelling.ScrollytellingOptionsMap['display'][keyof scrollytelling.ScrollytellingOptionsMap['display']] interface ScrollyCopyProps extends ContentProps {} export const ScrollyCopy: React.FC< React.PropsWithChildren > = ({ children }) => { const { display, noBox, position, transition } = useContext( ScrollySectionOptionsContext ) ?? { display: 'dark-background', position: 'center', } const scrollyId = useContext(ScrollyIDContext) const displaySuffix: ScrollytellingDisplaySuffix = display === 'dark-background' ? 'background-dark' : 'background-light' return (
<>{children}
) } interface ScrollyHeadingProps extends ContentProps {} export const ScrollyHeading: React.FC< React.PropsWithChildren > = ({ content: { level }, children }) => { const classNames = classnames( 'n-scrollytelling__overlay-text', `n-scrollytelling__overlay-text--text-style-${level}` ) switch (level) { case 'chapter': return

{children}

case 'heading': return

{children}

case 'subheading': return

{children}

} }