From 2bc8a7eb0bb42f8e8ec4c4802dd602344af55a8e Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 12 Apr 2024 16:41:04 +0530 Subject: [PATCH 1/3] Social Previews | Update Mastodon and Tumblr previews --- .../share/mastodon-share-preview/index.jsx | 2 + packages/social-previews/src/helpers.tsx | 7 ++ .../src/mastodon-preview/constants.ts | 3 + .../src/mastodon-preview/post-preview.tsx | 36 ++++--- .../mastodon-preview/post/actions/index.tsx | 99 +++++++++++-------- .../mastodon-preview/post/actions/styles.scss | 31 ++---- .../src/mastodon-preview/post/card/index.tsx | 22 ++++- .../mastodon-preview/post/card/styles.scss | 50 +++++++--- .../mastodon-preview/post/header/index.tsx | 16 ++- .../src/mastodon-preview/post/icons/index.tsx | 20 ++-- .../mastodon-preview/post/icons/styles.scss | 50 ---------- .../src/mastodon-preview/styles.scss | 31 ++++++ .../src/tumblr-preview/previews.tsx | 4 +- 13 files changed, 211 insertions(+), 160 deletions(-) delete mode 100644 packages/social-previews/src/mastodon-preview/post/icons/styles.scss diff --git a/client/components/share/mastodon-share-preview/index.jsx b/client/components/share/mastodon-share-preview/index.jsx index 48d67ef19e666..2482576b3ebbb 100644 --- a/client/components/share/mastodon-share-preview/index.jsx +++ b/client/components/share/mastodon-share-preview/index.jsx @@ -13,6 +13,7 @@ export class MastodonSharePreview extends PureComponent { articleTitle, articleContent, imageUrl, + media, message, hidePostPreview, } = this.props; @@ -25,6 +26,7 @@ export class MastodonSharePreview extends PureComponent { description={ decodeEntities( articleContent ) } customText={ decodeEntities( message ) } image={ imageUrl } + media={ media } user={ { displayName: externalName, avatarUrl: externalProfilePicture, diff --git a/packages/social-previews/src/helpers.tsx b/packages/social-previews/src/helpers.tsx index d5369e892c914..24ff9e6d1dbd6 100644 --- a/packages/social-previews/src/helpers.tsx +++ b/packages/social-previews/src/helpers.tsx @@ -67,6 +67,13 @@ export const formatTweetDate = new Intl.DateTimeFormat( 'en-US', { day: 'numeric', } ).format; +export const formatMastodonDate = new Intl.DateTimeFormat( 'en-US', { + // Result: "Apr 7, 2024", "Dec 31, 2023" + month: 'short', + day: 'numeric', + year: 'numeric', +} ).format; + export type Platform = 'twitter' | 'facebook' | 'linkedin' | 'instagram' | 'mastodon' | 'nextdoor'; type PreviewTextOptions = { diff --git a/packages/social-previews/src/mastodon-preview/constants.ts b/packages/social-previews/src/mastodon-preview/constants.ts index bb6ffb41ac0df..bbe2311063805 100644 --- a/packages/social-previews/src/mastodon-preview/constants.ts +++ b/packages/social-previews/src/mastodon-preview/constants.ts @@ -1 +1,4 @@ export const DEFAULT_MASTODON_INSTANCE = 'mastodon.social'; + +export const DEFAULT_AVATAR = + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAWlBMVEXZ4ejW3+fQ2eTN1+LL1eHI0+DG0d7U3ebY4Oi7ydm0w9a2xNe5x9i+y9vS2+XDz93BzduwwNWputKjts+rvNOmudGtvtSgtM2OpMKHn72Bmbl8lbacsMuVq8fmVh92AAAKsklEQVR4AezBMQEAAAQAMKB/ZSWc2wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnmT17O5xVx8ItqJAFIZLUcIhqXV1/zudeZnObYCr+G2gwy91pOz7TrRKU0W0+vXLS9n/+uWb+mMIafCadV6Khi5PCemdxWtGCkXVCinGOy4KTVno0HZy8FFmfH1aRIfPmD7UWcPha3YQ+liJLrpx4pceMLFTR2sMFl9zUlFVtPBYw0a19xQOmPkzE/a3DtJiDdNRNRppsdoQttc2C39rHoeWNms9VrOyqSQHtvGB1mt6N/Fak+nK5EhJ7vQ6kkHROsLyRpNZnVsNSO6SRDjs0usVrePCeyyxoe9piV2coOtSA/b69kMOlneb/bdJgsFeXtFFdThC0hdax4fMpsn+PJKOLikiyfultZaTAq9EGRwzaLoc5XCUbekjjecs5qg/642kyMU9QWuRQU/v9RPnsgj6QI8MbEuXIiyyiPRGGDmn91OiI7Kw4iZz/sabSy9nzmsS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KOjUfrE8pNYjDJ2ZOJ9xR2cqfBOeIqZl5kNGJMJQzLBoHjIi8QHJn0jfUZxFlAzIwZQ9DxmRiIJouUSGjn5lIQ4vQuL22Z5fRRi8EZouqTM9340qIWDpsoYfp6YrlOThDF2xG/lBWrrGSCCarur6TMfziFJ2WDN0U6btVYSXI+EMgfherad5rBT6VcGiGPg+BWygOYLCy5p5iYwCoFq+i8LsRKysVxdVCh90z+l6vFFGErmgoFm0wxfb3/slKVeRNHvc7GtT4KC7/3vo5ey74MX4lPW84GThxg82Fq9EVWk3as+p9O2fraTNTwSPEw2n8jgoZLd1zIXUW5Q40YiD2bstIwPyg/E4V3GiPY55I4f2m/a7oUBMwYl2OFUGCWT2A5NQOkRZTlThjNMkb0e+VFemw+EXihN5RKgrU6LxKpy+3h1x6Z0eV5hLeci50JQWlyhO0+BXVgc5GcZLNWgLIEsgFS7x55mYAq8kch2q0uI6y0lGhcucLQ19M9riVVlflLoqrcMsZcY/9+N8qXVZeuswl6g4SYE8BHGKGpmIllOUyERMnGBCLoJTGGQiSk4wOGyJdHqFXETNt9sjF6HGTW2xRODbNchGDHyz0SMXYfh2hFyE6uVMuCmdNPqmaL7dDrmIYuSbTQqZiKKX1yBbUo0b2mEJ28prqQ1RNHKCQUE8nqqakVOMBcQjOVuarpk4VQXxQF3P9wkQj9TwfTqIh6qf6f/gSSCtg3is+nnykEB2EA+3f5L9lQQyVtgQCWQosCESSK2QhZg4wRiwIRLI5LEdEshIDtmIgW9Ue2yHBDJpZCV6vkEfHDZDAulJITfRSxzbMv7BxUoCGbYUhwQyGQexFL5s3HcFtkEC6etOK4hFOY6amq7yWJcEMvbTvmk7o73DWkRHwVSVLgur8JTEv/bgQAAAAAAAyP+1EVRVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUFpJkoc9sa+hgAAAAASUVORK5CYII='; diff --git a/packages/social-previews/src/mastodon-preview/post-preview.tsx b/packages/social-previews/src/mastodon-preview/post-preview.tsx index 3ee5c1d48b49f..a470e72249206 100644 --- a/packages/social-previews/src/mastodon-preview/post-preview.tsx +++ b/packages/social-previews/src/mastodon-preview/post-preview.tsx @@ -1,28 +1,42 @@ -import { __ } from '@wordpress/i18n'; +import classNames from 'classnames'; import MastodonPostActions from './post/actions'; import MastonPostBody from './post/body'; +import MastodonPostCard from './post/card'; import MastodonPostHeader from './post/header'; import type { MastodonPreviewProps } from './types'; import './styles.scss'; export const MastodonPostPreview: React.FC< MastodonPreviewProps > = ( props ) => { - const { user, customImage, image } = props; - - const img = customImage || image; + const { user, media } = props; return (
- { img && ( - { - ) } + { media ? ( +
1 } ) } + > + { media.map( ( mediaItem, index ) => ( +
+ { mediaItem.type.startsWith( 'video/' ) ? ( + // eslint-disable-next-line jsx-a11y/media-has-caption + + ) : ( + { + ) } +
+ ) ) } +
+ ) : null }
+ { ! media ? : null }
); diff --git a/packages/social-previews/src/mastodon-preview/post/actions/index.tsx b/packages/social-previews/src/mastodon-preview/post/actions/index.tsx index 2d0f00aa13679..cb4e56b0c1774 100644 --- a/packages/social-previews/src/mastodon-preview/post/actions/index.tsx +++ b/packages/social-previews/src/mastodon-preview/post/actions/index.tsx @@ -1,49 +1,64 @@ -import { __ } from '@wordpress/i18n'; -import MastodonPostIcon from '../icons'; - import './styles.scss'; const MastodonPostActions: React.FC = () => (
- +
+ +   + { 0 } +
+
+ +
+
+ +
+
+ +
+
+ +
); diff --git a/packages/social-previews/src/mastodon-preview/post/actions/styles.scss b/packages/social-previews/src/mastodon-preview/post/actions/styles.scss index 18ccb7d6a9039..57a6e81539127 100644 --- a/packages/social-previews/src/mastodon-preview/post/actions/styles.scss +++ b/packages/social-previews/src/mastodon-preview/post/actions/styles.scss @@ -2,34 +2,19 @@ .mastodon-preview__post-actions { margin-top: 1rem; + display: flex; + justify-content: space-between; + align-items: center; - ul { + & > div { display: flex; - justify-content: space-between; align-items: center; - - margin: 0; - padding: 0; - - list-style-type: none; - - > li { - display: flex; - align-items: center; - gap: 0.25rem; - - margin: 0; - } + color: #606984; } -} -.mastodon-preview__post-icon-wrapper { - display: flex; - justify-content: center; - align-items: center; - - width: 24px; - height: 24px; + svg { + fill: currentColor; + } } .mastodon-preview__post-icon-text { diff --git a/packages/social-previews/src/mastodon-preview/post/card/index.tsx b/packages/social-previews/src/mastodon-preview/post/card/index.tsx index ab32f364dc004..5944cfc881329 100644 --- a/packages/social-previews/src/mastodon-preview/post/card/index.tsx +++ b/packages/social-previews/src/mastodon-preview/post/card/index.tsx @@ -1,5 +1,6 @@ import { __ } from '@wordpress/i18n'; -import { baseDomain, getTitleFromDescription } from '../../../helpers'; +import classNames from 'classnames'; +import { baseDomain, getTitleFromDescription, stripHtmlTags } from '../../../helpers'; import { mastodonTitle } from '../../helpers'; import { MastodonPreviewProps } from '../../types'; @@ -14,20 +15,33 @@ const MastodonPostCard: React.FC< MastodonPreviewProps > = ( { customImage, } ) => { return ( -
+
- { ( image || customImage ) && ( + { image || customImage ? ( { + ) : ( +
+ +
) }
+ { siteName || baseDomain( url ) } { mastodonTitle( title ) || getTitleFromDescription( description ) } - { siteName || baseDomain( url ) } + { stripHtmlTags( description ) }
); diff --git a/packages/social-previews/src/mastodon-preview/post/card/styles.scss b/packages/social-previews/src/mastodon-preview/post/card/styles.scss index 3196c3bc8ad3f..d019ced28ceed 100644 --- a/packages/social-previews/src/mastodon-preview/post/card/styles.scss +++ b/packages/social-previews/src/mastodon-preview/post/card/styles.scss @@ -6,18 +6,24 @@ margin-top: 1rem; margin-bottom: 1rem; - border: solid 1px #ccd7e0; - border-radius: 4px; + border: solid 1px #d9e1e8; + /* stylelint-disable-next-line scales/radii */ + border-radius: 8px; + overflow: hidden; color: $mastodon-body-text-color; + + &.has-image { + flex-direction: column; + } + + &.has-image &-img { + width: 100%; + } } .mastodon-preview__card-img { - width: 60px; min-height: 60px; - border-start-start-radius: inherit; - border-end-start-radius: inherit; - img { display: block; @@ -28,25 +34,43 @@ border-start-start-radius: inherit; border-end-start-radius: inherit; } + + &--fallback { + aspect-ratio: 1; + background: #c0cdd9; + position: relative; + width: 120px; + display: flex; + align-items: center; + justify-content: center; + } } .mastodon-preview__card-text { display: flex; flex-direction: column; - gap: 0.25rem; - - padding: 0.625rem 0.5rem; + gap: 0.5rem; + padding: 1rem; + overflow: hidden; } .mastodon-preview__card-title { color: #282c37; - font-size: 0.875rem; + /* stylelint-disable-next-line scales/font-sizes */ + font-size: 1.187rem; font-weight: 700; - line-height: 1.3; + line-height: 1.4; } .mastodon-preview__card-site { - /* stylelint-disable-next-line scales/font-sizes */ - font-size: 0.8125rem; + font-size: 0.875rem; + display: block; +} + +.mastodon-preview__card-description { + font-size: 0.875rem; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } diff --git a/packages/social-previews/src/mastodon-preview/post/header/index.tsx b/packages/social-previews/src/mastodon-preview/post/header/index.tsx index 6205e28a28a40..b2e9c8d5a45e8 100644 --- a/packages/social-previews/src/mastodon-preview/post/header/index.tsx +++ b/packages/social-previews/src/mastodon-preview/post/header/index.tsx @@ -1,6 +1,7 @@ import { __ } from '@wordpress/i18n'; -import { DEFAULT_MASTODON_INSTANCE } from '../../constants'; -import MastodonPostIcon from '../icons'; +import { formatMastodonDate } from '../../../helpers'; +import { DEFAULT_AVATAR, DEFAULT_MASTODON_INSTANCE } from '../../constants'; +import { GlobeIcon } from '../icons'; import type { MastodonPreviewProps } from '../../types'; import './styles.scss'; @@ -13,7 +14,7 @@ const MastodonPostHeader: React.FC< Props > = ( { user } ) => { return (
- { avatarUrl && } +
{ displayName || @@ -21,16 +22,13 @@ const MastodonPostHeader: React.FC< Props > = ( { user } ) => { __( 'anonymous-user', 'social-previews' ) }
- { address?.replace( `@${ DEFAULT_MASTODON_INSTANCE }`, '' ) } + { address?.replace( `@${ DEFAULT_MASTODON_INSTANCE }`, '' ) || '@username' }
- - { - // translators: time elapsed since post was published (1 hour) - __( '1h', 'social-previews' ) - } + + { formatMastodonDate( new Date() ) }
); diff --git a/packages/social-previews/src/mastodon-preview/post/icons/index.tsx b/packages/social-previews/src/mastodon-preview/post/icons/index.tsx index 40e2d0b8c9860..cf897d30392b2 100644 --- a/packages/social-previews/src/mastodon-preview/post/icons/index.tsx +++ b/packages/social-previews/src/mastodon-preview/post/icons/index.tsx @@ -1,7 +1,13 @@ -import './styles.scss'; - -const MastodonPostIcon: React.FC< { name: string } > = ( { name } ) => ( - -); - -export default MastodonPostIcon; +export function GlobeIcon() { + return ( + + + + ); +} diff --git a/packages/social-previews/src/mastodon-preview/post/icons/styles.scss b/packages/social-previews/src/mastodon-preview/post/icons/styles.scss deleted file mode 100644 index 1d475cc7faf41..0000000000000 --- a/packages/social-previews/src/mastodon-preview/post/icons/styles.scss +++ /dev/null @@ -1,50 +0,0 @@ -.mastodon-preview__post-icon { - display: inline-block; - - /* stylelint-disable-next-line function-url-quotes */ - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAAAiCAYAAAAETqbJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA6NSURBVHgB7Z0JfEzXHsd/CLJHViGJICIIIrbQIJYQUftaS2iltbyS0pZHW7roR9u0T6ulrUfRhKK1hQqhanu21F57kJBVhIjsq3f+Z3pjJrPdydxkEvH9fOaTmTtn7sx1z//896PWUwZEkJ2Th/+dvIBW7q5wbdIIhiQnNw8/he2CbzcvdPTywAtkXL0ei6iDJ9m9yoW01IKDvTVGD+sHG2vL0qPbdv2JPw5HIz+/sPRYnTq10d7THTOCR6KukRE/dvFyDH7+5Xc8zsh6dsZagFMjB8wMHoVGjnb82MNHGVi5eivuxidDflpamJtiwpgA+HRuCzHEJyThRkwsUlJSkZ2di3r16sLKygLNmzVBq5ZuMDaur/UcRmK+KDMrB199G474xFTY2Voh9JMQGJKIPUdw/tINdvF32e8JQhNnR378u1W/cqHRh1z2eeEctjYN2LkbYvzoAFQEdO+3RRxkN8yJCXgr6EN8wn0sW7kRJSWi1jmduROXiJjb8ezez2aT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7x0LT8OT005JEc7G0weng/SAn5JiOH9EFNw6CCQb3KU1n0x03P+HxVhGx0evj5duSbhVH/hC44NbbnORXafn/7rkO8JN+4Guw19bxQ62l1C1pXE6hpv4hFdTRl8nWBtKu5Hv9NwAt04//tjEWOWGCBmwAAAABJRU5ErkJggg=="); - background-repeat: no-repeat; - background-size: 99px 17px; -} - -.mastodon-preview__post-icon-reply { - width: 19px; - height: 17px; - - background-position: 0 0; -} - -.mastodon-preview__post-icon-boost { - width: 21px; - height: 13px; - - background-position: -19px 0; -} - -.mastodon-preview__post-icon-like { - width: 17px; - height: 17px; - - background-position: -40px 0; -} - -.mastodon-preview__post-icon-bookmark { - width: 14px; - height: 16px; - - background-position: -57px 0; -} - -.mastodon-preview__post-icon-more { - width: 15px; - height: 4px; - - background-position: -71px 0; -} - -.mastodon-preview__post-icon-globe { - width: 13px; - height: 14px; - - background-position: -86px 0; -} diff --git a/packages/social-previews/src/mastodon-preview/styles.scss b/packages/social-previews/src/mastodon-preview/styles.scss index c1bbcf3fac326..68132865d073b 100644 --- a/packages/social-previews/src/mastodon-preview/styles.scss +++ b/packages/social-previews/src/mastodon-preview/styles.scss @@ -40,3 +40,34 @@ aspect-ratio: 16 / 9; object-fit: cover; } + +.mastodon-preview__media { + + margin-top: 8px; + min-height: 64px; + /* stylelint-disable-next-line scales/radii */ + border-radius: 8px; + + &.as-grid { + display: grid; + gap: 2px; + grid-template-columns: 50% 50%; + width: 100%; + overflow: hidden; + } + + &-item { + display: flex; + border: 0; + /* stylelint-disable-next-line scales/radii */ + border-radius: 8px; + overflow: hidden; + + img, + video { + width: 100%; + object-fit: cover; + } + } + +} diff --git a/packages/social-previews/src/tumblr-preview/previews.tsx b/packages/social-previews/src/tumblr-preview/previews.tsx index 72444f907b722..76fc48b7913e7 100644 --- a/packages/social-previews/src/tumblr-preview/previews.tsx +++ b/packages/social-previews/src/tumblr-preview/previews.tsx @@ -14,6 +14,8 @@ export const TumblrPreviews: React.FC< TumblrPreviewsProps > = ( { hidePostPreview, ...props } ) => { + const hasMedia = !! props.media?.length; + return (
{ ! hidePostPreview && ( @@ -27,7 +29,7 @@ export const TumblrPreviews: React.FC< TumblrPreviewsProps > = ( {

{ __( 'This is what your social post will look like on Tumblr:', 'social-previews' ) }

- + { hasMedia ? : } ) } { ! hideLinkPreview && ( From 7ac053d3e534a41698313cca7490b7dfe86c0544 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 12 Apr 2024 16:49:55 +0530 Subject: [PATCH 2/3] Update post-preview.tsx --- .../social-previews/src/mastodon-preview/post-preview.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/social-previews/src/mastodon-preview/post-preview.tsx b/packages/social-previews/src/mastodon-preview/post-preview.tsx index a470e72249206..2767adda14c8d 100644 --- a/packages/social-previews/src/mastodon-preview/post-preview.tsx +++ b/packages/social-previews/src/mastodon-preview/post-preview.tsx @@ -14,7 +14,7 @@ export const MastodonPostPreview: React.FC< MastodonPreviewProps > = ( props ) =
- { media ? ( + { media?.length ? (
1 } ) } > @@ -36,7 +36,7 @@ export const MastodonPostPreview: React.FC< MastodonPreviewProps > = ( props ) =
) : null }
- { ! media ? : null } + { ! media?.length ? : null }
); From 35901ab8ea00d0f9d1ef38963aa80dd6aa8e10b9 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Fri, 12 Apr 2024 17:23:09 +0530 Subject: [PATCH 3/3] Update version --- packages/social-previews/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/social-previews/package.json b/packages/social-previews/package.json index 1236cbaa27a38..0f674e0b906f3 100644 --- a/packages/social-previews/package.json +++ b/packages/social-previews/package.json @@ -1,6 +1,6 @@ { "name": "@automattic/social-previews", - "version": "2.0.1-beta.12", + "version": "2.0.1-beta.13", "description": "A suite of components to generate previews for a post for both social and search engines.", "main": "dist/cjs/index.js", "module": "dist/esm/index.js",