import classNames from 'classnames' import { Text, types } from 'react-bricks/rsc' import blockNames from '../../blockNames' import { textColors } from '../../colors' type TextAlign = 'left' | 'center' | 'right' export interface TableCellProps { isHeader: boolean textAlign: TextAlign borders: 'none' | 'horizontal' | 'all' cellText: types.TextValue } const getAlignClass = (textAlign: TextAlign) => { switch (textAlign) { case 'left': return 'text-left' case 'center': return 'text-center' case 'right': return 'text-right' } } const TableCell: types.Brick = ({ isHeader = false, textAlign = 'left', borders, cellText, }) => { if (isHeader) { return ( ( {children} )} /> ) } return ( {children}} /> ) } TableCell.schema = { name: blockNames.TableCell, label: 'Cell', category: 'single column / blog', hideFromAddMenu: true, playgroundLinkLabel: 'View source code on Github', playgroundLinkUrl: 'https://github.com/ReactBricks/reactbricks-starters/blob/main/packages/reactbricks-ui/nextjs-app/src/singleColumnContent/Table/TableCell.tsx', getDefaultProps: () => ({ cellText: '', textAlign: 'left', }), sideEditProps: [ { name: 'textAlign', label: 'Text alignment', type: types.SideEditPropType.Select, selectOptions: { display: types.OptionsDisplay.Radio, options: [ { value: 'left', label: 'Left' }, { value: 'center', label: 'Center' }, { value: 'right', label: 'Right' }, ], }, }, ], } export default TableCell