import classNames from 'classnames' import React from 'react' import { Plain, types } from 'react-bricks/frontend' import { RichText, Text, Image, Link } from 'react-bricks/frontend' import blockNames from '../../blockNames' import { textColors } from '../../colors' import { icons } from '../../shared/defaultImages' interface CardProps { withIcon: boolean withTitle: boolean withLink: boolean linkText: types.TextValue linkPath: string logo: types.IImageSource title: types.TextValue description: types.TextValue } const Card: types.Brick = ({ withIcon, withTitle, withLink, linkText, linkPath, logo, title, description, }) => { const linkTextPlain = typeof linkText === 'string' ? linkText : Plain.serialize(linkText) return (
{withIcon && ( logo )}
{withTitle && ( (
{props.children}
)} placeholder="Title..." propName="title" value={title} /> )} (
{props.children}
)} placeholder="Description..." propName="description" value={description} /> {withLink && (

{props.children}

} placeholder="Link..." propName="linkText" value={linkText} />
)}
) } Card.schema = { name: blockNames.Card, label: 'Card', category: 'main content', hideFromAddMenu: true, playgroundLinkLabel: 'View source code on Github', playgroundLinkUrl: 'https://github.com/ReactBricks/reactbricks-starters/blob/main/packages/reactbricks-ui/nextjs-pages/src/mainContent/Cards/Card.tsx', getDefaultProps: () => ({ withIcon: true, withTitle: true, withLink: true, icon: icons.TWITTER, title: 'Twitter', description: 'Get the latest event updates about React Bricks.', linkText: 'Follow us now', }), sideEditProps: [ { name: 'withIcon', label: 'With Icon', type: types.SideEditPropType.Boolean, }, { name: 'withTitle', label: 'With Title', type: types.SideEditPropType.Boolean, }, { name: 'withLink', label: 'With Link', type: types.SideEditPropType.Boolean, }, { name: 'linkPath', label: 'Link to', type: types.SideEditPropType.Text, show: ({ withLink }) => !!withLink, }, ], } export default Card