mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
parent
b10767d038
commit
04ef848b15
2 changed files with 12 additions and 10 deletions
|
@ -5,11 +5,11 @@ import React, {useState} from 'react';
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string,
|
title: string,
|
||||||
favicon?: string | null,
|
favicon?: string | null,
|
||||||
showSubscribes?: number | boolean,
|
featured_image?: string | null,
|
||||||
featured_image?: string | null
|
isGhostSite?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const RecommendationIcon: React.FC<Props> = ({title, favicon, showSubscribes, featured_image}) => {
|
const RecommendationIcon: React.FC<Props> = ({title, favicon, featured_image, isGhostSite}) => {
|
||||||
const [icon, setIcon] = useState(favicon || featured_image || null);
|
const [icon, setIcon] = useState(favicon || featured_image || null);
|
||||||
|
|
||||||
const clearIcon = () => {
|
const clearIcon = () => {
|
||||||
|
@ -20,12 +20,12 @@ const RecommendationIcon: React.FC<Props> = ({title, favicon, showSubscribes, fe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hint = showSubscribes ? 'This is a Ghost site that supports one-click subscribe' : '';
|
const hint = isGhostSite ? 'This is a Ghost site that supports one-click subscribe' : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative h-6 w-6" title={hint}>
|
<div className="relative h-6 w-6" title={hint}>
|
||||||
<img alt={title} className="h-6 w-6 rounded-sm" src={icon} onError={clearIcon} />
|
<img alt={title} className="h-6 w-6 rounded-sm" src={icon} onError={clearIcon} />
|
||||||
{showSubscribes && <img alt='Ghost Logo' className='absolute bottom-[-3px] right-[-3px] h-[14px] w-[14px]' src={GhostLogo} />}
|
{isGhostSite && <img alt='Ghost Logo' className='absolute bottom-[-3px] right-[-3px] h-[14px] w-[14px]' src={GhostLogo} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,8 +31,10 @@ const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recomme
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const showSubscribes = recommendation.one_click_subscribe;
|
const isGhostSite = recommendation.one_click_subscribe;
|
||||||
const count = (showSubscribes ? recommendation.count?.subscribers : recommendation.count?.clicks) || 0;
|
const count = (isGhostSite ? recommendation.count?.subscribers : recommendation.count?.clicks) || 0;
|
||||||
|
const newMembers = count === 1 ? 'new member' : 'new members';
|
||||||
|
const clicks = count === 1 ? 'click' : 'clicks';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
@ -40,7 +42,7 @@ const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recomme
|
||||||
<div className='group flex items-center gap-3 hover:cursor-pointer'>
|
<div className='group flex items-center gap-3 hover:cursor-pointer'>
|
||||||
<div className={`flex grow flex-col`}>
|
<div className={`flex grow flex-col`}>
|
||||||
<div className="mb-0.5 flex items-center gap-3">
|
<div className="mb-0.5 flex items-center gap-3">
|
||||||
<RecommendationIcon showSubscribes={showSubscribes} {...recommendation} />
|
<RecommendationIcon isGhostSite={isGhostSite} {...recommendation} />
|
||||||
<span className='line-clamp-1 font-medium'>{recommendation.title}</span>
|
<span className='line-clamp-1 font-medium'>{recommendation.title}</span>
|
||||||
</div>
|
</div>
|
||||||
{/* <span className='line-clamp-1 text-xs leading-snug text-grey-700'>{recommendation.url || 'No reason added'}</span> */}
|
{/* <span className='line-clamp-1 text-xs leading-snug text-grey-700'>{recommendation.url || 'No reason added'}</span> */}
|
||||||
|
@ -50,11 +52,11 @@ const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recomme
|
||||||
<TableCell className='hidden w-8 align-middle md:!visible md:!table-cell' onClick={showDetails}>
|
<TableCell className='hidden w-8 align-middle md:!visible md:!table-cell' onClick={showDetails}>
|
||||||
{/* {(count === 0) ? (<span className="text-grey-500">-</span>) : (<div className='flex grow flex-col'>
|
{/* {(count === 0) ? (<span className="text-grey-500">-</span>) : (<div className='flex grow flex-col'>
|
||||||
<span>{count}</span>
|
<span>{count}</span>
|
||||||
<span className='whitespace-nowrap text-xs text-grey-700'>{showSubscribes ? ('New members') : ('Clicks')}</span>
|
<span className='whitespace-nowrap text-xs text-grey-700'>{isGhostSite ? newMembers : clicks}</span>
|
||||||
</div>)} */}
|
</div>)} */}
|
||||||
{(count === 0) ? (<span className="text-grey-500">-</span>) : (<div className='-mt-px flex grow items-end gap-1'>
|
{(count === 0) ? (<span className="text-grey-500">-</span>) : (<div className='-mt-px flex grow items-end gap-1'>
|
||||||
<span>{count}</span>
|
<span>{count}</span>
|
||||||
<span className='-mb-px whitespace-nowrap text-sm lowercase text-grey-700'>{showSubscribes ? ('New members') : ('Clicks')}</span>
|
<span className='-mb-px whitespace-nowrap text-sm lowercase text-grey-700'>{isGhostSite ? newMembers : clicks}</span>
|
||||||
</div>)}
|
</div>)}
|
||||||
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
Loading…
Add table
Reference in a new issue