| 1 |
import React from 'react' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import classnames from 'classnames' |
| 4 |
import { DEMO_SECTIONS } from './demoBlueprint' |
| 5 |
|
| 6 |
interface BlueprintSidebarProps { |
| 7 |
activeSection: string |
| 8 |
browsable: boolean |
| 9 |
/** Whether the walkthrough is clicking the generate button right now. */ |
| 10 |
generating: boolean |
| 11 |
onSelect: (id: string) => void |
| 12 |
} |
| 13 |
|
| 14 |
export const BlueprintSidebar: React.FC<BlueprintSidebarProps> = ({ |
| 15 |
activeSection, |
| 16 |
browsable, |
| 17 |
generating, |
| 18 |
onSelect |
| 19 |
}) => |
| 20 |
<nav className="blueprint-form-sidebar" aria-label={__('Blueprint sections', 'code-snippets')}> |
| 21 |
<ul> |
| 22 |
{DEMO_SECTIONS.map(section => { |
| 23 |
const isActive = section.id === activeSection |
| 24 |
|
| 25 |
return ( |
| 26 |
<li key={section.id}> |
| 27 |
<button |
| 28 |
type="button" |
| 29 |
className={classnames('blueprint-form-sidebar__item', { 'is-active': isActive })} |
| 30 |
aria-current={isActive ? 'step' : undefined} |
| 31 |
disabled={!browsable} |
| 32 |
onClick={() => onSelect(section.id)} |
| 33 |
> |
| 34 |
<span>{section.title}</span> |
| 35 |
</button> |
| 36 |
</li> |
| 37 |
) |
| 38 |
})} |
| 39 |
</ul> |
| 40 |
|
| 41 |
<div className="blueprint-form-sidebar__generate-wrap"> |
| 42 |
<button |
| 43 |
type="button" |
| 44 |
className={classnames('blueprint-form-sidebar__generate', { 'demo-click': generating })} |
| 45 |
aria-hidden="true" |
| 46 |
tabIndex={-1} |
| 47 |
> |
| 48 |
{__('Generate Code', 'code-snippets')} |
| 49 |
</button> |
| 50 |
</div> |
| 51 |
</nav> |
| 52 |
|