@automattic/social-previews 2.0.0-beta.6 → 2.0.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/cjs/facebook-preview/previews.js +4 -4
  3. package/dist/cjs/facebook-preview/previews.js.map +1 -1
  4. package/dist/cjs/linkedin-preview/previews.js +4 -4
  5. package/dist/cjs/linkedin-preview/previews.js.map +1 -1
  6. package/dist/cjs/tumblr-preview/previews.js +4 -4
  7. package/dist/cjs/tumblr-preview/previews.js.map +1 -1
  8. package/dist/cjs/twitter-preview/previews.js +8 -5
  9. package/dist/cjs/twitter-preview/previews.js.map +1 -1
  10. package/dist/esm/facebook-preview/previews.js +4 -4
  11. package/dist/esm/facebook-preview/previews.js.map +1 -1
  12. package/dist/esm/linkedin-preview/previews.js +4 -4
  13. package/dist/esm/linkedin-preview/previews.js.map +1 -1
  14. package/dist/esm/tumblr-preview/previews.js +4 -4
  15. package/dist/esm/tumblr-preview/previews.js.map +1 -1
  16. package/dist/esm/twitter-preview/previews.js +8 -5
  17. package/dist/esm/twitter-preview/previews.js.map +1 -1
  18. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/types/facebook-preview/previews.d.ts.map +1 -1
  21. package/dist/types/linkedin-preview/previews.d.ts.map +1 -1
  22. package/dist/types/tumblr-preview/previews.d.ts.map +1 -1
  23. package/dist/types/twitter-preview/previews.d.ts.map +1 -1
  24. package/dist/types/types.d.ts +11 -0
  25. package/dist/types/types.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/facebook-preview/previews.tsx +44 -35
  28. package/src/linkedin-preview/previews.tsx +37 -31
  29. package/src/tumblr-preview/previews.tsx +41 -32
  30. package/src/twitter-preview/previews.tsx +53 -41
  31. package/src/types.ts +13 -0
@@ -5,49 +5,61 @@ import { TwitterLinkPreview } from './link-preview';
5
5
  import { TwitterPostPreview } from './post-preview';
6
6
  import type { TwitterPreviewsProps } from './types';
7
7
 
8
- export const TwitterPreviews: React.FC< TwitterPreviewsProps > = ( { tweets, headingLevel } ) => {
8
+ export const TwitterPreviews: React.FC< TwitterPreviewsProps > = ( {
9
+ headingLevel,
10
+ hideLinkPreview,
11
+ hidePostPreview,
12
+ tweets,
13
+ } ) => {
14
+ if ( ! tweets?.length ) {
15
+ return null;
16
+ }
9
17
  return (
10
18
  <div className="social-preview twitter-preview">
11
- <section className="social-preview__section twitter-preview__section">
12
- <SectionHeading level={ headingLevel }>
13
- {
14
- // translators: refers to a social post on Twitter
15
- __( 'Your post', 'social-previews' )
16
- }
17
- </SectionHeading>
18
- <p className="social-preview__section-desc">
19
- { __( 'This is what your social post will look like on Twitter:', 'social-previews' ) }
20
- </p>
21
- { tweets?.map( ( tweet, index ) => {
22
- const isLast = index + 1 === tweets.length;
23
- return (
24
- <TwitterPostPreview
25
- key={ `twitter-preview__tweet-${ index }` }
26
- { ...tweet }
27
- showThreadConnector={ ! isLast }
28
- />
29
- );
30
- } ) }
31
- </section>
32
- <section className="social-preview__section twitter-preview__section">
33
- <SectionHeading level={ headingLevel }>
34
- {
35
- // translators: refers to a link to a Twitter post
36
- __( 'Link preview', 'social-previews' )
37
- }
38
- </SectionHeading>
39
- <p className="social-preview__section-desc">
40
- { __(
41
- 'This is what it will look like when someone shares the link to your WordPress post on Twitter.',
42
- 'social-previews'
43
- ) }
44
- &nbsp;
45
- <ExternalLink href="https://jetpack.com/support/jetpack-social-image-generator">
46
- { __( 'Learn more about links', 'social-previews' ) }
47
- </ExternalLink>
48
- </p>
49
- <TwitterLinkPreview { ...tweets[ 0 ] } />
50
- </section>
19
+ { ! hidePostPreview && (
20
+ <section className="social-preview__section twitter-preview__section">
21
+ <SectionHeading level={ headingLevel }>
22
+ {
23
+ // translators: refers to a social post on Twitter
24
+ __( 'Your post', 'social-previews' )
25
+ }
26
+ </SectionHeading>
27
+ <p className="social-preview__section-desc">
28
+ { __( 'This is what your social post will look like on Twitter:', 'social-previews' ) }
29
+ </p>
30
+ { tweets.map( ( tweet, index ) => {
31
+ const isLast = index + 1 === tweets.length;
32
+ return (
33
+ <TwitterPostPreview
34
+ key={ `twitter-preview__tweet-${ index }` }
35
+ { ...tweet }
36
+ showThreadConnector={ ! isLast }
37
+ />
38
+ );
39
+ } ) }
40
+ </section>
41
+ ) }
42
+ { ! hideLinkPreview && (
43
+ <section className="social-preview__section twitter-preview__section">
44
+ <SectionHeading level={ headingLevel }>
45
+ {
46
+ // translators: refers to a link to a Twitter post
47
+ __( 'Link preview', 'social-previews' )
48
+ }
49
+ </SectionHeading>
50
+ <p className="social-preview__section-desc">
51
+ { __(
52
+ 'This is what it will look like when someone shares the link to your WordPress post on Twitter.',
53
+ 'social-previews'
54
+ ) }
55
+ &nbsp;
56
+ <ExternalLink href="https://jetpack.com/support/jetpack-social-image-generator">
57
+ { __( 'Learn more about links', 'social-previews' ) }
58
+ </ExternalLink>
59
+ </p>
60
+ <TwitterLinkPreview { ...tweets[ 0 ] } />
61
+ </section>
62
+ ) }
51
63
  </div>
52
64
  );
53
65
  };
package/src/types.ts CHANGED
@@ -23,7 +23,20 @@ export interface SocialPreviewBaseProps {
23
23
  }
24
24
 
25
25
  export interface SocialPreviewsBaseProps {
26
+ /**
27
+ * The heading level to use for the preview section title
28
+ */
26
29
  headingLevel?: SectionHeadingProps[ 'level' ];
30
+
31
+ /**
32
+ * Whether to hide the "Your post" section
33
+ */
34
+ hidePostPreview?: boolean;
35
+
36
+ /**
37
+ * Whether to hide the "Link preview" section
38
+ */
39
+ hideLinkPreview?: boolean;
27
40
  }
28
41
 
29
42
  export type MediaItem = {