PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.0.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.0.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / src / admin / components / ui / AIButton.js

AIButton.js in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 1.0.0, at src/admin/components/ui/AIButton.js

79 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * AI Button Component
3 *
4 * Standardized button component for AI-powered features
5 * Includes sparkle icon and consistent loading states
6 *
7 * @package ThinkRank
8 * @since 1.0.0
9 */
10
11 import { Button, Spinner } from '@wordpress/components';
12 import { __ } from '@wordpress/i18n';
13
14 /**
15 * AI Button Component
16 *
17 * @param {Object} props Component props
18 * @param {string} props.children Button text
19 * @param {boolean} props.isLoading Loading state
20 * @param {string} props.variant Button variant (primary, secondary)
21 * @param {string} props.size Button size (small, medium, large)
22 * @param {boolean} props.showSparkle Show sparkle icon
23 * @param {string} props.className Additional CSS classes
24 * @param {Function} props.onClick Click handler
25 * @param {boolean} props.disabled Disabled state
26 * @param {Object} props.rest Additional props
27 */
28 const AIButton = ({
29 children,
30 isLoading = false,
31 variant = 'primary',
32 size = 'medium',
33 showSparkle = true,
34 className = '',
35 onClick,
36 disabled = false,
37 ...rest
38 }) => {
39 const buttonClasses = [
40 'thinkrank-ai-button',
41 `thinkrank-ai-button--${variant}`,
42 `thinkrank-ai-button--${size}`,
43 className
44 ].filter(Boolean).join(' ');
45
46 const handleClick = (event) => {
47 if (!isLoading && !disabled && onClick) {
48 onClick(event);
49 }
50 };
51
52 return (
53 <Button
54 className={buttonClasses}
55 disabled={isLoading || disabled}
56 onClick={handleClick}
57 isPrimary={variant === 'primary'}
58 isSecondary={variant === 'secondary'}
59 {...rest}
60 >
61 {isLoading ? (
62 <>
63 <Spinner />
64 {__('Processing...', 'thinkrank')}
65 </>
66 ) : (
67 <>
68 {showSparkle && (
69 <span className="sparkle-icon" aria-hidden="true"></span>
70 )}
71 {children}
72 </>
73 )}
74 </Button>
75 );
76 };
77
78 export default AIButton;
79