add confirm dialog

This commit is contained in:
Matt Wiebe 2023-08-09 22:07:04 -05:00
parent 773abd38d9
commit a5e11a47d6

View file

@ -1,6 +1,11 @@
import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { SelectControl, PanelBody, Button } from '@wordpress/components'; import {
SelectControl,
PanelBody,
Button,
__experimentalConfirmDialog as ConfirmDialog
} from '@wordpress/components';
import { useUserOptions } from '../shared/use-user-options'; import { useUserOptions } from '../shared/use-user-options';
import apiFetch from '@wordpress/api-fetch'; import apiFetch from '@wordpress/api-fetch';
import { useEffect, useState } from '@wordpress/element'; import { useEffect, useState } from '@wordpress/element';
@ -89,10 +94,22 @@ function Profile( profile ) {
} }
function Follow( { profile } ) { function Follow( { profile } ) {
const [ isOpen, setIsOpen ] = useState( false );
return ( return (
<Button className="activitypub-profile__follow" isPrimary onClick={ () => console.log( profile ) } > <>
{ __( 'Follow', 'fediverse' ) } <Button className="activitypub-profile__follow" isPrimary onClick={ () => setIsOpen( true ) } >
</Button> { __( 'Follow', 'fediverse' ) }
</Button>
<ConfirmDialog
className="activitypub-profile__confirm"
isOpen={ isOpen }
onConfirm={ () => setIsOpen( false ) }
onCancel={ () => setIsOpen( false ) }
>
Todo: put the follow layout in here.
</ConfirmDialog>
</>
); );
} }