Skip to content

Commit

Permalink
Improve defaults for LinkedIn preview
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed May 30, 2023
1 parent 3a0a3a4 commit 17692a5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DEFAULT_PROPS } from './constants';
import { LinkedInPostPreview } from './post-preview';
import { LinkedInPreviewProps } from './types';

type OptionalProps = Partial< typeof DEFAULT_PROPS >;
type OptionalProps = Partial< Pick< LinkedInPreviewProps, 'name' | 'profileImage' > >;

export type LinkedInLinkPreviewProps = Omit< LinkedInPreviewProps, keyof OptionalProps > &
OptionalProps;

export function LinkedInLinkPreview( props: LinkedInLinkPreviewProps ) {
return (
<LinkedInPostPreview
{ ...DEFAULT_PROPS }
name=""
profileImage=""
{ ...props }
// Override the props that are irrelevant to link preview
description=""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { __, sprintf } from '@wordpress/i18n';
import { baseDomain, preparePreviewText } from '../helpers';
import { FEED_TEXT_MAX_LENGTH, FEED_TEXT_MAX_LINES } from './constants';
import { DefaultAvatar } from './icons/default-avatar';
import { LinkedInPreviewProps } from './types';

import './style.scss';
Expand All @@ -23,11 +24,13 @@ export function LinkedInPostPreview( {
<section className={ `linkedin-preview__container ${ hasMedia ? 'has-media' : '' }` }>
<div className="linkedin-preview__header">
<div className="linkedin-preview__header--avatar">
<img src={ profileImage } alt="" />
{ profileImage ? <img src={ profileImage } alt="" /> : <DefaultAvatar /> }
</div>
<div className="linkedin-preview__header--profile">
<div className="linkedin-preview__header--profile-info">
<div className="linkedin-preview__header--profile-name">{ name }</div>
<div className="linkedin-preview__header--profile-name">
{ name || __( 'Account Name', 'social-previews' ) }
</div>
<span></span>
<div className="linkedin-preview__header--profile-actor">
{
Expand Down
3 changes: 1 addition & 2 deletions packages/social-previews/src/linkedin-preview/previews.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ExternalLink } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import SectionHeading from '../shared/section-heading';
import { DEFAULT_PROPS } from './constants';
import { LinkedInLinkPreview } from './link-preview';
import { LinkedInPostPreview } from './post-preview';
import type { LinkedInPreviewsProps } from './types';
Expand Down Expand Up @@ -46,7 +45,7 @@ export const LinkedInPreviews: React.FC< LinkedInPreviewsProps > = ( {
{ __( 'Learn more about links', 'social-previews' ) }
</ExternalLink>
</p>
<LinkedInLinkPreview { ...props } { ...DEFAULT_PROPS } />
<LinkedInLinkPreview { ...props } name="" profileImage="" />
</section>
) }
</div>
Expand Down
11 changes: 8 additions & 3 deletions packages/social-previews/src/linkedin-preview/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@
margin-bottom: 0.8rem;

&--avatar {
width: 48px;
height: 48px;
border-radius: 50%;
overflow: hidden;
display: flex;
align-items: center;
flex-shrink: 0;
}

&--avatar img {
width: 48px;
height: 48px;
border-radius: 50%;
width: 100%;
object-fit: contain;
}

&--profile {
Expand Down

0 comments on commit 17692a5

Please sign in to comment.