@atlaskit/smart-card 18.0.13 → 18.0.16

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 (243) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/extractors/common/context/extractProvider.js +14 -4
  3. package/dist/cjs/extractors/common/detail/extractCommentCount.js +3 -1
  4. package/dist/cjs/extractors/common/detail/extractProgrammingLanguage.js +3 -1
  5. package/dist/cjs/extractors/common/detail/extractSubscriberCount.js +3 -1
  6. package/dist/cjs/extractors/common/primitives/extractTitleTextColor.js +3 -1
  7. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +9 -0
  8. package/dist/cjs/state/flexible-ui-context/index.js +4 -0
  9. package/dist/cjs/utils/analytics/analytics.js +52 -2
  10. package/dist/cjs/utils/analytics/index.js +18 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/cjs/view/BlockCard/components/Frame.js +10 -7
  13. package/dist/cjs/view/BlockCard/components/Link.js +3 -1
  14. package/dist/cjs/view/BlockCard/components/Provider.js +3 -1
  15. package/dist/cjs/view/BlockCard/views/ErroredView.js +3 -1
  16. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +3 -1
  17. package/dist/cjs/view/BlockCard/views/NotFoundView.js +3 -1
  18. package/dist/cjs/view/BlockCard/views/ResolvingView.js +4 -2
  19. package/dist/cjs/view/CardWithUrl/component.js +4 -2
  20. package/dist/cjs/view/CardWithUrl/loader.js +4 -2
  21. package/dist/cjs/view/EmbedCard/components/styled.js +15 -13
  22. package/dist/cjs/view/EmbedCard/views/ErroredView.js +3 -1
  23. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +26 -4
  24. package/dist/cjs/view/FlexibleCard/components/actions/index.js +18 -2
  25. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
  26. package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +9 -2
  27. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +9 -2
  28. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
  29. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
  30. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
  31. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
  32. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +39 -19
  33. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +92 -17
  34. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +45 -9
  35. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +23 -12
  36. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +8 -2
  37. package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +3 -1
  38. package/dist/cjs/view/FlexibleCard/components/container/index.js +5 -0
  39. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
  40. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +18 -3
  41. package/dist/cjs/view/FlexibleCard/components/elements/date-time/index.js +9 -1
  42. package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +9 -1
  43. package/dist/cjs/view/FlexibleCard/components/elements/index.js +96 -0
  44. package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +10 -1
  45. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
  46. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +9 -2
  47. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +12 -6
  48. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +7 -3
  49. package/dist/cjs/view/FlexibleCard/index.js +6 -0
  50. package/dist/cjs/view/HoverCard/index.js +48 -10
  51. package/dist/cjs/view/HoverCard/styled.js +3 -1
  52. package/dist/cjs/view/InlineCard/ErroredView/index.js +3 -1
  53. package/dist/cjs/view/InlineCard/ForbiddenView/index.js +4 -2
  54. package/dist/cjs/view/InlineCard/Frame/styled.js +16 -13
  55. package/dist/cjs/view/InlineCard/Icon.js +3 -1
  56. package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +4 -2
  57. package/dist/cjs/view/InlineCard/styled.js +6 -4
  58. package/dist/cjs/view/common/Byline.js +3 -1
  59. package/dist/cjs/view/common/Metadata.js +3 -1
  60. package/dist/cjs/view/common/ModalHeader.js +4 -2
  61. package/dist/es2019/extractors/common/context/extractProvider.js +13 -4
  62. package/dist/es2019/extractors/common/detail/extractCommentCount.js +2 -1
  63. package/dist/es2019/extractors/common/detail/extractProgrammingLanguage.js +2 -1
  64. package/dist/es2019/extractors/common/detail/extractSubscriberCount.js +2 -1
  65. package/dist/es2019/extractors/common/primitives/extractTitleTextColor.js +2 -1
  66. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +7 -2
  67. package/dist/es2019/state/flexible-ui-context/index.js +5 -0
  68. package/dist/es2019/utils/analytics/analytics.js +35 -0
  69. package/dist/es2019/utils/analytics/index.js +1 -1
  70. package/dist/es2019/version.json +1 -1
  71. package/dist/es2019/view/BlockCard/components/Frame.js +9 -7
  72. package/dist/es2019/view/BlockCard/components/Link.js +2 -1
  73. package/dist/es2019/view/BlockCard/components/Provider.js +2 -1
  74. package/dist/es2019/view/BlockCard/views/ErroredView.js +2 -1
  75. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +2 -1
  76. package/dist/es2019/view/BlockCard/views/NotFoundView.js +2 -1
  77. package/dist/es2019/view/BlockCard/views/ResolvingView.js +3 -2
  78. package/dist/es2019/view/CardWithUrl/component.js +4 -2
  79. package/dist/es2019/view/CardWithUrl/loader.js +4 -2
  80. package/dist/es2019/view/EmbedCard/components/styled.js +15 -15
  81. package/dist/es2019/view/EmbedCard/views/ErroredView.js +2 -1
  82. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +37 -4
  83. package/dist/es2019/view/FlexibleCard/components/actions/index.js +18 -2
  84. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
  85. package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +9 -2
  86. package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +8 -2
  87. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
  88. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
  89. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
  90. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
  91. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +31 -15
  92. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +77 -15
  93. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +35 -8
  94. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +20 -11
  95. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +8 -3
  96. package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +7 -6
  97. package/dist/es2019/view/FlexibleCard/components/container/index.js +5 -0
  98. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
  99. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +18 -3
  100. package/dist/es2019/view/FlexibleCard/components/elements/date-time/index.js +9 -1
  101. package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +9 -1
  102. package/dist/es2019/view/FlexibleCard/components/elements/index.js +96 -0
  103. package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +10 -1
  104. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
  105. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +8 -1
  106. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +11 -4
  107. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +5 -2
  108. package/dist/es2019/view/FlexibleCard/index.js +6 -0
  109. package/dist/es2019/view/HoverCard/index.js +40 -10
  110. package/dist/es2019/view/HoverCard/styled.js +6 -1
  111. package/dist/es2019/view/InlineCard/ErroredView/index.js +2 -1
  112. package/dist/es2019/view/InlineCard/ForbiddenView/index.js +3 -2
  113. package/dist/es2019/view/InlineCard/Frame/styled.js +15 -12
  114. package/dist/es2019/view/InlineCard/Icon.js +7 -6
  115. package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +3 -2
  116. package/dist/es2019/view/InlineCard/styled.js +5 -4
  117. package/dist/es2019/view/common/Byline.js +2 -1
  118. package/dist/es2019/view/common/Metadata.js +2 -1
  119. package/dist/es2019/view/common/ModalHeader.js +3 -2
  120. package/dist/esm/extractors/common/context/extractProvider.js +13 -4
  121. package/dist/esm/extractors/common/detail/extractCommentCount.js +2 -1
  122. package/dist/esm/extractors/common/detail/extractProgrammingLanguage.js +2 -1
  123. package/dist/esm/extractors/common/detail/extractSubscriberCount.js +2 -1
  124. package/dist/esm/extractors/common/primitives/extractTitleTextColor.js +2 -1
  125. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +10 -1
  126. package/dist/esm/state/flexible-ui-context/index.js +5 -0
  127. package/dist/esm/utils/analytics/analytics.js +41 -0
  128. package/dist/esm/utils/analytics/index.js +1 -1
  129. package/dist/esm/version.json +1 -1
  130. package/dist/esm/view/BlockCard/components/Frame.js +9 -7
  131. package/dist/esm/view/BlockCard/components/Link.js +2 -1
  132. package/dist/esm/view/BlockCard/components/Provider.js +2 -1
  133. package/dist/esm/view/BlockCard/views/ErroredView.js +2 -1
  134. package/dist/esm/view/BlockCard/views/ForbiddenView.js +2 -1
  135. package/dist/esm/view/BlockCard/views/NotFoundView.js +2 -1
  136. package/dist/esm/view/BlockCard/views/ResolvingView.js +3 -2
  137. package/dist/esm/view/CardWithUrl/component.js +4 -2
  138. package/dist/esm/view/CardWithUrl/loader.js +4 -2
  139. package/dist/esm/view/EmbedCard/components/styled.js +14 -13
  140. package/dist/esm/view/EmbedCard/views/ErroredView.js +2 -1
  141. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +25 -4
  142. package/dist/esm/view/FlexibleCard/components/actions/index.js +18 -2
  143. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
  144. package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +9 -2
  145. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +8 -2
  146. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
  147. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
  148. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
  149. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
  150. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +33 -16
  151. package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +79 -17
  152. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +39 -8
  153. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +22 -11
  154. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +8 -3
  155. package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +2 -1
  156. package/dist/esm/view/FlexibleCard/components/container/index.js +5 -0
  157. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
  158. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +18 -3
  159. package/dist/esm/view/FlexibleCard/components/elements/date-time/index.js +9 -1
  160. package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +9 -1
  161. package/dist/esm/view/FlexibleCard/components/elements/index.js +96 -0
  162. package/dist/esm/view/FlexibleCard/components/elements/link/index.js +10 -1
  163. package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
  164. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +9 -2
  165. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +12 -6
  166. package/dist/esm/view/FlexibleCard/components/elements/utils.js +5 -3
  167. package/dist/esm/view/FlexibleCard/index.js +6 -0
  168. package/dist/esm/view/HoverCard/index.js +42 -10
  169. package/dist/esm/view/HoverCard/styled.js +2 -1
  170. package/dist/esm/view/InlineCard/ErroredView/index.js +2 -1
  171. package/dist/esm/view/InlineCard/ForbiddenView/index.js +3 -2
  172. package/dist/esm/view/InlineCard/Frame/styled.js +16 -13
  173. package/dist/esm/view/InlineCard/Icon.js +2 -1
  174. package/dist/esm/view/InlineCard/UnauthorisedView/index.js +3 -2
  175. package/dist/esm/view/InlineCard/styled.js +5 -4
  176. package/dist/esm/view/common/Byline.js +2 -1
  177. package/dist/esm/view/common/Metadata.js +2 -1
  178. package/dist/esm/view/common/ModalHeader.js +3 -2
  179. package/dist/types/client/errors.d.ts +3 -2
  180. package/dist/types/extractors/block/index.d.ts +2 -2
  181. package/dist/types/extractors/common/__mocks__/jsonld.d.ts +46 -66
  182. package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
  183. package/dist/types/extractors/common/title-prefix/extractTitlePrefix.d.ts +2 -1
  184. package/dist/types/extractors/embed/index.d.ts +1 -1
  185. package/dist/types/extractors/flexible/icon/extract-url-icon.d.ts +1 -1
  186. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +4 -0
  187. package/dist/types/state/flexible-ui-context/index.d.ts +4 -0
  188. package/dist/types/state/flexible-ui-context/types.d.ts +102 -0
  189. package/dist/types/state/hooks/useSmartLink.d.ts +3 -0
  190. package/dist/types/utils/analytics/analytics.d.ts +5 -1
  191. package/dist/types/utils/analytics/index.d.ts +1 -1
  192. package/dist/types/utils/types.d.ts +2 -2
  193. package/dist/types/view/BlockCard/utils/handlers.d.ts +1 -1
  194. package/dist/types/view/Card/index.d.ts +1 -1
  195. package/dist/types/view/Card/types.d.ts +1 -0
  196. package/dist/types/view/CardWithUrl/component.d.ts +1 -1
  197. package/dist/types/view/CardWithUrl/types.d.ts +1 -0
  198. package/dist/types/view/EmbedCard/components/styled.d.ts +9 -9
  199. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +8 -0
  200. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +4 -2
  201. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +15 -0
  202. package/dist/types/view/FlexibleCard/components/blocks/action-group/index.d.ts +6 -0
  203. package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +1 -1
  204. package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +6 -0
  205. package/dist/types/view/FlexibleCard/components/blocks/element-group/index.d.ts +6 -0
  206. package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +2 -2
  207. package/dist/types/view/FlexibleCard/components/blocks/footer-block/index.d.ts +6 -0
  208. package/dist/types/view/FlexibleCard/components/blocks/metadata-block/index.d.ts +6 -0
  209. package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +5 -0
  210. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +5 -0
  211. package/dist/types/view/FlexibleCard/components/blocks/title-block/errored/index.d.ts +9 -2
  212. package/dist/types/view/FlexibleCard/components/blocks/title-block/index.d.ts +11 -0
  213. package/dist/types/view/FlexibleCard/components/blocks/title-block/resolved/index.d.ts +7 -3
  214. package/dist/types/view/FlexibleCard/components/blocks/title-block/resolving/index.d.ts +8 -2
  215. package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +10 -1
  216. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +7 -5
  217. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +2 -1
  218. package/dist/types/view/FlexibleCard/components/container/index.d.ts +4 -0
  219. package/dist/types/view/FlexibleCard/components/container/types.d.ts +2 -2
  220. package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +7 -0
  221. package/dist/types/view/FlexibleCard/components/elements/badge/index.d.ts +13 -0
  222. package/dist/types/view/FlexibleCard/components/elements/date-time/index.d.ts +7 -0
  223. package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +6 -0
  224. package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +5 -1
  225. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +77 -0
  226. package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +6 -0
  227. package/dist/types/view/FlexibleCard/components/elements/lozenge/index.d.ts +6 -0
  228. package/dist/types/view/FlexibleCard/components/elements/media/index.d.ts +6 -0
  229. package/dist/types/view/FlexibleCard/components/elements/text/index.d.ts +6 -0
  230. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -2
  231. package/dist/types/view/FlexibleCard/components/elements/types.d.ts +2 -0
  232. package/dist/types/view/FlexibleCard/index.d.ts +6 -0
  233. package/dist/types/view/HoverCard/index.d.ts +3 -2
  234. package/dist/types/view/HoverCard/types.d.ts +5 -2
  235. package/dist/types/view/InlineCard/Icon.d.ts +3 -3
  236. package/dist/types/view/InlineCard/IconAndTitleLayout/styled.d.ts +9 -9
  237. package/dist/types/view/InlineCard/ResolvingView/styled.d.ts +3 -3
  238. package/dist/types/view/InlineCard/styled.d.ts +4 -4
  239. package/package.json +9 -4
  240. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/utils.js +0 -105
  241. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/utils.js +0 -71
  242. package/dist/esm/view/FlexibleCard/components/blocks/title-block/utils.js +0 -76
  243. package/dist/types/view/FlexibleCard/components/blocks/title-block/utils.d.ts +0 -11
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import Loadable from 'react-loadable';
3
3
  import { B200, B400, N700, R400 } from '@atlaskit/theme/colors';
