import * as React from 'react'; import Promote from '../../../icons/Promote'; import Code from '../../../icons/Code'; import { HeaderSection } from '../../../typings/story-section'; import { StoryConfig } from '../../../typings/story-config'; import { Layout, Cell } from '../../../ui/Layout'; import styles from './styles.scss'; import classNames from 'classnames'; import Badge from '../../../ui/badge'; export const header: (a: HeaderSection, b: StoryConfig) => React.ReactNode = ( section, storyConfig, ) => { const { title, component, sourceUrl, issueUrl, source = true } = section; const issueURL = storyConfig.config?.issueURL || issueUrl; const status = storyConfig?.story?.config?.status; const renderStatus = () => { return ( {status === 'wip' ? 'WORK IN PROGRESS' : 'DEPRECATED'} ); }; const renderStatusMessage = () => { const statusToMessageMap = { wip: "This component is under development. API is not stable yet and can change anytime. Please don't use this component unless you were instructed otherwise.", deprecated: 'This component deprecated and will not be supported moving forward.', }; return (
{storyConfig?.story?.config?.statusMessage || statusToMessageMap[status]}
); }; const renderHeader = () => { return ( <> <>
{title || storyConfig.storyName} {status && renderStatus()}
{status && renderStatusMessage()}
{issueURL && (
Report an issue
)} {source && (
Source
)}
{component &&
{component}
} ); }; return (
{renderHeader()}
); };