import * as React from 'react';
import PostHoverPreview from './PostHoverPreview';
import {
  anchorClassNamesForVisualStyle,
  iconClassNamesForSize,
} from '../utils/hoverPreviewUtils';

interface PostHoverPreviewWrapperProps {
  visualStyle: 'sky-link' | 'description-section-link';
  linkText: string;
  postTitle: string;
  postPath: string;
  postThumbnailPath: string;
  postThumbnailAlt: string;
  postDomainIcon: string;
  creatorName?: string;
  creatorAvatarPath?: string;
}

export const PostHoverPreviewWrapper: React.FC<
  PostHoverPreviewWrapperProps
> = ({
  visualStyle,
  linkText,
  postTitle,
  postPath,
  postThumbnailPath,
  postThumbnailAlt,
  postDomainIcon,
  creatorName,
  creatorAvatarPath,
}) => {
  return (
    <PostHoverPreview
      postTitle={postTitle}
      postThumbnailPath={postThumbnailPath}
      postThumbnailAlt={postThumbnailAlt}
      postDomainIcon={postDomainIcon}
      creatorName={creatorName}
      creatorAvatarPath={creatorAvatarPath}
    >
      <a
        href={postPath}
        className={anchorClassNamesForVisualStyle(visualStyle, true)}
      >
        {visualStyle === 'description-section-link' && (
          <img
            src={postDomainIcon}
            alt={postTitle}
            className={iconClassNamesForSize('small')}
          />
        )}
        {linkText}
      </a>
    </PostHoverPreview>
  );
};

export default PostHoverPreviewWrapper;
