-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Expand file tree
/
Copy pathautomations-help-cards.tsx
More file actions
109 lines (94 loc) · 4.33 KB
/
Copy pathautomations-help-cards.tsx
File metadata and controls
109 lines (94 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React from 'react';
import {LucideIcon, cn} from '@tryghost/shade/utils';
import {isContributorUser} from '@tryghost/admin-x-framework/api/users';
import {useCurrentUser} from '@tryghost/admin-x-framework/api/current-user';
import {useFeaturebase} from '@tryghost/admin-x-framework';
const FORUM_URL = 'https://forum.ghost.org';
const HELP_URL = 'https://ghost.org/help/automations-beta';
interface HelpCardLayoutProps {
title: string;
description: string;
children?: React.ReactNode;
}
const cardClass = 'block w-full rounded-xl border border-border bg-card p-6 text-left transition-all hover:shadow-xs hover:bg-table-row-hover group/card';
const HelpCardBody: React.FC<HelpCardLayoutProps> = ({title, description, children}) => (
<div className='flex items-center gap-6'>
{children}
<div className='flex flex-col gap-0.5 leading-tight'>
<span className='text-base font-semibold'>{title}</span>
<span className='text-sm font-normal text-gray-700'>{description}</span>
</div>
</div>
);
interface HelpLinkCardProps extends HelpCardLayoutProps {
url: string;
className?: string;
}
const HelpLinkCard: React.FC<HelpLinkCardProps> = ({url, className, title, description, children}) => (
<a className={cn(cardClass, className)} href={url} rel='noreferrer' target='_blank'>
<HelpCardBody description={description} title={title}>
{children}
</HelpCardBody>
</a>
);
interface HelpButtonCardProps extends HelpCardLayoutProps {
onClick: () => void;
onMouseEnter?: () => void;
onFocus?: () => void;
className?: string;
}
const HelpButtonCard: React.FC<HelpButtonCardProps> = ({className, title, description, children, onClick, onMouseEnter, onFocus}) => (
<button className={cn(cardClass, 'cursor-pointer appearance-none', className)} type='button' onClick={onClick} onFocus={onFocus} onMouseEnter={onMouseEnter}>
<HelpCardBody description={description} title={title}>
{children}
</HelpCardBody>
</button>
);
const AutomationsIconTile: React.FC = () => (
<div className='flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#8B5CF6]/20 to-[#EC4899]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100'>
<LucideIcon.Zap className='text-[#8B5CF6]' size={20} strokeWidth={1.5} />
</div>
);
const FeedbackIconTile: React.FC = () => (
<div className='flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#10B981]/20 to-[#0EA5E9]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100'>
<LucideIcon.MessageCircle className='text-[#0EA5E9]' size={20} strokeWidth={1.5} />
</div>
);
const FEEDBACK_TITLE = 'Share your feedback';
const FEEDBACK_DESCRIPTION = 'Tell us what’s working and what’s missing — your input shapes what we build next.';
const AutomationsHelpCards: React.FC = () => {
const {data: currentUser} = useCurrentUser();
const {isAvailable: featurebaseAvailable, openFeedbackWidget, preloadFeedbackWidget} = useFeaturebase();
const canUseFeaturebase = featurebaseAvailable && currentUser && !isContributorUser(currentUser);
return (
<div className='mt-auto grid grid-cols-1 gap-6 pt-10 lg:grid-cols-2'>
<HelpLinkCard
description='Learn how to set up automations, customize your emails, and get the most out of the beta.'
title='Automations in Ghost'
url={HELP_URL}
>
<AutomationsIconTile />
</HelpLinkCard>
{canUseFeaturebase ? (
<HelpButtonCard
description={FEEDBACK_DESCRIPTION}
title={FEEDBACK_TITLE}
onClick={() => openFeedbackWidget()}
onFocus={preloadFeedbackWidget}
onMouseEnter={preloadFeedbackWidget}
>
<FeedbackIconTile />
</HelpButtonCard>
) : (
<HelpLinkCard
description={FEEDBACK_DESCRIPTION}
title={FEEDBACK_TITLE}
url={FORUM_URL}
>
<FeedbackIconTile />
</HelpLinkCard>
)}
</div>
);
};
export default AutomationsHelpCards;