4
4
  import { IconType } from '../../../../../constants';
5
- // prettier-ignore
5
+ import { token } from '@atlaskit/tokens'; // prettier-ignore
6
+
6
7
  const importIconMapper = {
7
8
  [IconType.Archive]: () => import(
8
9
  /* webpackChunkName: "glyphArchive" */
@@ -228,10 +229,14 @@ const AtlaskitIcon = ({
228
229
  return /*#__PURE__*/React.createElement(ImportedIcon, {
229
230
  "data-testid": testId // Confluence and Jira imports don't have native testId prop
230
231
  ,
231
- textColor: N700,
232
+ textColor: token('color.text.subtle', N700)
233
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
234
+ ,
232
235
  iconColor: B200,
233
236
  iconGradientStart: B400,
234
237
  iconGradientStop: B200
238
+ /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
239
+
235
240
  });
236
241
 
237
242
  case IconType.Error:
@@ -239,7 +244,7 @@ const AtlaskitIcon = ({
239
244
  return /*#__PURE__*/React.createElement(ImportedIcon, {
240
245
  label: label,
241
246
  testId: testId,
242
- primaryColor: R400
247
+ primaryColor: token('color.icon.danger', R400)
243
248
  });
244
249
 
245
250
  default:
@@ -2,6 +2,7 @@
2
2
  import React from 'react';
3
3
  import { css, jsx, keyframes } from '@emotion/core';
4
4
  import ImageLoader from 'react-render-image';
5
+ import { token } from '@atlaskit/tokens';
5
6
  const placeholderShimmer = keyframes`
6
7
  0% { background-position: -20px 0; }
7
8
  100% { background-position: 20px 0; }
@@ -9,14 +10,14 @@ const placeholderShimmer = keyframes`
9
10
  const shimmer = css`
10
11
  border-radius: 2px;
11
12
  user-select: none;
12
-
13
- background: #f6f7f8;
13
+ background: ${token('color.skeleton.subtle', '#f6f7f8')};
14
+ // TODO: https://product-fabric.atlassian.net/browse/DSP-4236
14
15
  background-image: linear-gradient(
15
16
  to right,
16
- #f6f7f8 0%,
17
- #edeef1 20%,
18
- #f6f7f8 40%,
19
- #f6f7f8 100%
17
+ ${token('color.skeleton.subtle', '#f6f7f8')} 0%,
18
+ ${token('color.skeleton', '#edeef1')} 20%,
19
+ ${token('color.skeleton.subtle', '#f6f7f8')} 40%,
20
+ ${token('color.skeleton.subtle', '#f6f7f8')}100%
20
21
  );
21
22
  background-repeat: no-repeat;
22
23
  background-size: 280% 100%;
@@ -70,6 +70,11 @@ const renderChildren = (children, containerSize, containerTheme, status, retry,
70
70
  });
71
71
  }
72
72
  });
73
+ /**
74
+ * This represents the container in which all Flexible UI Smart Links are rendered.
75
+ * @see Block
76
+ */
77
+
73
78
 
74
79
  const Container = ({
75
80
  children,
@@ -26,10 +26,19 @@ const getStyles = size => {
26
26
  `;
27
27
  }
28
28
  };
29
+ /**
30
+ * An element that displays a group of avatars.
31
+ * @public
32
+ * @param {AvatarGroupProps} AvatarGroupProps - The props necessary for the AvatarGroup.
33
+ * @see AuthorGroup
34
+ * @see CollaboratorGroup
35
+ */
36
+
29
37
 
30
38
  const AvatarGroup = ({
31
39
  items = [],
32
40
  maxCount = MAX_COUNT,
41
+ overrideCss,
33
42
  size = SmartLinkSize.Medium,
34
43
  testId = 'smart-element-avatar-group'
35
44
  }) => {
@@ -38,7 +47,9 @@ const AvatarGroup = ({
38
47
  }
39
48
 
40
49
  return jsx("span", {
41
- css: getStyles(size)
50
+ css: [getStyles(size), overrideCss],
51
+ "data-smart-element-avatar-group": true,
52
+ "data-testid": testId
42
53
  }, jsx(AtlaskitAvatarGroup, {
43
54
  maxCount: maxCount,
44
55
  appearance: "stack",
@@ -70,12 +70,27 @@ const renderImageIcon = (url, testId) => {
70
70
  });
71
71
  }
72
72
  };
73
+ /**
74
+ * An element that displays some text with an associated icon.
75
+ * @public
76
+ * @param {BadgeProps} BadgeProps - The props necessary for the Badge.
77
+ * @see CommentCount
78
+ * @see ViewCount
79
+ * @see ReactCount
80
+ * @see VoteCount
81
+ * @see SubscriberCount
82
+ * @see Priority
83
+ * @see ProgrammingLanguage
84
+ * @see Provider
85
+ */
86
+
73
87
 
74
88
  const Badge = ({
75
89
  icon,
76
- url,
77
90
  label,
78
- testId = 'smart-element-badge'
91
+ overrideCss,
92
+ testId = 'smart-element-badge',
93
+ url
79
94
  }) => {
80
95
  const formattedMessageOrLabel = getFormattedMessageFromIcon(icon) || label;
81
96
  const badgeIcon = renderAtlaskitIcon(icon, testId) || renderImageIcon(url, testId);
@@ -85,7 +100,7 @@ const Badge = ({
85
100
  }
86
101
 
87
102
  return jsx("div", {
88
- css: badgeStyles,
103
+ css: [badgeStyles, overrideCss],
89
104
  "data-fit-to-content": true,
90
105
  "data-smart-element-badge": true,
91
106
  "data-testid": testId
@@ -18,9 +18,17 @@ const typeToDescriptorMap = {
18
18
  created: messages.created_on,
19
19
  modified: messages.modified_on
20
20
  };
21
+ /**
22
+ * An element that displays an ISO Timestamp in text.
23
+ * @public
24
+ * @param {DateTimeProps} DateTimeProps - The props necessary for the DateTime element.
25
+ * @see CreatedOn
26
+ * @see ModifiedOn
27
+ */
21
28
 
22
29
  const DateTime = ({
23
30
  date,
31
+ overrideCss,
24
32
  type,
25
33
  testId = 'smart-element-date-time'
26
34
  }) => {
@@ -40,7 +48,7 @@ const DateTime = ({
40
48
  numeric: 'auto'
41
49
  });
42
50
  return jsx("span", {
43
- css: styles,
51
+ css: [styles, overrideCss],
44
52
  "data-separator": true,
45
53
  "data-smart-element-date-time": true,
46
54
  "data-testid": testId
@@ -83,11 +83,19 @@ const renderImageIcon = (defaultIcon, icon, url, testId) => {
83
83
  });
84
84
  }
85
85
  };
86
+ /**
87
+ * An element that displays an Icon or favicon.
88
+ * @public
89
+ * @param {IconProps} IconProps - The props necessary for the Icon element.
90
+ * @see LinkIcon
91
+ */
92
+
86
93
 
87
94
  const Icon = ({
88
95
  icon,
89
96
  label = 'Link',
90
97
  position = SmartLinkPosition.Top,
98
+ overrideCss,
91
99
  render,
92
100
  size = SmartLinkSize.Medium,
93
101
  testId = 'smart-element-icon',
@@ -101,7 +109,7 @@ const Icon = ({
101
109
  const styles = getIconStyles(size, position, width);
102
110
  const renderStyles = render ? getCustomRenderStyles(width) : undefined;
103
111
  return jsx("div", {
104
- css: [styles, renderStyles],
112
+ css: [styles, renderStyles, overrideCss],
105
113
  "data-fit-to-content": true,
106
114
  "data-smart-element-icon": true,
107
115
  "data-testid": testId
@@ -3,22 +3,118 @@ import { ElementName } from '../../../../constants';
3
3
  // Attention: Keep the export name and element name the same.
4
4
  // This will help reducing the code for mapping elements inside
5
5
  // createElement and renderElementItems
6
+
7
+ /**
8
+ * Creates an AvatarGroup element using the data from AuthorGroup in the Flexible UI Context.
9
+ * @see AvatarGroup
10
+ */
6
11
  export const AuthorGroup = createElement(ElementName.AuthorGroup);
12
+ /**
13
+ * Creates an AvatarGroup element using the data from CollaboratorGroup in the Flexible UI Context.
14
+ * @see AvatarGroup
15
+ */
16
+
7
17
  export const CollaboratorGroup = createElement(ElementName.CollaboratorGroup);
18
+ /**
19
+ * Creates a CommentCount Badge element using the data from CommentCount in the Flexible UI Context.
20
+ * @see Badge
21
+ */
22
+
8
23
  export const CommentCount = createElement(ElementName.CommentCount);
24
+ /**
25
+ * Creates a ViewCount Badge element using the data from ViewCount in the Flexible UI Context.
26
+ * @see Badge
27
+ */
28
+
9
29
  export const ViewCount = createElement(ElementName.ViewCount);
30
+ /**
31
+ * Creates a ReactCount Badge element using the data from ReactCount in the Flexible UI Context.
32
+ * @see Badge
33
+ */
34
+
10
35
  export const ReactCount = createElement(ElementName.ReactCount);
36
+ /**
37
+ * Creates a VoteCount Badge element using the data from VoteCount in the Flexible UI Context.
38
+ * @see Badge
39
+ */
40
+
11
41
  export const VoteCount = createElement(ElementName.VoteCount);
42
+ /**
43
+ * Creates a CreatedBy text element using the data from CreatedBy in the Flexible UI Context.
44
+ * @see Text
45
+ */
46
+
12
47
  export const CreatedBy = createElement(ElementName.CreatedBy);
48
+ /**
49
+ * Creates a CreatedOn DateTime element using the data from CreatedOn in the Flexible UI Context.
50
+ * @see DateTime
51
+ */
52
+
13
53
  export const CreatedOn = createElement(ElementName.CreatedOn);
54
+ /**
55
+ * Creates a LinkIcon Icon element using the data from LinkIcon in the Flexible UI Context.
56
+ * @see Icon
57
+ */
58
+
14
59
  export const LinkIcon = createElement(ElementName.LinkIcon);
60
+ /**
61
+ * Creates a ModifiedBy Text element using the data from ModifiedBy in the Flexible UI Context.
62
+ * @see Text
63
+ */
64
+
15
65
  export const ModifiedBy = createElement(ElementName.ModifiedBy);
66
+ /**
67
+ * Creates a ModifiedOn DateTime element using the data from ModifiedOn in the Flexible UI Context.
68
+ * @see DateTime
69
+ */
70
+
16
71
  export const ModifiedOn = createElement(ElementName.ModifiedOn);
72
+ /**
73
+ * Creates a Preview element using the data from Preview in the Flexible UI Context.
74
+ * @see Preview
75
+ */
76
+
17
77
  export const Preview = createElement(ElementName.Preview);
78
+ /**
79
+ * Creates a Priority Badge element using the data from Priority in the Flexible UI Context.
80
+ * @see Badge
81
+ */
82
+
18
83
  export const Priority = createElement(ElementName.Priority);
84
+ /**
85
+ * Creates a ProgrammingLanguage Badge element using the data from ProgrammingLanguage in the Flexible UI Context.
86
+ * @see Badge
87
+ */
88
+
19
89
  export const ProgrammingLanguage = createElement(ElementName.ProgrammingLanguage);
90
+ /**
91
+ * Creates a Snippet element using the data from Snippet in the Flexible UI Context.
92
+ * @see Text
93
+ */
94
+
20
95
  export const Snippet = createElement(ElementName.Snippet);
96
+ /**
97
+ * Creates a State Lozenge element using the data from State in the Flexible UI Context.
98
+ * @see Lozenge
99
+ */
100
+
21
101
  export const State = createElement(ElementName.State);
102
+ /**
103
+ * Creates a SubscriberCount Badge element using the data from SubscriberCount in the Flexible UI Context.
104
+ * @see Badge
105
+ */
106
+
22
107
  export const SubscriberCount = createElement(ElementName.SubscriberCount);
108
+ /**
109
+ * Creates a Title Link element using the data from Title in the Flexible UI Context.
110
+ * This represents the main link text within the Smart Link.
111
+ * @see Link
112
+ */
113
+
23
114
  export const Title = createElement(ElementName.Title);
115
+ /**
116
+ * Creates a Provider Badge element using the data from Provider in the Flexible UI Context.
117
+ * @see Badge
118
+ */
119
+
24
120
  export const Provider = createElement(ElementName.Provider);
@@ -14,6 +14,7 @@ const containerStyles = css`
14
14
 
15
15
  const getThemeStyles = theme => {
16
16
  switch (theme) {
17
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
17
18
  case SmartLinkTheme.Black:
18
19
  return css`
19
20
  color: ${tokens.blackLink};
@@ -63,9 +64,17 @@ const getMaxLines = maxLines => {
63
64
 
64
65
  return maxLines;
65
66
  };
67
+ /**
68
+ * An element that represent.
69
+ * @public
70
+ * @param {LinkProps} LinkProps - The props necessary for the Icon element.
71
+ * @see LinkIcon
72
+ */
73
+
66
74
 
67
75
  const Link = ({
68
76
  maxLines = DEFAULT_MAX_LINES,
77
+ overrideCss,
69
78
  size = SmartLinkSize.Medium,
70
79
  testId = 'smart-element-link',
71
80
  text,
@@ -80,7 +89,7 @@ const Link = ({
80
89
  testId: `${testId}-tooltip`,
81
90
  tag: "span"
82
91
  }, jsx("a", {
83
- css: getAnchorStyles(size, theme, getMaxLines(maxLines)),
92
+ css: [getAnchorStyles(size, theme, getMaxLines(maxLines)), overrideCss],
84
93
  "data-smart-element-link": true,
85
94
  "data-testid": testId,
86
95
  onClick: onClick,
@@ -5,9 +5,16 @@ import AtlaskitLozenge from '@atlaskit/lozenge';
5
5
  const styles = css`
6
6
  line-height: inherit;
7
7
  `;
8
+ /**
9
+ * An element that displays a Lozenge.
10
+ * @public
11
+ * @param {LozengeProps} LozengeProps - The props necessary for the Lozenge element.
12
+ * @see State
13
+ */
8
14
 
9
15
  const Lozenge = ({
10
16
  appearance = 'default',
17
+ overrideCss,
11
18
  text,
12
19
  testId = 'smart-element-lozenge'
13
20
  }) => {
@@ -16,12 +23,13 @@ const Lozenge = ({
16
23
  }
17
24
 
18
25
  return jsx("span", {
19
- css: styles,
26
+ css: [styles, overrideCss],
20
27
  "data-fit-to-content": true,
21
- "data-smart-element-lozenge": true
28
+ "data-smart-element-lozenge": true,
29
+ "data-testid": testId
22
30
  }, jsx(AtlaskitLozenge, {
23
31
  appearance: appearance,
24
- testId: testId
32
+ testId: `${testId}-lozenge`
25
33
  }, text));
26
34
  };
27
35
 
@@ -45,8 +45,15 @@ const styles = css`
45
45
  }
46
46
  }
47
47
  `;
48
+ /**
49
+ * An element that displays a Media.
50
+ * @public
51
+ * @param {MediaProps} MediaProps - The props necessary for the Media element.
52
+ * @see Preview
53
+ */
48
54
 
49
55
  const Media = ({
56
+ overrideCss,
50
57
  testId = 'smart-element-media',
51
58
  type,
52
59
  url
@@ -56,7 +63,7 @@ const Media = ({
56
63
  }
57
64
 
58
65
  return jsx("div", {
59
- css: styles,
66
+ css: [styles, overrideCss],
60
67
  "data-smart-element-media": true,
61
68
  "data-testid": testId
62
69
  }, jsx(ImageIcon, {
@@ -4,18 +4,25 @@ import { css, jsx } from '@emotion/core';
4
4
  import { getFormattedMessage, getTruncateStyles } from '../../utils';
5
5
  import { tokens } from '../../../../../utils/token';
6
6
 
7
- const getStyles = (maxLines, color) => css`
8
- color: ${color};
7
+ const getStyles = maxLines => css`
8
+ color: ${tokens.text};
9
9
  font-size: 0.75rem;
10
10
  line-height: 1rem;
11
11
  ${getTruncateStyles(maxLines)}
12
12
  `;
13
+ /**
14
+ * An element that displays some Text.
15
+ * @public
16
+ * @param {TextProps} TextProps - The props necessary for the Text element.
17
+ * @see Title
18
+ */
19
+
13
20
 
14
21
  const Text = ({
15
- color = tokens.text,
16
22
  content,
17
23
  maxLines = 1,
18
24
  message,
25
+ overrideCss,
19
26
  testId = 'smart-element-text'
20
27
  }) => {
21
28
  if (!message && !content) {
@@ -23,7 +30,7 @@ const Text = ({
23
30
  }
24
31
 
25
32
  return jsx("span", {
26
- css: getStyles(maxLines, color),
33
+ css: [getStyles(maxLines), overrideCss],
27
34
  "data-separator": true,
28
35
  "data-smart-element-text": true,
29
36
  "data-testid": testId
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useContext } from 'react';
3
+ import { css } from '@emotion/core';
3
4
  import { ElementName, IconType } from '../../../../constants';
4
5
  import Icon from './icon';
5
6
  import Link from './link';
@@ -68,8 +69,10 @@ const elementMappings = {
68
69
  [ElementName.Snippet]: {
69
70
  component: Text,
70
71
  props: {
71
- color: tokens.snippet,
72
- maxLines: SNIPPET_DEFAULT_MAX_LINES
72
+ maxLines: SNIPPET_DEFAULT_MAX_LINES,
73
+ overrideCss: css`
74
+ color: ${tokens.snippet};
75
+ `
73
76
  }
74
77
  },
75
78
  [ElementName.State]: {
@@ -3,6 +3,12 @@ import React from 'react';
3
3
  import Container from './components/container';
4
4
  import { FlexibleUiContext } from '../../state/flexible-ui-context';
5
5
  import { getContextByStatus, getRetryOptions } from './utils';
6
+ /**
7
+ * This represents a Flexible Card: a link represented by a card with metadata.
8
+ * This is the container in which all Flexible UI Blocks and Elements exist.
9
+ * Note: TitleBlock is mandatory for a Flexible Card to render.
10
+ * @see Container
11
+ */
6
12
 
7
13
  const FlexibleCard = ({
8
14
  cardState,
@@ -10,34 +10,58 @@ import { SmartLinkSize, ActionName } from '../../constants';
10
10
  import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
11
11
  import { HoverCardContainer } from './styled';
12
12
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
13
- export const HoverCard = ({
13
+ import { withAnalyticsEvents, withAnalyticsContext } from '@atlaskit/analytics-next';
14
+ import { fireSmartLinkEvent } from '../../utils/analytics';
15
+ import { useSmartCardState as useLinkState } from '../../state/store';
16
+ import { useSmartLinkAnalytics } from '../../state/analytics';
17
+ import { getExtensionKey, getDefinitionId } from '../../state/helpers';
18
+ export const HoverCardComponent = ({
14
19
  children,
15
- url
20
+ url,
21
+ createAnalyticsEvent
16
22
  }) => {
23
+ const analyticsHandler = useCallback(analyticsPayload => {
24
+ fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
25
+ }, [createAnalyticsEvent]);
17
26
  const delay = 300;
18
27
  const [isOpen, setIsOpen] = React.useState(false);
19
28
  const fadeOutTimeoutId = useRef();
20
29
  const fadeInTimeoutId = useRef();
30
+ const cardOpenTime = useRef();
31
+ const linkState = useLinkState(url);
32
+ const analytics = useSmartLinkAnalytics(analyticsHandler);
33
+ const extensionKey = useMemo(() => getExtensionKey(linkState.details), [linkState]);
34
+ const definitionId = useMemo(() => getDefinitionId(linkState.details), [linkState]);
21
35
  const initHideCard = useCallback(() => {
22
36
  if (fadeInTimeoutId.current) {
23
37
  clearTimeout(fadeInTimeoutId.current);
24
38
  }
25
39
 
26
40
  fadeOutTimeoutId.current = setTimeout(() => {
41
+ //Check its previously open to avoid firing events when moving between the child and hover card components
42
+ if (isOpen === true && cardOpenTime.current) {
43
+ const hoverTime = Date.now() - cardOpenTime.current;
44
+ analytics.ui.hoverCardDismissedEvent('card', hoverTime, definitionId, extensionKey);
45
+ }
46
+
27
47
  setIsOpen(false);
28
48
  }, delay);
29
- }, [delay]);
49
+ }, [delay, isOpen, definitionId, extensionKey, analytics]);
30
50
  const initShowCard = useCallback(() => {
31
51
  if (fadeOutTimeoutId.current) {
32
52
  clearTimeout(fadeOutTimeoutId.current);
33
53
  }
34
54
 
35
55
  fadeInTimeoutId.current = setTimeout(() => {
56
+ //Check if its previously closed to avoid firing events when moving between the child and hover card components
57
+ if (isOpen === false) {
58
+ cardOpenTime.current = Date.now();
59
+ analytics.ui.hoverCardViewedEvent('card', definitionId, extensionKey);
60
+ }
61
+
36
62
  setIsOpen(true);
37
63
  }, delay);
38
- }, [delay]); //TODO: EDM-2905: Add analytics events
39
-
40
- const analyticsHandler = useCallback(() => {}, []);
64
+ }, [delay, isOpen, definitionId, extensionKey, analytics]);
41
65
  const linkActions = useSmartLinkActions({
42
66
  url,
43
67
  appearance: 'block',
@@ -57,10 +81,13 @@ export const HoverCard = ({
57
81
  size: "medium"
58
82
  }),
59
83
  iconPosition: 'before',
60
- onClick: () => window.open(url, '_blank'),
84
+ onClick: () => {
85
+ window.open(url, '_blank');
86
+ analytics.ui.hoverCardOpenLinkClickedEvent('card', definitionId, extensionKey);
87
+ },
61
88
  testId: 'hover-card-open-button'
62
89
  };
63
- }, [url]);
90
+ }, [url, definitionId, extensionKey, analytics]);
64
91
 
65
92
  const cardComponent = () => jsx("div", {
66
93
  onMouseEnter: initShowCard,
@@ -84,11 +111,14 @@ export const HoverCard = ({
84
111
  testId: "hover-card",
85
112
  isOpen: isOpen,
86
113
  onClose: onClose,
87
- placement: "bottom",
114
+ placement: "bottom-start",
88
115
  content: cardComponent,
89
116
  trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
90
117
  onMouseEnter: initShowCard,
91
118
  onMouseLeave: initHideCard
92
119
  }), children)
93
120
  });
94
- };
121
+ };
122
+ export const HoverCard = withAnalyticsContext({
123
+ source: 'smartLinkPreviewHoverCard'
124
+ })(withAnalyticsEvents()(HoverCardComponent));
@@ -1,7 +1,12 @@
1
1
  import { css } from '@emotion/core';
2
+ import { loadingPlaceholderClassName } from '../../index';
2
3
  export const HoverCardContainer = css`
3
4
  background: none;
4
5
  border-width: 0;
5
- max-width: 500px;
6
+ max-width: 350px;
6
7
  padding: 0;
8
+
9
+ .${loadingPlaceholderClassName} {
10
+ display: none;
11
+ }
7
12
  `;
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { R300 } from '@atlaskit/theme/colors';
4
+ import { token } from '@atlaskit/tokens';
4
5
  import ErrorIcon from '@atlaskit/icon/glyph/error';
5
6
  import Button from '@atlaskit/button/custom-theme-button';
6
7
  import { Frame } from '../Frame';
@@ -61,7 +62,7 @@ export class InlineCardErroredView extends React.Component {
61
62
  icon: icon || /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(ErrorIcon, {
62
63
  label: "error",
63
64
  size: "small",
64
- primaryColor: R300
65
+ primaryColor: token('color.icon.danger', R300)
65
66
  })),
66
67
  title: this.renderMessage()
67
68
  }));
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React from 'react';
4
4
  import { R400, N500 } from '@atlaskit/theme/colors';
5
+ import { token } from '@atlaskit/tokens';
5
6
  import LockIcon from '@atlaskit/icon/glyph/lock-filled';
6
7
  import Button from '@atlaskit/button/custom-theme-button';
7
8
  import { Frame } from '../Frame';
@@ -13,7 +14,7 @@ import { IconStyledButton, LowercaseAppearance, LinkAppearance } from '../styled
13
14
  const FallbackForbiddenIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
14
15
  label: "error",
15
16
  size: "small",
16
- primaryColor: R400
17
+ primaryColor: token('color.icon.danger', R400)
17
18
  }));
18
19
  export class InlineCardForbiddenView extends React.Component {
19
20
  constructor(...args) {
@@ -91,7 +92,7 @@ export class InlineCardForbiddenView extends React.Component {
91
92
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
92
93
  icon: icon ? icon : FallbackForbiddenIcon,
93
94
  title: this.renderMessage(),
94
- titleColor: N500
95
+ titleColor: token('color.text.subtle', N500)
95
96
  }));
96
97
  }
97
98