import * as React from 'react'; import classNames from 'classnames'; type RwdHelperTypeType = | 'small-only' | 'medium-only' | 'medium-down' | 'medium-up' | 'large-only'; export const TYPE = { SMALL_ONLY: 'small-only', MEDIUM_ONLY: 'medium-only', MEDIUM_DOWN: 'medium-down', MEDIUM_UP: 'medium-up', LARGE_ONLY: 'large-only', } as const; export type RwdHelperPropsType = { hide: RwdHelperTypeType; children: React.ReactElement | string; } & Omit, 'hide' | 'children'>; const RwdHelper = ({hide, children}: RwdHelperPropsType) => { if (!children) { return null; } const hideClass = `sg-hide-for-${hide}`; if (typeof children === 'string') { return {children}; } const finalClassName = classNames(children.props.className, hideClass); return React.cloneElement(children, { className: finalClassName, }); }; export default RwdHelper;