@automattic/social-previews 2.0.1-beta.8 → 2.0.1

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 (231) hide show
  1. package/dist/cjs/facebook-preview/custom-text.js.map +1 -1
  2. package/dist/cjs/facebook-preview/hooks/use-image-hook.js.map +1 -1
  3. package/dist/cjs/facebook-preview/post/header/index.js.map +1 -1
  4. package/dist/cjs/helpers.js +22 -1
  5. package/dist/cjs/helpers.js.map +1 -1
  6. package/dist/cjs/index.js +1 -0
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/instagram-preview/style.scss +6 -1
  9. package/dist/cjs/linkedin-preview/link-preview.js +2 -1
  10. package/dist/cjs/linkedin-preview/link-preview.js.map +1 -1
  11. package/dist/cjs/linkedin-preview/post-preview.js +1 -1
  12. package/dist/cjs/linkedin-preview/post-preview.js.map +1 -1
  13. package/dist/cjs/mastodon-preview/constants.js +2 -1
  14. package/dist/cjs/mastodon-preview/constants.js.map +1 -1
  15. package/dist/cjs/mastodon-preview/post/actions/index.js +1 -31
  16. package/dist/cjs/mastodon-preview/post/actions/index.js.map +1 -1
  17. package/dist/cjs/mastodon-preview/post/actions/styles.scss +8 -23
  18. package/dist/cjs/mastodon-preview/post/body/index.js +8 -3
  19. package/dist/cjs/mastodon-preview/post/body/index.js.map +1 -1
  20. package/dist/cjs/mastodon-preview/post/card/index.js +4 -2
  21. package/dist/cjs/mastodon-preview/post/card/index.js.map +1 -1
  22. package/dist/cjs/mastodon-preview/post/card/styles.scss +37 -13
  23. package/dist/cjs/mastodon-preview/post/header/index.js +4 -6
  24. package/dist/cjs/mastodon-preview/post/header/index.js.map +1 -1
  25. package/dist/cjs/mastodon-preview/post/icons/index.js +5 -3
  26. package/dist/cjs/mastodon-preview/post/icons/index.js.map +1 -1
  27. package/dist/cjs/mastodon-preview/post-preview.js +6 -4
  28. package/dist/cjs/mastodon-preview/post-preview.js.map +1 -1
  29. package/dist/cjs/mastodon-preview/styles.scss +31 -0
  30. package/dist/cjs/nextdoor-preview/constants.js +6 -0
  31. package/dist/cjs/nextdoor-preview/constants.js.map +1 -0
  32. package/dist/cjs/nextdoor-preview/footer-actions.js +13 -0
  33. package/dist/cjs/nextdoor-preview/footer-actions.js.map +1 -0
  34. package/dist/cjs/nextdoor-preview/icons/chevron-icon.js +9 -0
  35. package/dist/cjs/nextdoor-preview/icons/chevron-icon.js.map +1 -0
  36. package/dist/cjs/nextdoor-preview/icons/comment-icon.js +9 -0
  37. package/dist/cjs/nextdoor-preview/icons/comment-icon.js.map +1 -0
  38. package/dist/cjs/nextdoor-preview/icons/default-avatar.js +9 -0
  39. package/dist/cjs/nextdoor-preview/icons/default-avatar.js.map +1 -0
  40. package/dist/cjs/nextdoor-preview/icons/default-image.js +9 -0
  41. package/dist/cjs/nextdoor-preview/icons/default-image.js.map +1 -0
  42. package/dist/cjs/nextdoor-preview/icons/globe-icon.js +9 -0
  43. package/dist/cjs/nextdoor-preview/icons/globe-icon.js.map +1 -0
  44. package/dist/cjs/nextdoor-preview/icons/like-icon.js +9 -0
  45. package/dist/cjs/nextdoor-preview/icons/like-icon.js.map +1 -0
  46. package/dist/cjs/nextdoor-preview/icons/share-icon.js +9 -0
  47. package/dist/cjs/nextdoor-preview/icons/share-icon.js.map +1 -0
  48. package/dist/cjs/nextdoor-preview/index.js +7 -0
  49. package/dist/cjs/nextdoor-preview/index.js.map +1 -0
  50. package/dist/cjs/nextdoor-preview/link-preview.js +13 -0
  51. package/dist/cjs/nextdoor-preview/link-preview.js.map +1 -0
  52. package/dist/cjs/nextdoor-preview/post-preview.js +31 -0
  53. package/dist/cjs/nextdoor-preview/post-preview.js.map +1 -0
  54. package/dist/cjs/nextdoor-preview/previews.js +19 -0
  55. package/dist/cjs/nextdoor-preview/previews.js.map +1 -0
  56. package/dist/cjs/nextdoor-preview/style.scss +211 -0
  57. package/dist/cjs/nextdoor-preview/types.js +3 -0
  58. package/dist/cjs/nextdoor-preview/types.js.map +1 -0
  59. package/dist/cjs/tumblr-preview/post/icons/index.js.map +1 -1
  60. package/dist/cjs/tumblr-preview/previews.js +2 -1
  61. package/dist/cjs/tumblr-preview/previews.js.map +1 -1
  62. package/dist/cjs/tumblr-preview/variables.scss +0 -1
  63. package/dist/cjs/twitter-preview/card.js +2 -2
  64. package/dist/cjs/twitter-preview/card.js.map +1 -1
  65. package/dist/cjs/twitter-preview/media.js +2 -2
  66. package/dist/cjs/twitter-preview/media.js.map +1 -1
  67. package/dist/cjs/twitter-preview/post-preview.js +1 -1
  68. package/dist/cjs/twitter-preview/post-preview.js.map +1 -1
  69. package/dist/cjs/twitter-preview/previews.js +2 -2
  70. package/dist/cjs/twitter-preview/previews.js.map +1 -1
  71. package/dist/cjs/twitter-preview/quote-tweet.js.map +1 -1
  72. package/dist/cjs/twitter-preview/text.js.map +1 -1
  73. package/dist/esm/facebook-preview/custom-text.js.map +1 -1
  74. package/dist/esm/facebook-preview/hooks/use-image-hook.js.map +1 -1
  75. package/dist/esm/facebook-preview/post/header/index.js.map +1 -1
  76. package/dist/esm/helpers.js +20 -0
  77. package/dist/esm/helpers.js.map +1 -1
  78. package/dist/esm/index.js +1 -0
  79. package/dist/esm/index.js.map +1 -1
  80. package/dist/esm/instagram-preview/style.scss +6 -1
  81. package/dist/esm/linkedin-preview/link-preview.js +2 -1
  82. package/dist/esm/linkedin-preview/link-preview.js.map +1 -1
  83. package/dist/esm/linkedin-preview/post-preview.js +2 -2
  84. package/dist/esm/linkedin-preview/post-preview.js.map +1 -1
  85. package/dist/esm/mastodon-preview/constants.js +1 -0
  86. package/dist/esm/mastodon-preview/constants.js.map +1 -1
  87. package/dist/esm/mastodon-preview/post/actions/index.js +1 -30
  88. package/dist/esm/mastodon-preview/post/actions/index.js.map +1 -1
  89. package/dist/esm/mastodon-preview/post/actions/styles.scss +8 -23
  90. package/dist/esm/mastodon-preview/post/body/index.js +8 -3
  91. package/dist/esm/mastodon-preview/post/body/index.js.map +1 -1
  92. package/dist/esm/mastodon-preview/post/card/index.js +4 -3
  93. package/dist/esm/mastodon-preview/post/card/index.js.map +1 -1
  94. package/dist/esm/mastodon-preview/post/card/styles.scss +37 -13
  95. package/dist/esm/mastodon-preview/post/header/index.js +5 -6
  96. package/dist/esm/mastodon-preview/post/header/index.js.map +1 -1
  97. package/dist/esm/mastodon-preview/post/icons/index.js +3 -3
  98. package/dist/esm/mastodon-preview/post/icons/index.js.map +1 -1
  99. package/dist/esm/mastodon-preview/post-preview.js +6 -4
  100. package/dist/esm/mastodon-preview/post-preview.js.map +1 -1
  101. package/dist/esm/mastodon-preview/styles.scss +31 -0
  102. package/dist/esm/nextdoor-preview/constants.js +3 -0
  103. package/dist/esm/nextdoor-preview/constants.js.map +1 -0
  104. package/dist/esm/nextdoor-preview/footer-actions.js +9 -0
  105. package/dist/esm/nextdoor-preview/footer-actions.js.map +1 -0
  106. package/dist/esm/nextdoor-preview/icons/chevron-icon.js +5 -0
  107. package/dist/esm/nextdoor-preview/icons/chevron-icon.js.map +1 -0
  108. package/dist/esm/nextdoor-preview/icons/comment-icon.js +5 -0
  109. package/dist/esm/nextdoor-preview/icons/comment-icon.js.map +1 -0
  110. package/dist/esm/nextdoor-preview/icons/default-avatar.js +5 -0
  111. package/dist/esm/nextdoor-preview/icons/default-avatar.js.map +1 -0
  112. package/dist/esm/nextdoor-preview/icons/default-image.js +5 -0
  113. package/dist/esm/nextdoor-preview/icons/default-image.js.map +1 -0
  114. package/dist/esm/nextdoor-preview/icons/globe-icon.js +5 -0
  115. package/dist/esm/nextdoor-preview/icons/globe-icon.js.map +1 -0
  116. package/dist/esm/nextdoor-preview/icons/like-icon.js +5 -0
  117. package/dist/esm/nextdoor-preview/icons/like-icon.js.map +1 -0
  118. package/dist/esm/nextdoor-preview/icons/share-icon.js +5 -0
  119. package/dist/esm/nextdoor-preview/icons/share-icon.js.map +1 -0
  120. package/dist/esm/nextdoor-preview/index.js +4 -0
  121. package/dist/esm/nextdoor-preview/index.js.map +1 -0
  122. package/dist/esm/nextdoor-preview/link-preview.js +9 -0
  123. package/dist/esm/nextdoor-preview/link-preview.js.map +1 -0
  124. package/dist/esm/nextdoor-preview/post-preview.js +26 -0
  125. package/dist/esm/nextdoor-preview/post-preview.js.map +1 -0
  126. package/dist/esm/nextdoor-preview/previews.js +14 -0
  127. package/dist/esm/nextdoor-preview/previews.js.map +1 -0
  128. package/dist/esm/nextdoor-preview/style.scss +211 -0
  129. package/dist/esm/nextdoor-preview/types.js +2 -0
  130. package/dist/esm/nextdoor-preview/types.js.map +1 -0
  131. package/dist/esm/tumblr-preview/post/icons/index.js.map +1 -1
  132. package/dist/esm/tumblr-preview/previews.js +2 -1
  133. package/dist/esm/tumblr-preview/previews.js.map +1 -1
  134. package/dist/esm/tumblr-preview/variables.scss +0 -1
  135. package/dist/esm/twitter-preview/card.js +2 -2
  136. package/dist/esm/twitter-preview/card.js.map +1 -1
  137. package/dist/esm/twitter-preview/media.js +2 -2
  138. package/dist/esm/twitter-preview/media.js.map +1 -1
  139. package/dist/esm/twitter-preview/post-preview.js +1 -1
  140. package/dist/esm/twitter-preview/post-preview.js.map +1 -1
  141. package/dist/esm/twitter-preview/previews.js +2 -2
  142. package/dist/esm/twitter-preview/previews.js.map +1 -1
  143. package/dist/esm/twitter-preview/quote-tweet.js.map +1 -1
  144. package/dist/esm/twitter-preview/text.js.map +1 -1
  145. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  146. package/dist/tsconfig.tsbuildinfo +1 -1
  147. package/dist/types/helpers.d.ts +11 -3
  148. package/dist/types/helpers.d.ts.map +1 -1
  149. package/dist/types/index.d.ts +1 -0
  150. package/dist/types/index.d.ts.map +1 -1
  151. package/dist/types/linkedin-preview/link-preview.d.ts.map +1 -1
  152. package/dist/types/linkedin-preview/post-preview.d.ts.map +1 -1
  153. package/dist/types/mastodon-preview/constants.d.ts +1 -0
  154. package/dist/types/mastodon-preview/constants.d.ts.map +1 -1
  155. package/dist/types/mastodon-preview/post/actions/index.d.ts.map +1 -1
  156. package/dist/types/mastodon-preview/post/body/index.d.ts.map +1 -1
  157. package/dist/types/mastodon-preview/post/card/index.d.ts.map +1 -1
  158. package/dist/types/mastodon-preview/post/header/index.d.ts.map +1 -1
  159. package/dist/types/mastodon-preview/post/icons/index.d.ts +1 -6
  160. package/dist/types/mastodon-preview/post/icons/index.d.ts.map +1 -1
  161. package/dist/types/mastodon-preview/post-preview.d.ts.map +1 -1
  162. package/dist/types/nextdoor-preview/constants.d.ts +3 -0
  163. package/dist/types/nextdoor-preview/constants.d.ts.map +1 -0
  164. package/dist/types/nextdoor-preview/footer-actions.d.ts +2 -0
  165. package/dist/types/nextdoor-preview/footer-actions.d.ts.map +1 -0
  166. package/dist/types/nextdoor-preview/icons/chevron-icon.d.ts +2 -0
  167. package/dist/types/nextdoor-preview/icons/chevron-icon.d.ts.map +1 -0
  168. package/dist/types/nextdoor-preview/icons/comment-icon.d.ts +2 -0
  169. package/dist/types/nextdoor-preview/icons/comment-icon.d.ts.map +1 -0
  170. package/dist/types/nextdoor-preview/icons/default-avatar.d.ts +3 -0
  171. package/dist/types/nextdoor-preview/icons/default-avatar.d.ts.map +1 -0
  172. package/dist/types/nextdoor-preview/icons/default-image.d.ts +2 -0
  173. package/dist/types/nextdoor-preview/icons/default-image.d.ts.map +1 -0
  174. package/dist/types/nextdoor-preview/icons/globe-icon.d.ts +2 -0
  175. package/dist/types/nextdoor-preview/icons/globe-icon.d.ts.map +1 -0
  176. package/dist/types/nextdoor-preview/icons/like-icon.d.ts +2 -0
  177. package/dist/types/nextdoor-preview/icons/like-icon.d.ts.map +1 -0
  178. package/dist/types/nextdoor-preview/icons/share-icon.d.ts +2 -0
  179. package/dist/types/nextdoor-preview/icons/share-icon.d.ts.map +1 -0
  180. package/dist/types/nextdoor-preview/index.d.ts +4 -0
  181. package/dist/types/nextdoor-preview/index.d.ts.map +1 -0
  182. package/dist/types/nextdoor-preview/link-preview.d.ts +6 -0
  183. package/dist/types/nextdoor-preview/link-preview.d.ts.map +1 -0
  184. package/dist/types/nextdoor-preview/post-preview.d.ts +4 -0
  185. package/dist/types/nextdoor-preview/post-preview.d.ts.map +1 -0
  186. package/dist/types/nextdoor-preview/previews.d.ts +4 -0
  187. package/dist/types/nextdoor-preview/previews.d.ts.map +1 -0
  188. package/dist/types/nextdoor-preview/types.d.ts +8 -0
  189. package/dist/types/nextdoor-preview/types.d.ts.map +1 -0
  190. package/dist/types/tumblr-preview/previews.d.ts.map +1 -1
  191. package/package.json +71 -71
  192. package/src/helpers.tsx +26 -3
  193. package/src/index.ts +1 -0
  194. package/src/instagram-preview/style.scss +6 -1
  195. package/src/linkedin-preview/link-preview.tsx +2 -0
  196. package/src/linkedin-preview/post-preview.tsx +4 -2
  197. package/src/mastodon-preview/constants.ts +3 -0
  198. package/src/mastodon-preview/post/actions/index.tsx +57 -42
  199. package/src/mastodon-preview/post/actions/styles.scss +8 -23
  200. package/src/mastodon-preview/post/body/index.tsx +14 -10
  201. package/src/mastodon-preview/post/card/index.tsx +21 -4
  202. package/src/mastodon-preview/post/card/styles.scss +37 -13
  203. package/src/mastodon-preview/post/header/index.tsx +7 -9
  204. package/src/mastodon-preview/post/icons/index.tsx +13 -7
  205. package/src/mastodon-preview/post-preview.tsx +23 -11
  206. package/src/mastodon-preview/styles.scss +31 -0
  207. package/src/nextdoor-preview/constants.ts +2 -0
  208. package/src/nextdoor-preview/footer-actions.tsx +23 -0
  209. package/src/nextdoor-preview/icons/chevron-icon.tsx +11 -0
  210. package/src/nextdoor-preview/icons/comment-icon.tsx +12 -0
  211. package/src/nextdoor-preview/icons/default-avatar.tsx +3 -0
  212. package/src/nextdoor-preview/icons/default-image.tsx +23 -0
  213. package/src/nextdoor-preview/icons/globe-icon.tsx +12 -0
  214. package/src/nextdoor-preview/icons/like-icon.tsx +12 -0
  215. package/src/nextdoor-preview/icons/share-icon.tsx +12 -0
  216. package/src/nextdoor-preview/index.tsx +3 -0
  217. package/src/nextdoor-preview/link-preview.tsx +22 -0
  218. package/src/nextdoor-preview/post-preview.tsx +117 -0
  219. package/src/nextdoor-preview/previews.tsx +53 -0
  220. package/src/nextdoor-preview/style.scss +211 -0
  221. package/src/nextdoor-preview/types.ts +9 -0
  222. package/src/tumblr-preview/previews.tsx +3 -1
  223. package/src/tumblr-preview/variables.scss +0 -1
  224. package/src/twitter-preview/card.tsx +2 -2
  225. package/src/twitter-preview/media.tsx +2 -2
  226. package/src/twitter-preview/post-preview.tsx +3 -3
  227. package/src/twitter-preview/previews.tsx +2 -2
  228. package/CHANGELOG.md +0 -62
  229. package/dist/cjs/mastodon-preview/post/icons/styles.scss +0 -50
  230. package/dist/esm/mastodon-preview/post/icons/styles.scss +0 -50
  231. package/src/mastodon-preview/post/icons/styles.scss +0 -50
