/* * External dependencies */ import { speakToneIcon } from '@automattic/jetpack-ai-client'; import { MenuItem, MenuGroup, ToolbarDropdownMenu, DropdownMenu, Icon, Button, Tooltip, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { chevronRight } from '@wordpress/icons'; import React from 'react'; /** * Internal dependencies */ import './style.scss'; const PROMPT_TONES_LIST = [ 'formal', 'informal', 'optimistic', // 'pessimistic', 'humorous', 'serious', 'skeptical', 'empathetic', // 'enthusiastic', // 'neutral', 'confident', // 'curious', // 'respectful', 'passionate', // 'cautious', 'provocative', // 'inspirational', // 'satirical', // 'dramatic', // 'mysterious', ] as const; export const DEFAULT_PROMPT_TONE = 'formal'; export const PROMPT_TONES_MAP = { formal: { label: __( 'Formal', 'jetpack' ), emoji: '๐ŸŽฉ', }, informal: { label: __( 'Informal', 'jetpack' ), emoji: '๐Ÿ˜Š', }, optimistic: { label: __( 'Optimistic', 'jetpack' ), emoji: '๐Ÿ˜ƒ', }, // pessimistic: { // label: __( 'Pessimistic', 'jetpack' ), // emoji: 'โ˜น๏ธ', // }, humorous: { label: __( 'Humorous', 'jetpack' ), emoji: '๐Ÿ˜‚', }, serious: { label: __( 'Serious', 'jetpack' ), emoji: '๐Ÿ˜', }, skeptical: { label: __( 'Skeptical', 'jetpack' ), emoji: '๐Ÿคจ', }, empathetic: { label: __( 'Empathetic', 'jetpack' ), emoji: '๐Ÿ’—', }, // enthusiastic: { // label: __( 'Enthusiastic', 'jetpack' ), // emoji: '๐Ÿคฉ', // }, // neutral: { // label: __( 'Neutral', 'jetpack' ), // emoji: '๐Ÿ˜ถ', // }, confident: { label: __( 'Confident', 'jetpack' ), emoji: '๐Ÿ˜Ž', }, // curious: { // label: __( 'Curious', 'jetpack' ), // emoji: '๐Ÿง', // }, // respectful: { // label: __( 'Respectful', 'jetpack' ), // emoji: '๐Ÿ™', // }, passionate: { label: __( 'Passionate', 'jetpack' ), emoji: 'โค๏ธ', }, // cautious: { // label: __( 'Cautious', 'jetpack' ), // emoji: '๐Ÿšง', // }, provocative: { label: __( 'Provocative', 'jetpack' ), emoji: '๐Ÿ”ฅ', }, // inspirational: { // label: __( 'Inspirational', 'jetpack' ), // emoji: 'โœจ', // }, // satirical: { // label: __( 'Satirical', 'jetpack' ), // emoji: '๐Ÿƒ', // }, // dramatic: { // label: __( 'Dramatic', 'jetpack' ), // emoji: '๐ŸŽญ', // }, // mysterious: { // label: __( 'Mysterious', 'jetpack' ), // emoji: '๐Ÿ”ฎ', // }, }; export type ToneProp = ( typeof PROMPT_TONES_LIST )[ number ]; type ToneToolbarDropdownMenuProps = { value?: ToneProp; onChange: ( value: ToneProp ) => void; label?: string; disabled?: boolean; }; const ToneMenuGroup = ( { value, onChange }: ToneToolbarDropdownMenuProps ) => ( { PROMPT_TONES_LIST.map( tone => { return ( onChange( tone ) } isSelected={ value === tone } > { `${ PROMPT_TONES_MAP[ tone ].emoji } ${ PROMPT_TONES_MAP[ tone ].label }` } ); } ) } ); export function ToneDropdownMenu( { label = __( 'Change tone', 'jetpack' ), value = DEFAULT_PROMPT_TONE, onChange, disabled = false, }: ToneToolbarDropdownMenuProps ) { return (
{ label }
), disabled, } } > { ( { onClose } ) => ( { onChange( newTone ); onClose(); } } /> ) }
); } export default function ToneToolbarDropdownMenu( { value = DEFAULT_PROMPT_TONE, onChange, disabled = false, }: ToneToolbarDropdownMenuProps ) { const label = __( 'Change tone', 'jetpack' ); return disabled ? ( ) : ( { () => } ); }