| 1 |
import React from 'react' |
| 2 |
import { __, _n, sprintf } from '@wordpress/i18n' |
| 3 |
import classnames from 'classnames' |
| 4 |
import { Badge } from '../../common/Badge' |
| 5 |
import { Button } from '../../common/Button' |
| 6 |
import { DEMO_PLAN } from './demoScript' |
| 7 |
import { languageToSnippetType } from './types' |
| 8 |
|
| 9 |
interface DemoPlanCardProps { |
| 10 |
/** Whether the walkthrough is clicking "Accept & create" right now. */ |
| 11 |
accepted: boolean |
| 12 |
} |
| 13 |
|
| 14 |
export const DemoPlanCard: React.FC<DemoPlanCardProps> = ({ accepted }) => { |
| 15 |
const badge = sprintf( |
| 16 |
/* translators: %d: number of snippets in the bundle. */ |
| 17 |
_n('Bundle · %d snippet', 'Bundle · %d snippets', DEMO_PLAN.parts.length, 'code-snippets'), |
| 18 |
DEMO_PLAN.parts.length |
| 19 |
) |
| 20 |
|
| 21 |
return ( |
| 22 |
<div className="ai-agent-plan"> |
| 23 |
<div className="ai-agent-plan__header"> |
| 24 |
<h2 className="ai-agent-plan__title">{DEMO_PLAN.title}</h2> |
| 25 |
<span className="ai-agent-plan__badge is-bundle">{badge}</span> |
| 26 |
</div> |
| 27 |
|
| 28 |
<p className="ai-agent-plan__overview">{DEMO_PLAN.summary}</p> |
| 29 |
|
| 30 |
<h3 className="ai-agent-plan__parts-heading">{__('What will be created', 'code-snippets')}</h3> |
| 31 |
|
| 32 |
<ul className="ai-agent-plan__parts"> |
| 33 |
{DEMO_PLAN.parts.map(part => |
| 34 |
<li key={part.name} className="ai-agent-plan__part"> |
| 35 |
<Badge name={languageToSnippetType(part.language)} small /> |
| 36 |
<span className="ai-agent-plan__part-name">{part.name}</span> |
| 37 |
<p className="ai-agent-plan__part-desc">{part.description}</p> |
| 38 |
</li>)} |
| 39 |
</ul> |
| 40 |
|
| 41 |
<div className="ai-agent-plan__actions"> |
| 42 |
<Button |
| 43 |
primary |
| 44 |
type="button" |
| 45 |
className={classnames('ai-agent-demo-accept', { 'demo-click': accepted })} |
| 46 |
aria-hidden="true" |
| 47 |
tabIndex={-1} |
| 48 |
> |
| 49 |
{__('Accept & create', 'code-snippets')} |
| 50 |
</Button> |
| 51 |
|
| 52 |
<Button secondary type="button" aria-hidden="true" tabIndex={-1}> |
| 53 |
{__('Refine plan', 'code-snippets')} |
| 54 |
</Button> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
) |
| 58 |
} |
| 59 |
|