Skip to content

Commit f8adc6e

Browse files
author
ederrengifo
committed
Social: Update social media preview mockups to match current platform UIs
1 parent 758c71c commit f8adc6e

42 files changed

Lines changed: 735 additions & 505 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

projects/js-packages/charts/src/charts/leaderboard-chart/leaderboard-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ const LeaderboardChartInternal: FC< LeaderboardChartProps > = ( {
326326

327327
return (
328328
<Fragment key={ entry.id }>
329-
<Stack direction="column" gap={ labelSpacing }>
329+
<Stack direction="column" gap={ labelSpacing as any }>
330330
<BarWithLabel
331331
entry={ entry }
332332
withComparison={ withComparison }

projects/js-packages/number-formatters/.duel-cache/dual.708b8660.tsbuildinfo

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

projects/js-packages/number-formatters/.duel-cache/primary.708b8660.tsbuildinfo

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

projects/js-packages/social-previews/src/bluesky-preview/post/card/index.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,28 @@ const BlueskyPostCard: React.FC< BlueskyPreviewProps > = ( { title, description,
1313
</div>
1414
) : null }
1515
<div className="bluesky-preview__card-text">
16-
<div className="bluesky-preview__card-site">{ baseDomain( url ) }</div>
1716
<div className="bluesky-preview__card-title">
1817
{ blueskyTitle( title ) || getTitleFromDescription( description ) }
1918
</div>
20-
<div className="bluesky-preview__card-description">{ stripHtmlTags( description ) }</div>
19+
{ description && (
20+
<div className="bluesky-preview__card-description">{ stripHtmlTags( description ) }</div>
21+
) }
22+
</div>
23+
<div className="bluesky-preview__card-domain">
24+
<svg
25+
xmlns="http://www.w3.org/2000/svg"
26+
viewBox="0 0 24 24"
27+
fill="none"
28+
stroke="currentColor"
29+
strokeWidth="2"
30+
width="14"
31+
height="14"
32+
aria-hidden="true"
33+
>
34+
<circle cx="12" cy="12" r="10" />
35+
<path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
36+
</svg>
37+
<span>{ baseDomain( url ) }</span>
2138
</div>
2239
</div>
2340
);

projects/js-packages/social-previews/src/bluesky-preview/post/card/styles.scss

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,71 @@
55
flex-direction: column;
66
margin-top: 1rem;
77

8-
border: solid 1px #d9e1e8;
8+
border: solid 1px #d4dbe2;
99
border-radius: 8px;
1010
overflow: hidden;
1111
color: vars.$bluesky-body-text-color;
1212
}
1313

14-
.bluesky-preview__card-image img {
15-
width: 100%;
16-
object-fit: cover;
14+
.bluesky-preview__card-image {
15+
aspect-ratio: 1.91 / 1;
16+
overflow: hidden;
17+
18+
img {
19+
width: 100%;
20+
height: 100%;
21+
object-fit: cover;
22+
display: block;
23+
}
1724
}
1825

1926
.bluesky-preview__card-text {
20-
border-bottom-width: 1px;
21-
border-left-width: 1px;
22-
border-right-width: 1px;
23-
flex: 1 1 0%;
24-
padding: 8px 14px;
25-
border-color: rgb(212, 219, 226);
26-
border-bottom-right-radius: 8px;
27-
border-bottom-left-radius: 8px;
27+
padding: 14px !important;
2828
}
2929

3030
.bluesky-preview__card-title {
3131
-webkit-box-orient: vertical;
32-
-webkit-line-clamp: 3;
32+
-webkit-line-clamp: 2;
3333
display: -webkit-box;
3434
overflow: hidden;
3535
text-overflow: ellipsis;
3636
color: rgb(11, 15, 20);
3737
font-size: 16px;
38-
font-weight: 700;
39-
letter-spacing: 0.25px;
40-
}
41-
42-
.bluesky-preview__card-site {
43-
font-size: 14px;
44-
overflow: hidden;
45-
text-overflow: ellipsis;
46-
white-space: nowrap;
47-
color: rgb(66, 87, 108);
48-
font-weight: 400;
38+
font-weight: 600;
4939
letter-spacing: 0.25px;
50-
margin-bottom: 2px;
51-
margin-top: 2px;
40+
line-height: 1.3;
5241
}
5342

5443
.bluesky-preview__card-description {
5544
-webkit-box-orient: vertical;
5645
-webkit-line-clamp: 2;
57-
color: rgb(11, 15, 20);
46+
color: rgb(66, 87, 108);
5847
display: -webkit-box;
59-
font-size: 15px;
48+
font-size: 14px;
6049
font-weight: 400;
6150
letter-spacing: 0.25px;
6251
margin-top: 4px;
6352
overflow: hidden;
53+
line-height: 1.4;
54+
}
55+
56+
.bluesky-preview__card-domain {
57+
display: flex;
58+
align-items: center;
59+
gap: 4px;
60+
padding: 10px 14px;
61+
border-top: 1px solid #d4dbe2;
62+
font-size: 14px;
63+
color: rgb(66, 87, 108);
64+
65+
svg {
66+
flex-shrink: 0;
67+
color: rgb(66, 87, 108);
68+
}
69+
70+
span {
71+
overflow: hidden;
72+
text-overflow: ellipsis;
73+
white-space: nowrap;
74+
}
6475
}

projects/js-packages/social-previews/src/bluesky-preview/styles.scss

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@use "./variables" as vars;
22

33
.bluesky-preview__section {
4-
max-width: 100%;
5-
width: vars.$bluesky-preview-width;
4+
width: 100%;
5+
max-width: vars.$bluesky-preview-width;
66
margin-inline: auto;
77
}
88

@@ -25,7 +25,7 @@
2525
font-family: vars.$bluesky-preview-font-family;
2626
/* stylelint-disable-next-line scales/font-sizes */
2727
font-size: 0.9375rem;
28-
line-height: 1.47;
28+
line-height: 20px !important;
2929

3030
:any-link {
3131
color: vars.$bluesky-preview-accent-color;
@@ -38,6 +38,10 @@
3838
margin-top: 8px;
3939
min-height: 64px;
4040
border-radius: 8px;
41+
max-height: 516px;
42+
width: fit-content;
43+
max-width: 100%;
44+
overflow: hidden;
4145

4246
&.as-grid {
4347
display: grid;
@@ -55,8 +59,11 @@
5559

5660
img,
5761
video {
58-
width: 100%;
59-
object-fit: cover;
62+
max-width: 100%;
63+
max-height: 516px;
64+
width: auto;
65+
height: auto;
66+
display: block;
6067
}
6168
}
6269
}

projects/js-packages/social-previews/src/facebook-preview/link-preview.tsx

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,37 @@
11
import { __ } from '@wordpress/i18n';
2-
import { TYPE_ARTICLE, PORTRAIT_MODE } from '../constants';
2+
import { TYPE_ARTICLE } from '../constants';
33
import { baseDomain } from '../helpers';
44
import CustomText from './custom-text';
5-
import { facebookTitle, facebookDescription } from './helpers';
6-
import useImage from './hooks/use-image-hook';
5+
import { facebookTitle } from './helpers';
76
import FacebookPostActions from './post/actions';
87
import FacebookPostHeader from './post/header';
9-
import FacebookPostIcon from './post/icons';
108
import type { FacebookPreviewProps } from './types';
119

1210
import './style.scss';
1311

14-
export type FacebookLinkPreviewProps = FacebookPreviewProps & {
15-
compactDescription?: boolean;
16-
};
12+
export type FacebookLinkPreviewProps = Omit< FacebookPreviewProps, 'imageMode' >;
1713

1814
export const FacebookLinkPreview: React.FC< FacebookLinkPreviewProps > = ( {
1915
url,
2016
title,
21-
description,
2217
image,
2318
user,
2419
customText,
2520
type,
26-
imageMode,
27-
compactDescription,
2821
} ) => {
29-
const [ mode, isLoadingImage, imgProps ] = useImage( { mode: imageMode } );
3022
const isArticle = type === TYPE_ARTICLE;
31-
const portraitMode = ( isArticle && ! image ) || mode === PORTRAIT_MODE;
32-
const modeClass = `is-${ portraitMode ? 'portrait' : 'landscape' }`;
3323

3424
return (
3525
<div className="facebook-preview__post">
3626
<FacebookPostHeader user={ user } />
3727
<div className="facebook-preview__content">
3828
{ customText && <CustomText text={ customText } url={ url } /> }
39-
<div
40-
className={ `facebook-preview__body ${ modeClass } ${
41-
image && isLoadingImage ? 'is-loading' : ''
42-
}` }
43-
>
29+
<div className="facebook-preview__body">
4430
{ ( image || isArticle ) && (
45-
<div
46-
className={ `facebook-preview__image ${ image ? '' : 'is-empty' } ${ modeClass }` }
47-
>
48-
{ /* eslint-disable jsx-a11y/alt-text */ }
49-
{ image && <img src={ image } { ...imgProps } /> }
31+
<div className="facebook-preview__image is-landscape">
32+
{ image && (
33+
<img src={ image } alt={ __( 'Facebook Preview Thumbnail', 'social-previews' ) } />
34+
) }
5035
</div>
5136
) }
5237
<div className="facebook-preview__text">
@@ -55,20 +40,6 @@ export const FacebookLinkPreview: React.FC< FacebookLinkPreviewProps > = ( {
5540
<div className="facebook-preview__title">
5641
{ facebookTitle( title ) || baseDomain( url ) }
5742
</div>
58-
<div
59-
className={ `facebook-preview__description ${
60-
compactDescription ? 'is-compact' : ''
61-
}` }
62-
>
63-
{ description && facebookDescription( description ) }
64-
{ isArticle &&
65-
! description &&
66-
// translators: Default description for a Facebook post
67-
__( 'Visit the post for more.', 'social-previews' ) }
68-
</div>
69-
<div className="facebook-preview__info">
70-
<FacebookPostIcon name="info" />
71-
</div>
7243
</div>
7344
</div>
7445
</div>

projects/js-packages/social-previews/src/facebook-preview/post-preview.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { PORTRAIT_MODE } from '../constants';
21
import CustomText from './custom-text';
3-
import useImage from './hooks/use-image-hook';
42
import FacebookPostActions from './post/actions';
53
import FacebookPostHeader from './post/header';
64
import type { FacebookPreviewProps } from './types';
@@ -12,23 +10,19 @@ export const FacebookPostPreview: React.FC< FacebookPreviewProps > = ( {
1210
user,
1311
customText,
1412
media,
15-
imageMode,
1613
} ) => {
17-
const [ mode ] = useImage( { mode: imageMode } );
18-
const modeClass = `is-${ mode === PORTRAIT_MODE ? 'portrait' : 'landscape' }`;
19-
2014
return (
2115
<div className="facebook-preview__post">
2216
<FacebookPostHeader user={ user } />
2317
<div className="facebook-preview__content">
2418
{ customText && <CustomText text={ customText } url={ url } forceUrlDisplay /> }
2519
<div className="facebook-preview__body">
2620
{ media ? (
27-
<div className={ `facebook-preview__media ${ modeClass }` }>
21+
<div className="facebook-preview__media">
2822
{ media.map( ( mediaItem, index ) => (
2923
<div
3024
key={ `facebook-preview__media-item-${ index }` }
31-
className={ `facebook-preview__media-item ${ modeClass }` }
25+
className="facebook-preview__media-item"
3226
>
3327
{ mediaItem.type.startsWith( 'video/' ) ? (
3428
<video controls>

projects/js-packages/social-previews/src/facebook-preview/style.scss

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
.facebook-preview__post {
44
overflow-y: hidden;
5-
max-width: clamp(#{vars.$facebook-preview-min-width}, 100%, #{vars.$facebook-preview-max-width});
5+
width: 100%;
6+
max-width: vars.$facebook-preview-max-width;
67
margin-inline: auto;
78

89
display: flex;
@@ -81,16 +82,16 @@
8182
/* stylelint-disable-next-line scales/font-sizes */
8283
font-size: 0.8125rem; // 13px
8384
line-height: 1;
84-
text-transform: uppercase;
85+
text-transform: lowercase !important;
8586
}
8687

8788
.facebook-preview__title {
8889
margin: 0.25rem 0 0.125rem;
8990

9091
/* stylelint-disable-next-line scales/font-sizes */
91-
font-size: 0.9444rem; // 17px
92+
font-size: 0.9375rem !important; // 15px
9293
font-weight: 600;
93-
line-height: 1.18;
94+
line-height: 1.33 !important;
9495
}
9596

9697
.facebook-preview__description {
@@ -153,25 +154,19 @@
153154
.facebook-preview__media-item {
154155
display: flex;
155156
justify-content: center;
157+
overflow: hidden;
156158

157159
width: 100%;
160+
// Cap height at 4:5 ratio to match Facebook's mobile feed max
161+
max-height: 850px;
158162

159163
background-color: vars.$facebook-preview-image-background;
160164

161-
&.is-portrait {
162-
163-
img {
164-
width: 500px;
165-
height: 685px;
166-
}
167-
}
168-
169-
&.is-landscape {
170-
171-
img {
172-
width: 100%;
173-
aspect-ratio: 1.78;
174-
}
165+
img,
166+
video {
167+
width: 100%;
168+
height: auto;
169+
object-fit: cover;
175170
}
176171
}
177172

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const Repost: React.FC = () => {
2+
return (
3+
<svg
4+
color="rgb(38, 38, 38)"
5+
fill="currentColor"
6+
height="24"
7+
role="img"
8+
viewBox="0 0 24 24"
9+
width="24"
10+
>
11+
<path d="M19.998 9.497a1 1 0 0 0-1 1v4.228a3.274 3.274 0 0 1-3.27 3.27h-5.313l1.791-1.787a1 1 0 0 0-1.412-1.416L7.29 18.287a1.004 1.004 0 0 0-.294.707v.001c0 .023.012.042.013.065a.923.923 0 0 0 .281.643l3.502 3.504a1 1 0 0 0 1.414-1.414l-1.797-1.798h5.318a5.276 5.276 0 0 0 5.27-5.27v-4.228a1 1 0 0 0-1-1Zm-6.41-3.496-1.795 1.795a1 1 0 1 0 1.414 1.414l3.5-3.5a1.003 1.003 0 0 0 0-1.417l-3.5-3.5a1 1 0 0 0-1.414 1.414l1.794 1.794H8.27A5.277 5.277 0 0 0 3 9.271V13.5a1 1 0 0 0 2 0V9.271a3.275 3.275 0 0 1 3.271-3.27Z" />
12+
</svg>
13+
);
14+
};

0 commit comments

Comments
 (0)