import { Button } from '@wordpress/components'; import SettingsBlock from './SettingsBlock'; import { Header, Title, Action, Description } from './SettingsBlockElements'; import TitleBadge from '../TitleBadge'; const FeatureSettingsBlock = ( { title, description, ...props } ) => { const printNotes = () => { const notes = props.actionProps?.notes; if ( ! notes || ( Array.isArray( notes ) && notes.length === 0 ) ) { return null; } return ( { notes.map( ( note, index ) => ( { note } ) ) } ); }; const renderButton = ( button ) => { const buttonElement = ( ); // If there's a URL (either direct or in urls object), wrap in anchor tag if ( button.url || button.urls ) { const href = button.urls ? button.urls.live : button.url; return ( { buttonElement } ); } return buttonElement; }; return (
{ title } { props.actionProps?.enabled && ( <TitleBadge { ...props.actionProps?.badge } /> ) } { description } { printNotes() }
{ props.actionProps?.buttons.map( renderButton ) }
); }; export default FeatureSettingsBlock;