import React from "react"; import { STATUS_VARIANT } from "../types"; import { Banner } from "../components/Banner"; export enum COMPONENT_STATUS { ALPHA = "alpha", BETA = "beta", DEPRECATED = "deprecated", DOCUMENTATION_PENDING = "documentation-pending", A11Y_VIOLATION_COLOR_CONTRAST = "a11y-violation-color-contrast", } export interface ComponentStatusProps { status?: COMPONENT_STATUS; children?: React.ReactNode; } const statusVariantMap = { [COMPONENT_STATUS.ALPHA]: STATUS_VARIANT.DEFAULT, [COMPONENT_STATUS.BETA]: STATUS_VARIANT.DANGER, [COMPONENT_STATUS.DEPRECATED]: STATUS_VARIANT.WARNING, [COMPONENT_STATUS.DOCUMENTATION_PENDING]: STATUS_VARIANT.WARNING, [COMPONENT_STATUS.A11Y_VIOLATION_COLOR_CONTRAST]: STATUS_VARIANT.WARNING, }; const statusTitleMap = { [COMPONENT_STATUS.ALPHA]: "Alpha", [COMPONENT_STATUS.BETA]: "Beta", [COMPONENT_STATUS.DEPRECATED]: "Deprecated", [COMPONENT_STATUS.DOCUMENTATION_PENDING]: "Documentation Pending", [COMPONENT_STATUS.A11Y_VIOLATION_COLOR_CONTRAST]: "Poor Color Contrast", }; const statusMessageMap = { [COMPONENT_STATUS.ALPHA]: `This component is still under development. It may behave or break unexpectedly; use with caution.`, [COMPONENT_STATUS.BETA]: `This component is still a work-in-progress and should not be used for production-ready apps.`, [COMPONENT_STATUS.DEPRECATED]: `This component has been deprecated and will be removed from the next major version.`, [COMPONENT_STATUS.DOCUMENTATION_PENDING]: `The documentation for this component is undergoing maintenance. All component configuration examples may not be illustrated below and some demonstrations may not be working`, [COMPONENT_STATUS.A11Y_VIOLATION_COLOR_CONTRAST]: `Variants of this component violate acceptable color contrast ratio for legibility.`, }; export const ComponentStatus = ({ status, children }: ComponentStatusProps) => { if (!status) { return null; } return ( {statusMessageMap[status]} {children} ); };