PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Admin / components / StatWidget / index.tsx

index.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Admin/components/StatWidget/index.tsx

65 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {Spinner} from '@givewp/components';
2 import {HeaderText} from '../Header';
3 import PercentChangePill
4 from '@givewp/campaigns/admin/components/CampaignDetailsPage/Components/CampaignStats/PercentChangePill';
5 import classnames from 'classnames';
6 import styles from './styles.module.scss';
7 import { __ } from '@wordpress/i18n';
8
9 /**
10 * @since 4.10.0 replace inActive with upgrade object.
11 * @since 4.6.0 add href & inActive props to handle Fee Recovery widget.
12 * @since 4.4.0
13 */
14 export type StatWidgetProps = {
15 label: string;
16 value: string | React.ReactNode;
17 description?: string;
18 loading?: boolean;
19 className?: string;
20 upgrade?: {
21 href: string;
22 tooltip: string;
23 };
24 };
25
26 /**
27 * @since 4.10.0 use upgrade object instead of inActive.
28 * @since 4.6.0 use new props to handle Fee Recovery widget.
29 * @since 4.4.0
30 */
31 export default function StatWidget({
32 label,
33 value,
34 description,
35 upgrade = null,
36 loading = false,
37 className,
38 }: StatWidgetProps) {
39 return (
40 <div className={classnames(styles.statWidget, className)}>
41 <header>
42 <HeaderText>{label}</HeaderText>
43 </header>
44 <div className={styles.statWidgetAmount}>
45 <div className={classnames(styles.statWidgetDisplay, {[styles.requiresUpgrade]: upgrade})}>
46 {!loading ? (
47 value
48 ) : (
49 <span>
50 <Spinner size="small" />
51 </span>
52 )}
53 {upgrade && (<a className={styles.upgradeLink} href={upgrade?.href} data-addon-tooltip={upgrade?.tooltip}>{__('Upgrade', 'give')}</a>)}
54 </div>
55 </div>
56 {description && (
57 <footer>
58 <div>{description}</div>
59 </footer>
60 )}
61
62 </div>
63 );
64 }
65