/** * SettingsCard Component * * Standardized settings card component extracted from Site Identity patterns. * Provides consistent card structure with integrated optimization controls, * toggle functionality, and notice display across all Essential SEO tabs. * * @package ThinkRank * @since 1.0.0 */ import { Card, CardHeader, CardBody, Flex, FlexItem, ToggleControl, Notice } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * SettingsCard Component * * @param {Object} props Component props * @param {string} props.title Card title displayed in header * @param {boolean} props.enabled Enable/disable state for the feature * @param {Function} props.onToggle Toggle handler function * @param {string} props.toggleLabel Custom toggle label (overrides default) * @param {Array} props.optimizationButtons Array of optimization button components * @param {Object} props.notice Notice object with status and message * @param {Function} props.onNoticeRemove Notice removal handler * @param {React.ReactNode} props.children Card content * @param {string} props.className Additional CSS classes * @param {string} props.size Card size: 'small', 'medium', 'large' * @param {boolean} props.showDisabledWarning Show warning when disabled * @param {string} props.disabledWarningMessage Custom disabled warning message */ const SettingsCard = ({ title, enabled = true, onToggle, toggleLabel, optimizationButtons = [], notice, onNoticeRemove, children, className = '', size = 'medium', showDisabledWarning = true, disabledWarningMessage, ...rest }) => { /** * Handle notice dismissal * Following Site Identity notice management pattern */ const handleNoticeRemove = () => { if (onNoticeRemove) { onNoticeRemove(); } }; /** * Get default disabled warning message */ const getDisabledWarningMessage = () => { if (disabledWarningMessage) { return disabledWarningMessage; } return __('This feature is disabled. Enable it to access configuration options.', 'thinkrank'); }; // Combine CSS classes const cardClasses = [ 'thinkrank-settings-card', `thinkrank-settings-card--${size}`, className ].filter(Boolean).join(' '); return (

{title}

{/* Render optimization buttons */} {optimizationButtons.map((button, index) => (
{button}
))} {/* Render toggle control if onToggle is provided */} {onToggle && ( )}
{/* Show disabled warning if feature is disabled */} {!enabled && showDisabledWarning && ( {getDisabledWarningMessage()} )} {/* Show notice if provided */} {notice && ( {notice.message} )} {/* Card content */} {children}
); }; export default SettingsCard;