/** * WordPress dependencies */ import { Button, Modal, TextareaControl } from '@safe-wordpress/components'; import { useState } from '@safe-wordpress/element'; import { _x } from '@safe-wordpress/i18n'; import type { ExperimentEditProps } from '@nab/types'; /** * External dependencies */ import { trim } from 'lodash'; /** * Internal dependencies */ import './style.scss'; import type { ControlAttributes } from '../../types'; export const Original = ( { attributes, setAttributes, }: ExperimentEditProps< ControlAttributes > ): JSX.Element => { const [ isModalVisible, setVisibility ] = useState( false ); const [ editingCode, setEditingCode ] = useState( '' ); const { code = '' } = attributes; const isDirty = trim( code ) !== trim( editingCode ); const open = () => { setEditingCode( code ); setVisibility( true ); }; const close = () => { setVisibility( false ); }; const save = () => { close(); setAttributes( { code: ! trim( editingCode ) ? undefined : trim( editingCode ), } ); }; return (

{ _x( 'Current look and feel', 'text', 'nelio-ab-testing' ) }

{ isModalVisible && ( void null } shouldCloseOnClickOutside={ false } >
) }
); }; // ======= // HELPERS // ======= const placeholder = [ _x( 'Customize when the plugin should track page views in the control version. If left empty, Nelio A/B Testing will start tracking as soon as the page has been loaded.', 'user', 'nelio-ab-testing' ), '\n', '\n- ', _x( 'Run callback when dom is ready', 'text', 'nelio-ab-testing' ), '\n utils.domReady( callback );', '\n', '\n- ', _x( 'Show variant:', 'text', 'nelio-ab-testing' ), '\n utils.showContent();', '\n', '\n- ', _x( 'Show variant and track events', 'text', 'nelio-ab-testing' ), '\n done();', ].join( '' );