import { useBlockProps as blockProps } from '@wordpress/block-editor'; import { registerBlockType } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import type { EnrichedTweet } from 'react-tweet'; import blockConfig from './block.json'; import { NoTweet } from './editor/NoTweet'; import { Settings } from './editor/Settings'; import { Xeet } from './front/Xeet'; import { xIcon } from './icons'; export type Attributes = { xeetId?: string; xeetData?: EnrichedTweet; theme?: 'light' | 'dark'; }; registerBlockType('kevinbatdorf/xeet-wp', { ...blockConfig, icon: xIcon, attributes: { xeetId: { type: 'string' }, xeetData: { type: 'object' }, theme: { type: 'string', default: undefined }, }, title: __('Xeet', 'xeet-wp'), edit: ({ attributes, setAttributes }) => { const { xeetData, theme } = attributes; return ( <>
{xeetData ? null : ( )}
{xeetData && }
); }, save: ({ attributes }) => { const { theme, xeetData } = attributes; return (
{xeetData && }
); }, });