@automattic/social-previews 2.0.0 → 2.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/helpers.js +10 -5
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instagram-preview/constants.js +6 -0
- package/dist/cjs/instagram-preview/constants.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/bookmark.js +9 -0
- package/dist/cjs/instagram-preview/icons/bookmark.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/comment.js +9 -0
- package/dist/cjs/instagram-preview/icons/comment.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/default-avatar.js +9 -0
- package/dist/cjs/instagram-preview/icons/default-avatar.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/heart.js +9 -0
- package/dist/cjs/instagram-preview/icons/heart.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/menu.js +9 -0
- package/dist/cjs/instagram-preview/icons/menu.js.map +1 -0
- package/dist/cjs/instagram-preview/icons/share.js +9 -0
- package/dist/cjs/instagram-preview/icons/share.js.map +1 -0
- package/dist/cjs/instagram-preview/index.js +6 -0
- package/dist/cjs/instagram-preview/index.js.map +1 -0
- package/dist/cjs/instagram-preview/post-preview.js +30 -0
- package/dist/cjs/instagram-preview/post-preview.js.map +1 -0
- package/dist/cjs/instagram-preview/previews.js +15 -0
- package/dist/cjs/instagram-preview/previews.js.map +1 -0
- package/dist/cjs/instagram-preview/style.scss +103 -0
- package/dist/cjs/instagram-preview/types.js +3 -0
- package/dist/cjs/instagram-preview/types.js.map +1 -0
- package/dist/esm/helpers.js +10 -5
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instagram-preview/constants.js +3 -0
- package/dist/esm/instagram-preview/constants.js.map +1 -0
- package/dist/esm/instagram-preview/icons/bookmark.js +5 -0
- package/dist/esm/instagram-preview/icons/bookmark.js.map +1 -0
- package/dist/esm/instagram-preview/icons/comment.js +5 -0
- package/dist/esm/instagram-preview/icons/comment.js.map +1 -0
- package/dist/esm/instagram-preview/icons/default-avatar.js +5 -0
- package/dist/esm/instagram-preview/icons/default-avatar.js.map +1 -0
- package/dist/esm/instagram-preview/icons/heart.js +5 -0
- package/dist/esm/instagram-preview/icons/heart.js.map +1 -0
- package/dist/esm/instagram-preview/icons/menu.js +5 -0
- package/dist/esm/instagram-preview/icons/menu.js.map +1 -0
- package/dist/esm/instagram-preview/icons/share.js +5 -0
- package/dist/esm/instagram-preview/icons/share.js.map +1 -0
- package/dist/esm/instagram-preview/index.js +3 -0
- package/dist/esm/instagram-preview/index.js.map +1 -0
- package/dist/esm/instagram-preview/post-preview.js +26 -0
- package/dist/esm/instagram-preview/post-preview.js.map +1 -0
- package/dist/esm/instagram-preview/previews.js +10 -0
- package/dist/esm/instagram-preview/previews.js.map +1 -0
- package/dist/esm/instagram-preview/style.scss +103 -0
- package/dist/esm/instagram-preview/types.js +2 -0
- package/dist/esm/instagram-preview/types.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instagram-preview/constants.d.ts +3 -0
- package/dist/types/instagram-preview/constants.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/bookmark.d.ts +2 -0
- package/dist/types/instagram-preview/icons/bookmark.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/comment.d.ts +2 -0
- package/dist/types/instagram-preview/icons/comment.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/default-avatar.d.ts +2 -0
- package/dist/types/instagram-preview/icons/default-avatar.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/heart.d.ts +2 -0
- package/dist/types/instagram-preview/icons/heart.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/menu.d.ts +2 -0
- package/dist/types/instagram-preview/icons/menu.d.ts.map +1 -0
- package/dist/types/instagram-preview/icons/share.d.ts +2 -0
- package/dist/types/instagram-preview/icons/share.d.ts.map +1 -0
- package/dist/types/instagram-preview/index.d.ts +3 -0
- package/dist/types/instagram-preview/index.d.ts.map +1 -0
- package/dist/types/instagram-preview/post-preview.d.ts +4 -0
- package/dist/types/instagram-preview/post-preview.d.ts.map +1 -0
- package/dist/types/instagram-preview/previews.d.ts +3 -0
- package/dist/types/instagram-preview/previews.d.ts.map +1 -0
- package/dist/types/instagram-preview/types.d.ts +8 -0
- package/dist/types/instagram-preview/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/helpers.ts +13 -8
- package/src/index.ts +1 -0
- package/src/instagram-preview/constants.tsx +2 -0
- package/src/instagram-preview/icons/bookmark.tsx +21 -0
- package/src/instagram-preview/icons/comment.tsx +20 -0
- package/src/instagram-preview/icons/default-avatar.tsx +10 -0
- package/src/instagram-preview/icons/heart.tsx +14 -0
- package/src/instagram-preview/icons/menu.tsx +24 -0
- package/src/instagram-preview/icons/share.tsx +30 -0
- package/src/instagram-preview/index.tsx +2 -0
- package/src/instagram-preview/post-preview.tsx +76 -0
- package/src/instagram-preview/previews.tsx +33 -0
- package/src/instagram-preview/style.scss +103 -0
- package/src/instagram-preview/types.ts +9 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { preparePreviewText } from '../helpers';
|
|
3
|
+
import { FEED_TEXT_MAX_LENGTH, FEED_TEXT_MAX_LINES } from './constants';
|
|
4
|
+
import { Bookmark as BookmarkIcon } from './icons/bookmark';
|
|
5
|
+
import { Comment as CommentIcon } from './icons/comment';
|
|
6
|
+
import { DefaultAvatar } from './icons/default-avatar';
|
|
7
|
+
import { Heart as HeartIcon } from './icons/heart';
|
|
8
|
+
import { Menu as MenuIcon } from './icons/menu';
|
|
9
|
+
import { Share as ShareIcon } from './icons/share';
|
|
10
|
+
import { InstagramPreviewProps } from './types';
|
|
11
|
+
|
|
12
|
+
import './style.scss';
|
|
13
|
+
|
|
14
|
+
export function InstagramPostPreview( {
|
|
15
|
+
image,
|
|
16
|
+
name,
|
|
17
|
+
profileImage,
|
|
18
|
+
caption,
|
|
19
|
+
}: InstagramPreviewProps ) {
|
|
20
|
+
const username = name || 'username';
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="instagram-preview__wrapper">
|
|
24
|
+
<section className="instagram-preview__container">
|
|
25
|
+
<div className="instagram-preview__header">
|
|
26
|
+
<div className="instagram-preview__header--avatar">
|
|
27
|
+
{ profileImage ? <img src={ profileImage } alt="" /> : <DefaultAvatar /> }
|
|
28
|
+
</div>
|
|
29
|
+
<div className="instagram-preview__header--profile">
|
|
30
|
+
<div className="instagram-preview__header--profile-name">{ username }</div>
|
|
31
|
+
<div className="instagram-preview__header--profile-menu">
|
|
32
|
+
<MenuIcon />
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div className="instagram-preview__media">
|
|
37
|
+
<img className="instagram-preview__media--image" src={ image } alt="" />
|
|
38
|
+
</div>
|
|
39
|
+
<div className="instagram-preview__content">
|
|
40
|
+
<section className="instagram-preview__content--actions">
|
|
41
|
+
<div className="instagram-preview__content--actions-primary">
|
|
42
|
+
<HeartIcon />
|
|
43
|
+
<CommentIcon />
|
|
44
|
+
<ShareIcon />
|
|
45
|
+
</div>
|
|
46
|
+
<div className="instagram-preview__content--actions-secondary">
|
|
47
|
+
<BookmarkIcon />
|
|
48
|
+
</div>
|
|
49
|
+
</section>
|
|
50
|
+
<div className="instagram-preview__content--body">
|
|
51
|
+
<div className="instagram-preview__content--name">{ username }</div>
|
|
52
|
+
|
|
53
|
+
{ caption ? (
|
|
54
|
+
<div
|
|
55
|
+
className="instagram-preview__content--text"
|
|
56
|
+
// TODO: Replace `dangerouslySetInnerHTML` with `createInterpolateElement` inside `preparePreviewText`
|
|
57
|
+
// eslint-disable-next-line react/no-danger
|
|
58
|
+
dangerouslySetInnerHTML={ {
|
|
59
|
+
__html: preparePreviewText( caption, {
|
|
60
|
+
platform: 'instagram',
|
|
61
|
+
maxChars: FEED_TEXT_MAX_LENGTH,
|
|
62
|
+
maxLines: FEED_TEXT_MAX_LINES,
|
|
63
|
+
hyperlinkUrls: false,
|
|
64
|
+
} ),
|
|
65
|
+
} }
|
|
66
|
+
/>
|
|
67
|
+
) : null }
|
|
68
|
+
</div>
|
|
69
|
+
<div className="instagram-preview__content--footer">
|
|
70
|
+
<span>{ __( 'View one comment', 'social-previews' ) }</span>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</section>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import SectionHeading from '../shared/section-heading';
|
|
3
|
+
import { InstagramPostPreview } from './post-preview';
|
|
4
|
+
import type { InstagramPreviewsProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const InstagramPreviews: React.FC< InstagramPreviewsProps > = ( {
|
|
7
|
+
headingLevel,
|
|
8
|
+
hideLinkPreview,
|
|
9
|
+
hidePostPreview,
|
|
10
|
+
...props
|
|
11
|
+
} ) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="social-preview instagram-preview">
|
|
14
|
+
{ ! hidePostPreview && (
|
|
15
|
+
<section className="social-preview__section instagram-preview__section">
|
|
16
|
+
<SectionHeading level={ headingLevel }>
|
|
17
|
+
{
|
|
18
|
+
// translators: refers to a social post on Instagram
|
|
19
|
+
__( 'Your post', 'social-previews' )
|
|
20
|
+
}
|
|
21
|
+
</SectionHeading>
|
|
22
|
+
<p className="social-preview__section-desc">
|
|
23
|
+
{ __(
|
|
24
|
+
'This is what your social post will look like on Instagram:',
|
|
25
|
+
'social-previews'
|
|
26
|
+
) }
|
|
27
|
+
</p>
|
|
28
|
+
<InstagramPostPreview { ...props } />
|
|
29
|
+
</section>
|
|
30
|
+
) }
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
.instagram-preview {
|
|
4
|
+
&__wrapper {
|
|
5
|
+
padding: 20px;
|
|
6
|
+
background-color: #fff;
|
|
7
|
+
margin-inline: auto;
|
|
8
|
+
max-width: clamp(200px, 100%, 555px);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// When the preview is in a section of all previews
|
|
12
|
+
&__section &__wrapper {
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__section.social-preview__section {
|
|
17
|
+
width: clamp(200px, 100%, 555px);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__container {
|
|
21
|
+
|
|
22
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__header {
|
|
27
|
+
|
|
28
|
+
padding: 0.5rem 1rem;
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 0.5rem;
|
|
31
|
+
|
|
32
|
+
&--avatar {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
max-width: 32px;
|
|
36
|
+
max-height: 32px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&--avatar img {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
border-radius: 50%;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&--profile {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&--profile-name {
|
|
53
|
+
font-weight: 700;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__media {
|
|
58
|
+
display: flex;
|
|
59
|
+
|
|
60
|
+
&--image {
|
|
61
|
+
width: 100%;
|
|
62
|
+
aspect-ratio: 1;
|
|
63
|
+
object-fit: cover;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&__content {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 0.5rem;
|
|
71
|
+
padding: 0.5rem 1rem;
|
|
72
|
+
|
|
73
|
+
a {
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
color: rgb(0, 55, 107);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--actions {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&--actions-primary {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 1rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&--name {
|
|
90
|
+
font-weight: 600;
|
|
91
|
+
display: inline;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&--text {
|
|
95
|
+
display: inline;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&--footer {
|
|
99
|
+
font-weight: 400;
|
|
100
|
+
color: rgb(115, 115, 115);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SocialPreviewBaseProps, SocialPreviewsBaseProps } from '../types';
|
|
2
|
+
|
|
3
|
+
export type InstagramPreviewProps = Pick< SocialPreviewBaseProps, 'image' > & {
|
|
4
|
+
name: string;
|
|
5
|
+
profileImage: string;
|
|
6
|
+
caption?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type InstagramPreviewsProps = InstagramPreviewProps & SocialPreviewsBaseProps;
|