| 1 |
/** |
| 2 |
* Schema How-To Form Component |
| 3 |
* |
| 4 |
* Extracted from SchemaGeneration.js - handles how-to schema form fields |
| 5 |
* |
| 6 |
* @package ThinkRank |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
import { __ } from '@wordpress/i18n'; |
| 11 |
import { |
| 12 |
Card, |
| 13 |
CardBody, |
| 14 |
CardHeader, |
| 15 |
TextControl, |
| 16 |
TextareaControl, |
| 17 |
SelectControl, |
| 18 |
Flex, |
| 19 |
FlexItem, |
| 20 |
FormTokenField |
| 21 |
} from '@wordpress/components'; |
| 22 |
import MediaPicker from '../../../common/MediaPicker'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Schema How-To Form Component |
| 26 |
*/ |
| 27 |
const SchemaHowToForm = ({ |
| 28 |
settings, |
| 29 |
onSettingChange, |
| 30 |
isLoading |
| 31 |
}) => { |
| 32 |
return ( |
| 33 |
<Card size="small"> |
| 34 |
<CardHeader> |
| 35 |
<h4>📋 {__('How-To Guide Configuration', 'thinkrank')}</h4> |
| 36 |
</CardHeader> |
| 37 |
<CardBody> |
| 38 |
<Flex direction="column" gap={3}> |
| 39 |
<TextControl |
| 40 |
label={__('How-To Title', 'thinkrank')} |
| 41 |
value={settings.howto_name || ''} |
| 42 |
onChange={(value) => onSettingChange('howto_name', value)} |
| 43 |
help={__('Clear, descriptive title (e.g., "How to Install WordPress")', 'thinkrank')} |
| 44 |
disabled={!settings.enabled} |
| 45 |
__next40pxDefaultSize={true} |
| 46 |
__nextHasNoMarginBottom={true} |
| 47 |
/> |
| 48 |
<TextareaControl |
| 49 |
label={__('Description', 'thinkrank')} |
| 50 |
value={settings.howto_description || ''} |
| 51 |
onChange={(value) => onSettingChange('howto_description', value)} |
| 52 |
help={__('Brief overview of what this guide teaches and the end result', 'thinkrank')} |
| 53 |
disabled={!settings.enabled} |
| 54 |
rows={3} |
| 55 |
__nextHasNoMarginBottom={true} |
| 56 |
/> |
| 57 |
<MediaPicker |
| 58 |
label={__('Guide Image', 'thinkrank')} |
| 59 |
value={settings.howto_image || ''} |
| 60 |
onChange={(value) => onSettingChange('howto_image', value)} |
| 61 |
help={__('Main image for the how-to guide (recommended: 1200x630px)', 'thinkrank')} |
| 62 |
allowedTypes={['image']} |
| 63 |
disabled={!settings.enabled} |
| 64 |
/> |
| 65 |
<TextareaControl |
| 66 |
label={__('Step-by-Step Instructions', 'thinkrank')} |
| 67 |
value={settings.howto_steps || ''} |
| 68 |
onChange={(value) => onSettingChange('howto_steps', value)} |
| 69 |
help={__('Enter each step on a new line. Example:\n1. Download WordPress\n2. Upload files to server\n3. Run installation', 'thinkrank')} |
| 70 |
disabled={!settings.enabled} |
| 71 |
rows={6} |
| 72 |
__nextHasNoMarginBottom={true} |
| 73 |
/> |
| 74 |
<Flex gap={2}> |
| 75 |
<FlexItem> |
| 76 |
<TextControl |
| 77 |
label={__('Total Time', 'thinkrank')} |
| 78 |
value={settings.howto_total_time || ''} |
| 79 |
onChange={(value) => onSettingChange('howto_total_time', value)} |
| 80 |
help={__('Duration in ISO format (PT30M = 30 min, PT2H = 2 hours)', 'thinkrank')} |
| 81 |
disabled={!settings.enabled} |
| 82 |
__next40pxDefaultSize={true} |
| 83 |
__nextHasNoMarginBottom={true} |
| 84 |
/> |
| 85 |
</FlexItem> |
| 86 |
<FlexItem> |
| 87 |
<TextControl |
| 88 |
label={__('Prep Time', 'thinkrank')} |
| 89 |
value={settings.howto_prep_time || ''} |
| 90 |
onChange={(value) => onSettingChange('howto_prep_time', value)} |
| 91 |
help={__('Preparation time (PT10M = 10 minutes)', 'thinkrank')} |
| 92 |
disabled={!settings.enabled} |
| 93 |
__next40pxDefaultSize={true} |
| 94 |
__nextHasNoMarginBottom={true} |
| 95 |
/> |
| 96 |
</FlexItem> |
| 97 |
</Flex> |
| 98 |
<Flex gap={2}> |
| 99 |
<FlexItem> |
| 100 |
<SelectControl |
| 101 |
label={__('Difficulty Level', 'thinkrank')} |
| 102 |
value={settings.howto_difficulty || ''} |
| 103 |
options={[ |
| 104 |
{ value: '', label: __('Select Difficulty', 'thinkrank') }, |
| 105 |
{ value: 'Beginner', label: __('Beginner', 'thinkrank') }, |
| 106 |
{ value: 'Intermediate', label: __('Intermediate', 'thinkrank') }, |
| 107 |
{ value: 'Advanced', label: __('Advanced', 'thinkrank') }, |
| 108 |
{ value: 'Expert', label: __('Expert', 'thinkrank') } |
| 109 |
]} |
| 110 |
onChange={(value) => onSettingChange('howto_difficulty', value)} |
| 111 |
help={__('Skill level required to complete this guide', 'thinkrank')} |
| 112 |
disabled={!settings.enabled} |
| 113 |
__next40pxDefaultSize={true} |
| 114 |
__nextHasNoMarginBottom={true} |
| 115 |
/> |
| 116 |
</FlexItem> |
| 117 |
<FlexItem> |
| 118 |
<TextControl |
| 119 |
label={__('Estimated Cost', 'thinkrank')} |
| 120 |
value={settings.howto_estimated_cost || ''} |
| 121 |
onChange={(value) => onSettingChange('howto_estimated_cost', value)} |
| 122 |
help={__('Approximate cost (e.g., $50, Free, $10-20)', 'thinkrank')} |
| 123 |
disabled={!settings.enabled} |
| 124 |
__next40pxDefaultSize={true} |
| 125 |
__nextHasNoMarginBottom={true} |
| 126 |
/> |
| 127 |
</FlexItem> |
| 128 |
</Flex> |
| 129 |
<div> |
| 130 |
<label style={{ display: 'block', marginBottom: '8px', fontWeight: '500' }}> |
| 131 |
{__('Required Tools', 'thinkrank')} |
| 132 |
</label> |
| 133 |
<FormTokenField |
| 134 |
value={settings.howto_tool || []} |
| 135 |
onChange={(tokens) => onSettingChange('howto_tool', tokens)} |
| 136 |
placeholder={__('Type and press Enter to add tools', 'thinkrank')} |
| 137 |
disabled={!settings.enabled} |
| 138 |
__experimentalExpandOnFocus={true} |
| 139 |
__experimentalShowHowTo={false} |
| 140 |
__next40pxDefaultSize={true} |
| 141 |
__nextHasNoMarginBottom={true} |
| 142 |
/> |
| 143 |
<p style={{ fontSize: '12px', color: '#666', margin: '4px 0 0 0' }}> |
| 144 |
{__('Tools required (e.g., screwdriver, computer, text editor)', 'thinkrank')} |
| 145 |
</p> |
| 146 |
</div> |
| 147 |
<div> |
| 148 |
<label style={{ display: 'block', marginBottom: '8px', fontWeight: '500' }}> |
| 149 |
{__('Materials & Supplies', 'thinkrank')} |
| 150 |
</label> |
| 151 |
<FormTokenField |
| 152 |
value={settings.howto_supply || []} |
| 153 |
onChange={(tokens) => onSettingChange('howto_supply', tokens)} |
| 154 |
placeholder={__('Type and press Enter to add materials', 'thinkrank')} |
| 155 |
disabled={!settings.enabled} |
| 156 |
__experimentalExpandOnFocus={true} |
| 157 |
__experimentalShowHowTo={false} |
| 158 |
__next40pxDefaultSize={true} |
| 159 |
__nextHasNoMarginBottom={true} |
| 160 |
/> |
| 161 |
<p style={{ fontSize: '12px', color: '#666', margin: '4px 0 0 0' }}> |
| 162 |
{__('Materials and supplies needed (e.g., wood, paint, software)', 'thinkrank')} |
| 163 |
</p> |
| 164 |
</div> |
| 165 |
<TextControl |
| 166 |
label={__('Guide URL', 'thinkrank')} |
| 167 |
type="url" |
| 168 |
value={settings.howto_url || ''} |
| 169 |
onChange={(value) => onSettingChange('howto_url', value)} |
| 170 |
help={__('Direct link to the how-to guide page (e.g., https://yoursite.com/how-to-guide)', 'thinkrank')} |
| 171 |
disabled={!settings.enabled} |
| 172 |
__next40pxDefaultSize={true} |
| 173 |
__nextHasNoMarginBottom={true} |
| 174 |
/> |
| 175 |
<TextControl |
| 176 |
label={__('Yield/Result', 'thinkrank')} |
| 177 |
value={settings.howto_yield || ''} |
| 178 |
onChange={(value) => onSettingChange('howto_yield', value)} |
| 179 |
help={__('What the user will have accomplished (e.g., "A working WordPress site")', 'thinkrank')} |
| 180 |
disabled={!settings.enabled} |
| 181 |
__next40pxDefaultSize={true} |
| 182 |
__nextHasNoMarginBottom={true} |
| 183 |
/> |
| 184 |
</Flex> |
| 185 |
</CardBody> |
| 186 |
</Card> |
| 187 |
); |
| 188 |
}; |
| 189 |
|
| 190 |
export default SchemaHowToForm; |
| 191 |
|