@@ -1,49 +1,64 @@
1
- import { __ } from '@wordpress/i18n';
2
- import MastodonPostIcon from '../icons';
3
-
4
1
  import './styles.scss';
5
2
 
6
3
  const MastodonPostActions: React.FC = () => (
7
4
  <div className="mastodon-preview__post-actions">
8
- <ul>
9
- { [
10
- {
11
- icon: 'reply',
12
- // translators: "Reply" action on a Mastodon post
13
- label: __( 'Reply', 'social-previews' ),
14
- text: 0,
15
- },
16
- {
17
- icon: 'boost',
18
- // translators: "Boost" action on a Mastodon post
19
- label: __( 'Boost', 'social-previews' ),
20
- },
21
- {
22
- icon: 'like',
23
- // translators: "Favourite" action on a Mastodon post
24
- label: __( 'Favourite', 'social-previews' ),
25
- },
26
- {
27
- icon: 'bookmark',
28
- // translators: "Bookmark" action on a Mastodon post
29
- label: __( 'Bookmark', 'social-previews' ),
30
- },
31
- {
32
- icon: 'more',
33
- // translators: "More" menu on a Mastodon post
34
- label: __( 'More', 'social-previews' ),
35
- },
36
- ].map( ( { icon, label, text } ) => (
37
- <li key={ icon } aria-label={ label }>
38
- <span className="mastodon-preview__post-icon-wrapper">
39
- <MastodonPostIcon name={ icon } />
40
- </span>
41
- { ( typeof text === 'number' || text ) && (
42
- <span className="mastodon-preview__post-icon-text">{ text }</span>
43
- ) }
44
- </li>
45
- ) ) }
46
- </ul>
5
+ <div>
6
+ <svg
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ height="24"
9
+ viewBox="0 -960 960 960"
10
+ width="24"
11
+ aria-hidden="true"
12
+ >
13
+ <path d="M760-200v-160q0-50-35-85t-85-35H273l144 144-57 56-240-240 240-240 57 56-144 144h367q83 0 141.5 58.5T840-360v160h-80Z"></path>
14
+ </svg>
15
+ &nbsp;
16
+ <span>{ 0 }</span>
17
+ </div>
18
+ <div>
19
+ <svg
20
+ xmlns="http://www.w3.org/2000/svg"
21
+ height="24"
22
+ viewBox="0 -960 960 960"
23
+ width="24"
24
+ aria-hidden="true"
25
+ >
26
+ <path d="M280-80 120-240l160-160 56 58-62 62h406v-160h80v240H274l62 62-56 58Zm-80-440v-240h486l-62-62 56-58 160 160-160 160-56-58 62-62H280v160h-80Z"></path>
27
+ </svg>
28
+ </div>
29
+ <div>
30
+ <svg
31
+ xmlns="http://www.w3.org/2000/svg"
32
+ height="24"
33
+ viewBox="0 -960 960 960"
34
+ width="24"
35
+ aria-hidden="true"
36
+ >
37
+ <path d="m354-287 126-76 126 77-33-144 111-96-146-13-58-136-58 135-146 13 111 97-33 143ZM233-120l65-281L80-590l288-25 112-265 112 265 288 25-218 189 65 281-247-149-247 149Zm247-350Z"></path>
38
+ </svg>
39
+ </div>
40
+ <div>
41
+ <svg
42
+ xmlns="http://www.w3.org/2000/svg"
43
+ height="24"
44
+ viewBox="0 -960 960 960"
45
+ width="24"
46
+ aria-hidden="true"
47
+ >
48
+ <path d="M200-120v-640q0-33 23.5-56.5T280-840h400q33 0 56.5 23.5T760-760v640L480-240 200-120Zm80-122 200-86 200 86v-518H280v518Zm0-518h400-400Z"></path>
49
+ </svg>
50
+ </div>
51
+ <div>
52
+ <svg
53
+ xmlns="http://www.w3.org/2000/svg"
54
+ height="24"
55
+ viewBox="0 -960 960 960"
56
+ width="24"
57
+ aria-hidden="true"
58
+ >
59
+ <path d="M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"></path>
60
+ </svg>
61
+ </div>
47
62
  </div>
48
63
  );
