/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Icon, check } from '@wordpress/icons'; import { Button, Tooltip } from '@wordpress/components'; import { Text } from '@woocommerce/experimental'; import { __experimentalListItem as ListItem } from '@woocommerce/components'; import NoticeOutline from 'gridicons/dist/notice-outline'; import classnames from 'classnames'; /** * Internal dependencies */ import './task-item.scss'; import sanitizeHTML from '../lib/sanitize-html'; type TaskLevel = 1 | 2 | 3; type TaskItemProps = { title: string; completed: boolean; onClick: () => void; isDismissable?: boolean; onDismiss?: () => void; additionalInfo?: string; time?: string; content?: string; expanded?: boolean; level?: TaskLevel; }; const OptionalTaskTooltip: React.FC< { level: TaskLevel; completed: boolean; children: JSX.Element; } > = ( { level, completed, children } ) => { let tooltip = ''; if ( level === 1 && ! completed ) { tooltip = __( 'This task is required to keep your store running', 'woocommerce-admin' ); } else if ( level === 2 && ! completed ) { tooltip = __( 'This task is required to set up your extension', 'woocommerce-admin' ); } if ( tooltip === '' ) { return children; } return { children }; }; export const TaskItem: React.FC< TaskItemProps > = ( { completed, title, isDismissable, onDismiss, onClick, additionalInfo, time, content, expanded = false, level = 3, } ) => { const className = classnames( 'woocommerce-task-list__item', { complete: completed, 'level-2': level === 2 && ! completed, 'level-1': level === 1 && ! completed, } ); return (
{ level === 1 && ! completed ? ( ) : (
{ completed && }
) }
{ title } { additionalInfo && (
) } { expanded && content && (
{ content }
) } { time && ! completed && (
{ time }
) }
{ onDismiss && isDismissable && ! completed && (
) }
); };