import * as React from 'react' import { Image, types, Text, Link, Plain } from 'react-bricks/rsc' import classNames from 'classnames' import blockNames from '../../blockNames' import { textColors } from '../../colors' import { ColsNumber } from './Features' import { icons } from '../../shared/defaultImages' export interface FeatureItemProps { colsNumber: ColsNumber withIcon: boolean withLink: boolean linkPath: string image: types.IImageSource title: types.TextValue text: types.TextValue linkText: types.TextValue } const getColumnClass = (colsNumber: ColsNumber) => { switch (colsNumber) { case '2': return 'sm:flex-[0_1_45%] mb-12 sm:mb-16' case '3': return 'sm:flex-[0_1_27%] mb-12 sm:mb-16' case '4': return 'sm:flex-[0_1_45%] lg:flex-[0_1_20.1%] mb-12 sm:mb-16' } } const FeatureItem: types.Brick = ({ colsNumber, withIcon, withLink, linkPath, image, title, text, linkText, }) => { const linkTextPlain = typeof linkText === 'string' ? linkText : Plain.serialize(linkText) return (
{withIcon && ( feature { return (
{children}
) }} /> )}
(
{props.children}
)} /> (
{props.children}
)} /> {withLink && (

{props.children}

} placeholder="Link..." />
)}
) } FeatureItem.schema = { name: blockNames.FeatureItem, label: 'Feature', category: 'main content', hideFromAddMenu: true, playgroundLinkLabel: 'View source code on Github', playgroundLinkUrl: 'https://github.com/ReactBricks/reactbricks-starters/blob/main/packages/reactbricks-ui/nextjs-app/src/mainContent/Features/FeatureItem.tsx', getDefaultProps: () => ({ title: 'The best experience for editors', text: 'Your marketing team hates gray forms. Give them the easiest UX.', withIcon: true, withLink: false, image: icons.PHOTO_STACK, }), sideEditProps: [ { name: 'withIcon', label: 'With icon', type: types.SideEditPropType.Boolean, }, { name: 'withLink', label: 'With link', type: types.SideEditPropType.Boolean, }, { name: 'linkPath', label: 'Link to', type: types.SideEditPropType.Text, show: ({ withLink }, page, user) => !!withLink, }, ], } export default FeatureItem