49
64
 
@@ -2,34 +2,19 @@
2
2
 
3
3
  .mastodon-preview__post-actions {
4
4
  margin-top: 1rem;
5
+ display: flex;
6
+ justify-content: space-between;
7
+ align-items: center;
5
8
 
6
- ul {
9
+ & > div {
7
10
  display: flex;
8
- justify-content: space-between;
9
11
  align-items: center;
10
-
11
- margin: 0;
12
- padding: 0;
13
-
14
- list-style-type: none;
15
-
16
- > li {
17
- display: flex;
18
- align-items: center;
19
- gap: 0.25rem;
20
-
21
- margin: 0;
22
- }
12
+ color: #606984;
23
13
  }
24
- }
25
14
 
26
- .mastodon-preview__post-icon-wrapper {
27
- display: flex;
28
- justify-content: center;
29
- align-items: center;
30
-
31
- width: 24px;
32
- height: 24px;
15
+ svg {
16
+ fill: currentColor;
17
+ }
33
18
  }
34
19
 
35
20
  .mastodon-preview__post-icon-text {
@@ -19,16 +19,20 @@ const MastonPostBody: React.FC< Props > = ( props ) => {
19
19
  if ( customText ) {
20
20
  bodyTxt = <p>{ mastodonBody( customText, options ) }</p>;
21
21
  } else if ( description ) {
22
- const renderedTitle = stripHtmlTags( title );
23
-
24
- options.offset = renderedTitle.length;
25
-
26
- bodyTxt = (
27
- <>
28
- <p>{ renderedTitle }</p>
29
- <p>{ mastodonBody( description, options ) }</p>
30
- </>
31
- );
22
+ if ( title ) {
23
+ const renderedTitle = stripHtmlTags( title );
24
+
25
+ options.offset = renderedTitle.length;
26
+
27
+ bodyTxt = (
28
+ <>
29
+ <p>{ renderedTitle }</p>
30
+ <p>{ mastodonBody( description, options ) }</p>
31
+ </>
32
+ );
33
+ } else {
34
+ bodyTxt = <p>{ mastodonBody( description, options ) }</p>;
35
+ }
32
36
  } else {
33
37
  bodyTxt = <p>{ mastodonBody( title, options ) }</p>;
34
38
  }
@@ -1,5 +1,6 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { baseDomain } from '../../../helpers';
2
+ import clsx from 'clsx';
3
+ import { baseDomain, getTitleFromDescription, stripHtmlTags } from '../../../helpers';
3
4
  import { mastodonTitle } from '../../helpers';
4
5
  import { MastodonPreviewProps } from '../../types';
5
6
 
@@ -8,23 +9,39 @@ import './styles.scss';
8
9
  const MastodonPostCard: React.FC< MastodonPreviewProps > = ( {
9
10
  siteName,
10
11
  title,
12
+ description,
11
13
  url,
12
14
  image,
13
15
  customImage,
14
16
  } ) => {
15
17
  return (
16
- <div className="mastodon-preview__card">
18
+ <div className={ clsx( 'mastodon-preview__card', { 'has-image': image } ) }>
17
19
  <div className="mastodon-preview__card-img">
18
- { ( image || customImage ) && (
20
+ { image || customImage ? (
19
21
  <img
20
22
  src={ image || customImage }
21
23
  alt={ __( 'Mastodon preview thumbnail', 'social-previews' ) }
22
24
  />
25
+ ) : (
26
+ <div className="mastodon-preview__card-img--fallback">
27
+ <svg
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ height="24"
30
+ viewBox="0 -960 960 960"
31
+ width="24"
32
+ aria-hidden="true"
33
+ >
34
+ <path d="M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520h200L520-800v200Z"></path>
35
+ </svg>
36
+ </div>
23
37
  ) }
24
38
  </div>
25
39
  <div className="mastodon-preview__card-text">
26
- <span className="mastodon-preview__card-title">{ mastodonTitle( title ) }</span>
27
40
  <span className="mastodon-preview__card-site">{ siteName || baseDomain( url ) }</span>
41
+ <span className="mastodon-preview__card-title">
42
+ { mastodonTitle( title ) || getTitleFromDescription( description ) }
43
+ </span>
44
+ <span className="mastodon-preview__card-description">{ stripHtmlTags( description ) }</span>
28
45
  </div>
29
46
  </div>
30
47
  );
@@ -6,18 +6,24 @@
6
6
  margin-top: 1rem;
7
7
  margin-bottom: 1rem;
8
8
 
9
- border: solid 1px #ccd7e0;
10
- border-radius: 4px;
9
+ border: solid 1px #d9e1e8;
10
+ /* stylelint-disable-next-line scales/radii */
11
+ border-radius: 8px;
12
+ overflow: hidden;
11
13
  color: $mastodon-body-text-color;
14
+
15
+ &.has-image {
16
+ flex-direction: column;
17
+ }
18
+
19
+ &.has-image &-img {
20
+ width: 100%;
21
+ }
12
22
  }
13
23
 
14
24
  .mastodon-preview__card-img {
15
- width: 60px;
16
25
  min-height: 60px;
17
26
 
18
- border-start-start-radius: inherit;
19
- border-end-start-radius: inherit;
20
-
21
27
  img {
22
28
  display: block;
23
29
 
@@ -28,25 +34,43 @@
28
34
  border-start-start-radius: inherit;
29
35
  border-end-start-radius: inherit;
30
36
  }
37
+
38
+ &--fallback {
39
+ aspect-ratio: 1;
40
+ background: #c0cdd9;
41
+ position: relative;
42
+ width: 120px;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ }
31
47
  }
32
48
 
33
49
  .mastodon-preview__card-text {
34
50
  display: flex;
35
51
  flex-direction: column;
36
- gap: 0.25rem;
37
-
38
- padding: 0.625rem 0.5rem;
52
+ gap: 0.5rem;
53
+ padding: 1rem;
54
+ overflow: hidden;
39
55
  }
40
56
 
41
57
  .mastodon-preview__card-title {
42
58
  color: #282c37;
43
59
 
44
- font-size: 0.875rem;
60
+ /* stylelint-disable-next-line scales/font-sizes */
61
+ font-size: 1.187rem;
45
62
  font-weight: 700;
46
- line-height: 1.3;
63
+ line-height: 1.4;
47
64
  }
48
65
 
49
66
  .mastodon-preview__card-site {
50
- /* stylelint-disable-next-line scales/font-sizes */
51
- font-size: 0.8125rem;
67
+ font-size: 0.875rem;
68
+ display: block;
69
+ }
70
+
71
+ .mastodon-preview__card-description {
72
+ font-size: 0.875rem;
73
+ white-space: nowrap;
74
+ overflow: hidden;
75
+ text-overflow: ellipsis;
52
76
  }
@@ -1,6 +1,7 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { DEFAULT_MASTODON_INSTANCE } from '../../constants';
3
- import MastodonPostIcon from '../icons';
2
+ import { formatMastodonDate } from '../../../helpers';
3
+ import { DEFAULT_AVATAR, DEFAULT_MASTODON_INSTANCE } from '../../constants';
4
+ import { GlobeIcon } from '../icons';
4
5
  import type { MastodonPreviewProps } from '../../types';
5
6
 
6
7
  import './styles.scss';
@@ -13,7 +14,7 @@ const MastodonPostHeader: React.FC< Props > = ( { user } ) => {
13
14
  return (
14
15
  <div className="mastodon-preview__post-header">
15
16
  <div className="mastodon-preview__post-header-user">
16
- { avatarUrl && <img className="mastodon-preview__post-avatar" src={ avatarUrl } alt="" /> }
17
+ <img className="mastodon-preview__post-avatar" src={ avatarUrl || DEFAULT_AVATAR } alt="" />
17
18
  <div>
18
19
  <div className="mastodon-preview__post-header-displayname">
19
20
  { displayName ||
@@ -21,16 +22,13 @@ const MastodonPostHeader: React.FC< Props > = ( { user } ) => {
21
22
  __( 'anonymous-user', 'social-previews' ) }
22
23
  </div>
23
24
  <div className="mastodon-preview__post-header-username">
24
- { address?.replace( `@${ DEFAULT_MASTODON_INSTANCE }`, '' ) }
25
+ { address?.replace( `@${ DEFAULT_MASTODON_INSTANCE }`, '' ) || '@username' }
25
26
  </div>
26
27
  </div>
27
28
  </div>
28
29
  <div className="mastodon-preview__post-header-audience">
29
- <MastodonPostIcon name="globe" />
30
- {
31
- // translators: time elapsed since post was published (1 hour)
32
- __( '1h', 'social-previews' )
33
- }
30
+ <GlobeIcon />
31
+ { formatMastodonDate( new Date() ) }
34
32
  </div>
35
33
  </div>
36
34
  );
@@ -1,7 +1,13 @@
1
- import './styles.scss';
2
-
3
- const MastodonPostIcon: React.FC< { name: string } > = ( { name } ) => (
4
- <i className={ `mastodon-preview__post-icon mastodon-preview__post-icon-${ name }` } />
5
- );
6
-
7
- export default MastodonPostIcon;
1
+ export function GlobeIcon() {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ height="15"
6
+ viewBox="0 -960 960 960"
7
+ width="15"
8
+ role="img"
9
+ >
10
+ <path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-40-82v-78q-33 0-56.5-23.5T360-320v-40L168-552q-3 18-5.5 36t-2.5 36q0 121 79.5 212T440-162Zm276-102q20-22 36-47.5t26.5-53q10.5-27.5 16-56.5t5.5-59q0-98-54.5-179T600-776v16q0 33-23.5 56.5T520-680h-80v80q0 17-11.5 28.5T400-560h-80v80h240q17 0 28.5 11.5T600-440v120h40q26 0 47 15.5t29 40.5Z"></path>
11
+ </svg>
12
+ );
13
+ }
@@ -1,28 +1,40 @@
1
- import { __ } from '@wordpress/i18n';
1
+ import clsx from 'clsx';
2
2
  import MastodonPostActions from './post/actions';
3
3
  import MastonPostBody from './post/body';
4
+ import MastodonPostCard from './post/card';
4
5
  import MastodonPostHeader from './post/header';
5
6
  import type { MastodonPreviewProps } from './types';
6
7
 
7
8
  import './styles.scss';
8
9
 
9
10
  export const MastodonPostPreview: React.FC< MastodonPreviewProps > = ( props ) => {
10
- const { user, customImage, image } = props;
11
-
12
- const img = customImage || image;
11
+ const { user, media } = props;
13
12
 
14
13
  return (
15
14
  <div className="mastodon-preview__post">
16
15
  <MastodonPostHeader user={ user } />
17
16
  <MastonPostBody { ...props }>
18
- { img && (
19
- <img
20
- className="mastodon-preview__img"
21
- src={ img }
22
- alt={ __( 'Mastodon preview thumbnail', 'social-previews' ) }
23
- />
24
- ) }
17
+ { media?.length ? (
18
+ <div className={ clsx( 'mastodon-preview__media', { 'as-grid': media.length > 1 } ) }>
19
+ { media.map( ( mediaItem, index ) => (
20
+ <div
21
+ key={ `mastodon-preview__media-item-${ index }` }
22
+ className="mastodon-preview__media-item"
23
+ >
24
+ { mediaItem.type.startsWith( 'video/' ) ? (
25
+ // eslint-disable-next-line jsx-a11y/media-has-caption
26
+ <video controls>
27
+ <source src={ mediaItem.url } type={ mediaItem.type } />
28
+ </video>
29
+ ) : (
30
+ <img alt={ mediaItem.alt || '' } src={ mediaItem.url } />
31
+ ) }
32
+ </div>
33
+ ) ) }
34
+ </div>
35
+ ) : null }
25
36
  </MastonPostBody>
37
+ { ! media?.length ? <MastodonPostCard { ...props } /> : null }
26
38
  <MastodonPostActions />
27
39
  </div>
28
40
  );
@@ -40,3 +40,34 @@
40
40
  aspect-ratio: 16 / 9;
41
41
  object-fit: cover;
42
42
  }
43
+
44
+ .mastodon-preview__media {
45
+
46
+ margin-top: 8px;
47
+ min-height: 64px;
48
+ /* stylelint-disable-next-line scales/radii */
49
+ border-radius: 8px;
50
+
51
+ &.as-grid {
52
+ display: grid;
53
+ gap: 2px;
54
+ grid-template-columns: 50% 50%;
55
+ width: 100%;
56
+ overflow: hidden;
57
+ }
58
+
59
+ &-item {
60
+ display: flex;
61
+ border: 0;
62
+ /* stylelint-disable-next-line scales/radii */
63
+ border-radius: 8px;
64
+ overflow: hidden;
65
+
66
+ img,
67
+ video {
68
+ width: 100%;
69
+ object-fit: cover;
70
+ }
71
+ }
72
+
73
+ }
@@ -0,0 +1,2 @@
1
+ export const FEED_TEXT_MAX_LENGTH = 160;
2
+ export const FEED_TEXT_MAX_LINES = 2;
@@ -0,0 +1,23 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { CommentIcon } from './icons/comment-icon';
3
+ import { LikeIcon } from './icons/like-icon';
4
+ import { ShareIcon } from './icons/share-icon';
5
+
6
+ export function FooterActions() {
7
+ return (
8
+ <div className="nextdoor-preview__footer--actions">
9
+ <div className="nextdoor-preview__footer--actions-item">
10
+ <LikeIcon />
11
+ <span>{ __( 'Like', 'social-previews' ) }</span>
12
+ </div>
13
+ <div className="nextdoor-preview__footer--actions-item">
14
+ <CommentIcon />
15
+ <span>{ __( 'Comment', 'social-previews' ) }</span>
16
+ </div>
17
+ <div className="nextdoor-preview__footer--actions-item">
18
+ <ShareIcon />
19
+ <span>{ __( 'Share', 'social-previews' ) }</span>
20
+ </div>
21
+ </div>
22
+ );
23
+ }
@@ -0,0 +1,11 @@
1
+ export function ChevronIcon() {
2
+ return (
3
+ <svg width="20" height="20" viewBox="0 0 20 20" aria-hidden="true">
4
+ <path
5
+ fill="#dfe1e4"
6
+ fillRule="evenodd"
7
+ d="M7.127 13.876a.732.732 0 1 0 1.035 1.035l4.75-4.749a.732.732 0 0 0 0-1.035L8.123 4.34A.732.732 0 0 0 7.09 5.375l4.27 4.27-4.232 4.23Z"
8
+ ></path>
9
+ </svg>
10
+ );
11
+ }
@@ -0,0 +1,12 @@
1
+ export function CommentIcon() {
2
+ return (
3
+ <svg width="20" height="20" fill="none" viewBox="0 0 24 24" aria-hidden="true">
4
+ <path
5
+ fill="currentColor"
6
+ fillRule="evenodd"
7
+ d="M2 10.031C2 5.596 5.574 2 10 2h4c4.427 0 8 3.596 8 8.031 0 4.435-3.573 8.031-8 8.031h-1.52a17.033 17.033 0 0 1-1.377 1.467c-.991.938-2.456 2.079-4.086 2.437a1.403 1.403 0 0 1-1.458-.565 1.55 1.55 0 0 1-.195-1.394c.28-.823.395-1.734.434-2.464.014-.257.018-.485.018-.672A8.017 8.017 0 0 1 2 10.031Zm5.798 6.178a7.02 7.02 0 0 1 .016.418c.005.252.004.606-.019 1.023-.03.573-.103 1.285-.266 2.024.775-.377 1.54-.974 2.202-1.598a15.066 15.066 0 0 0 1.448-1.586l.017-.022.003-.004a1 1 0 0 1 .801-.402h2c3.314 0 6-2.692 6-6.03C20 6.691 17.314 4 14 4h-4c-3.314 0-6 2.692-6 6.031 0 2.336 1.32 4.36 3.258 5.359.308.159.515.474.54.82Z"
8
+ clipRule="evenodd"
9
+ ></path>
10
+ </svg>
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ export const DefaultAvatar: React.FC = () => {
2
+ return <div className="nextdoor-preview__default-avatar">A</div>;
3
+ };
@@ -0,0 +1,23 @@
1
+ export function DefaultImage() {
2
+ return (
3
+ <div className="nextdoor-preview__default-image">
4
+ <svg
5
+ width="24"
6
+ height="24"
7
+ fill="none"
8
+ viewBox="0 0 24 24"
9
+ aria-hidden="true"
10
+ color="#055c00"
11
+ >
12
+ <path
13
+ fill="currentColor"
14
+ d="M13.207 5.207c1.51-1.51 4.076-1.51 5.586 0 1.51 1.51 1.51 4.076 0 5.586l-2.1 2.1c-1.51 1.51-4.077 1.51-5.586 0a1 1 0 1 0-1.414 1.414c2.29 2.29 6.123 2.29 8.414 0l2.1-2.1c2.29-2.29 2.29-6.124 0-8.414s-6.124-2.29-8.414 0l-.7.7a1 1 0 0 0 1.414 1.414l.7-.7Z"
15
+ ></path>
16
+ <path
17
+ fill="currentColor"
18
+ d="M7.307 11.107c1.51-1.51 4.076-1.51 5.586 0a1 1 0 0 0 1.414-1.414c-2.29-2.29-6.124-2.29-8.414 0l-2.1 2.1c-2.29 2.29-2.29 6.123 0 8.414 2.29 2.29 6.124 2.29 8.414 0l.7-.7a1 1 0 0 0-1.414-1.414l-.7.7c-1.51 1.51-4.076 1.51-5.586 0-1.51-1.51-1.51-4.076 0-5.586l2.1-2.1Z"
19
+ ></path>
20
+ </svg>
21
+ </div>
22
+ );
23
+ }
@@ -0,0 +1,12 @@
1
+ export function GlobeIcon() {
2
+ return (
3
+ <svg width="14" height="14" fill="none" viewBox="0 0 24 24" aria-hidden="true">
4
+ <path
5
+ fill="currentColor"
6
+ fillRule="evenodd"
7
+ d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm9.495-7.643c.286-.335.46-.357.505-.357.045 0 .219.022.505.357.282.33.581.868.852 1.619.464 1.283.79 3.034.872 5.024H9.771c.082-1.99.408-3.741.871-5.024.272-.751.571-1.289.854-1.62ZM7.77 11c.084-2.181.439-4.171.992-5.704.093-.255.192-.502.298-.738A8.009 8.009 0 0 0 4.062 11h3.707Zm-3.707 2h3.707c.084 2.181.439 4.171.992 5.704.093.255.192.502.298.738A8.009 8.009 0 0 1 4.062 13Zm15.876-2a8.009 8.009 0 0 0-4.997-6.442c.106.236.205.483.298.738.553 1.533.908 3.523.992 5.704h3.707Zm-3.707 2h3.707a8.009 8.009 0 0 1-4.997 6.442c.106-.236.205-.483.298-.738.553-1.533.908-3.523.992-5.704Zm-2.002 0c-.082 1.99-.408 3.741-.871 5.024-.272.751-.571 1.289-.854 1.62-.285.334-.46.356-.504.356-.045 0-.219-.022-.505-.357-.282-.33-.581-.868-.852-1.619-.464-1.283-.79-3.034-.872-5.024h4.458Z"
8
+ clipRule="evenodd"
9
+ ></path>
10
+ </svg>
11
+ );
12
+ }
@@ -0,0 +1,12 @@
1
+ export function LikeIcon() {
2
+ return (
3
+ <svg width="20" height="20" fill="none" viewBox="0 0 24 24" aria-hidden="true">
4
+ <path
5
+ fill="currentColor"
6
+ fillRule="evenodd"
7
+ d="M13.275 8.752a1.5 1.5 0 0 1-2.55 0C9.75 7.18 8.719 5.617 6.565 6.074 5.248 6.352 4 7.433 4 9.644c0 2.153 1.348 4.592 4.259 7.236A28.475 28.475 0 0 0 12 19.74a28.475 28.475 0 0 0 3.741-2.86C18.651 14.236 20 11.797 20 9.643c0-2.21-1.25-3.29-2.564-3.57-2.155-.456-3.187 1.106-4.16 2.68Zm-2.581-3.48C7.634 2.58 2 4.217 2 9.643c0 2.996 1.85 5.934 4.914 8.717 1.478 1.343 3.1 2.585 4.839 3.575a.5.5 0 0 0 .494 0c1.739-.99 3.361-2.232 4.84-3.575C20.148 15.577 22 12.64 22 9.643c0-5.426-5.634-7.062-8.694-4.371A5.287 5.287 0 0 0 12 7.04a5.287 5.287 0 0 0-1.306-1.77Z"
8
+ clipRule="evenodd"
9
+ ></path>
10
+ </svg>
11
+ );
12
+ }
@@ -0,0 +1,12 @@
1
+ export function ShareIcon() {
2
+ return (
3
+ <svg width="20" height="20" fill="none" viewBox="0 0 24 24" aria-hidden="true">
4
+ <path
5
+ fill="currentColor"
6
+ fillRule="evenodd"
7
+ d="M11.617 2.076a1 1 0 0 1 1.09.217l9 9a1 1 0 0 1 0 1.414l-9 9A1 1 0 0 1 11 21v-4.436c-2.849.366-5.261 2.271-6.384 4.837a1 1 0 0 1-1.856-.06C2.338 20.182 2 18.86 2 17.5a9.959 9.959 0 0 1 9-9.951V3a1 1 0 0 1 .617-.924ZM13 5.414V8.5a1 1 0 0 1-1 1c-4.448 0-8 3.552-8 8 0 .31.023.625.066.94C5.905 16.067 8.776 14.5 12 14.5a1 1 0 0 1 1 1v3.086L19.586 12 13 5.414Z"
8
+ clipRule="evenodd"
9
+ ></path>
10
+ </svg>
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ export * from './link-preview';
2
+ export * from './post-preview';
3
+ export * from './previews';
@@ -0,0 +1,22 @@
1
+ import { getTitleFromDescription } from '../helpers';
2
+ import { NextdoorPostPreview } from './post-preview';
3
+ import { NextdoorPreviewProps } from './types';
4
+
5
+ type OptionalProps = Partial< Pick< NextdoorPreviewProps, 'name' | 'profileImage' > >;
6
+
7
+ export type NextdoorLinkPreviewProps = Omit< NextdoorPreviewProps, keyof OptionalProps > &
8
+ OptionalProps;
9
+
10
+ export function NextdoorLinkPreview( props: NextdoorLinkPreviewProps ) {
11
+ return (
12
+ <NextdoorPostPreview
13
+ name=""
14
+ profileImage=""
15
+ { ...props }
16
+ // Override the props that are irrelevant to link preview
17
+ description=""
18
+ media={ undefined }
19
+ title={ props.title || getTitleFromDescription( props.description ) }
20
+ />
21
+ );
22
+ }