@automattic/jetpack-components 0.39.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 (235) hide show
  1. package/.gitattributes +8 -0
  2. package/CHANGELOG.md +747 -0
  3. package/LICENSE.txt +357 -0
  4. package/README.md +11 -0
  5. package/SECURITY.md +38 -0
  6. package/components/action-button/index.jsx +70 -0
  7. package/components/action-button/stories/index.stories.jsx +38 -0
  8. package/components/action-button/style.module.scss +11 -0
  9. package/components/action-button/test/component.jsx +16 -0
  10. package/components/action-popover/index.tsx +105 -0
  11. package/components/action-popover/stories/index.stories.jsx +115 -0
  12. package/components/action-popover/stories/styles.module.scss +7 -0
  13. package/components/action-popover/styles.module.scss +49 -0
  14. package/components/action-popover/types.ts +20 -0
  15. package/components/admin-page/index.tsx +58 -0
  16. package/components/admin-page/stories/index.stories.tsx +35 -0
  17. package/components/admin-page/stories/style.module.scss +13 -0
  18. package/components/admin-page/style.module.scss +11 -0
  19. package/components/admin-page/types.ts +41 -0
  20. package/components/admin-section/basic/index.tsx +15 -0
  21. package/components/admin-section/basic/style.module.scss +3 -0
  22. package/components/admin-section/hero/index.tsx +15 -0
  23. package/components/admin-section/hero/style.module.scss +3 -0
  24. package/components/admin-section/stories/index.stories.tsx +60 -0
  25. package/components/admin-section/types.ts +6 -0
  26. package/components/alert/index.tsx +61 -0
  27. package/components/alert/stories/index.stories.jsx +24 -0
  28. package/components/alert/style.module.scss +43 -0
  29. package/components/automattic-byline-logo/README.md +16 -0
  30. package/components/automattic-byline-logo/index.tsx +38 -0
  31. package/components/automattic-byline-logo/stories/index.stories.tsx +20 -0
  32. package/components/automattic-byline-logo/test/component.tsx +28 -0
  33. package/components/automattic-byline-logo/types.ts +18 -0
  34. package/components/boost-score-bar/index.tsx +103 -0
  35. package/components/boost-score-bar/stories/index.stories.tsx +39 -0
  36. package/components/boost-score-bar/style.scss +184 -0
  37. package/components/boost-score-bar/test/component.tsx +102 -0
  38. package/components/boost-score-bar/types.ts +9 -0
  39. package/components/button/index.tsx +84 -0
  40. package/components/button/stories/index.mdx +90 -0
  41. package/components/button/stories/index.stories.tsx +400 -0
  42. package/components/button/stories/style.module.scss +20 -0
  43. package/components/button/style.module.scss +212 -0
  44. package/components/button/types.ts +21 -0
  45. package/components/contextual-upgrade-trigger/README.md +81 -0
  46. package/components/contextual-upgrade-trigger/index.tsx +44 -0
  47. package/components/contextual-upgrade-trigger/stories/index.stories.tsx +25 -0
  48. package/components/contextual-upgrade-trigger/style.module.scss +75 -0
  49. package/components/contextual-upgrade-trigger/types.ts +9 -0
  50. package/components/decorative-card/index.tsx +44 -0
  51. package/components/decorative-card/stories/index.stories.tsx +18 -0
  52. package/components/decorative-card/style.scss +116 -0
  53. package/components/decorative-card/types.ts +16 -0
  54. package/components/dialog/index.tsx +69 -0
  55. package/components/dialog/stories/boost.png +0 -0
  56. package/components/dialog/stories/declaration.d.ts +1 -0
  57. package/components/dialog/stories/index.stories.tsx +118 -0
  58. package/components/dialog/stories/js-components.components.dialog.mdx +62 -0
  59. package/components/dialog/stories/js-components.components.dialog.stories.js +37 -0
  60. package/components/dialog/stories/style.module.scss +21 -0
  61. package/components/dialog/style.module.scss +30 -0
  62. package/components/donut-meter/index.tsx +147 -0
  63. package/components/donut-meter/stories/index.stories.tsx +51 -0
  64. package/components/donut-meter/style.scss +11 -0
  65. package/components/donut-meter/test/component.tsx +24 -0
  66. package/components/gridicon/index.tsx +298 -0
  67. package/components/gridicon/stories/index.stories.tsx +18 -0
  68. package/components/gridicon/style.scss +16 -0
  69. package/components/gridicon/types.ts +48 -0
  70. package/components/icon-tooltip/index.tsx +96 -0
  71. package/components/icon-tooltip/stories/index.stories.tsx +108 -0
  72. package/components/icon-tooltip/stories/style.scss +36 -0
  73. package/components/icon-tooltip/style.scss +121 -0
  74. package/components/icon-tooltip/test/component.tsx +15 -0
  75. package/components/icon-tooltip/types.ts +76 -0
  76. package/components/icons/README.md +98 -0
  77. package/components/icons/index.tsx +369 -0
  78. package/components/icons/stories/index.stories.tsx +65 -0
  79. package/components/icons/stories/style.module.scss +33 -0
  80. package/components/icons/style.module.scss +40 -0
  81. package/components/icons/types.ts +38 -0
  82. package/components/indeterminate-progress-bar/index.tsx +28 -0
  83. package/components/indeterminate-progress-bar/stories/index.stories.tsx +14 -0
  84. package/components/indeterminate-progress-bar/style.module.scss +34 -0
  85. package/components/indeterminate-progress-bar/types.ts +6 -0
  86. package/components/jetpack-footer/README.md +21 -0
  87. package/components/jetpack-footer/index.tsx +94 -0
  88. package/components/jetpack-footer/stories/index.stories.tsx +40 -0
  89. package/components/jetpack-footer/style.scss +116 -0
  90. package/components/jetpack-footer/test/component.tsx +45 -0
  91. package/components/jetpack-footer/types.ts +36 -0
  92. package/components/jetpack-logo/README.md +20 -0
  93. package/components/jetpack-logo/index.tsx +46 -0
  94. package/components/jetpack-logo/stories/index.stories.tsx +20 -0
  95. package/components/jetpack-logo/test/component.tsx +16 -0
  96. package/components/jetpack-logo/types.ts +7 -0
  97. package/components/jetpack-search-logo/README.md +20 -0
  98. package/components/jetpack-search-logo/index.tsx +93 -0
  99. package/components/jetpack-search-logo/stories/index.stories.tsx +21 -0
  100. package/components/jetpack-search-logo/test/component.tsx +16 -0
  101. package/components/jetpack-search-logo/types.ts +7 -0
  102. package/components/jetpack-vaultpress-backup-logo/README.md +19 -0
  103. package/components/jetpack-vaultpress-backup-logo/index.tsx +113 -0
  104. package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +20 -0
  105. package/components/jetpack-vaultpress-backup-logo/test/component.tsx +18 -0
  106. package/components/jetpack-vaultpress-backup-logo/types.ts +6 -0
  107. package/components/jetpack-videopress-logo/README.md +19 -0
  108. package/components/jetpack-videopress-logo/index.tsx +93 -0
  109. package/components/jetpack-videopress-logo/stories/index.stories.tsx +20 -0
  110. package/components/jetpack-videopress-logo/test/component.tsx +16 -0
  111. package/components/jetpack-videopress-logo/types.tsx +6 -0
  112. package/components/layout/README.md +9 -0
  113. package/components/layout/breakpoints.module.scss +20 -0
  114. package/components/layout/col/README.md +81 -0
  115. package/components/layout/col/index.tsx +49 -0
  116. package/components/layout/col/style.module.scss +28 -0
  117. package/components/layout/container/README.md +77 -0
  118. package/components/layout/container/index.tsx +42 -0
  119. package/components/layout/container/style.module.scss +35 -0
  120. package/components/layout/stories/index.stories.tsx +145 -0
  121. package/components/layout/stories/styles.module.scss +22 -0
  122. package/components/layout/types.ts +55 -0
  123. package/components/layout/use-breakpoint-match/README.md +43 -0
  124. package/components/layout/use-breakpoint-match/declaration.d.ts +9 -0
  125. package/components/layout/use-breakpoint-match/index.ts +79 -0
  126. package/components/loading-placeholder/README.md +22 -0
  127. package/components/loading-placeholder/index.tsx +23 -0
  128. package/components/loading-placeholder/stories/index.stories.tsx +78 -0
  129. package/components/loading-placeholder/style.module.scss +18 -0
  130. package/components/notice/index.tsx +98 -0
  131. package/components/notice/stories/index.stories.jsx +90 -0
  132. package/components/notice/style.module.scss +107 -0
  133. package/components/number-format/README.md +25 -0
  134. package/components/number-format/index.ts +16 -0
  135. package/components/pricing-card/index.tsx +127 -0
  136. package/components/pricing-card/stories/index.stories.tsx +55 -0
  137. package/components/pricing-card/style.scss +112 -0
  138. package/components/pricing-card/test/component.tsx +89 -0
  139. package/components/pricing-card/types.ts +52 -0
  140. package/components/pricing-slider/index.tsx +53 -0
  141. package/components/pricing-slider/stories/index.stories.tsx +44 -0
  142. package/components/pricing-slider/style.scss +55 -0
  143. package/components/pricing-slider/test/component.tsx +14 -0
  144. package/components/pricing-slider/types.ts +58 -0
  145. package/components/pricing-table/index.tsx +200 -0
  146. package/components/pricing-table/stories/index.stories.tsx +74 -0
  147. package/components/pricing-table/styles.module.scss +160 -0
  148. package/components/pricing-table/test/component.tsx +41 -0
  149. package/components/pricing-table/types.ts +84 -0
  150. package/components/product-offer/icons-card.tsx +47 -0
  151. package/components/product-offer/index.tsx +115 -0
  152. package/components/product-offer/product-offer-header.tsx +23 -0
  153. package/components/product-offer/stories/index.stories.tsx +104 -0
  154. package/components/product-offer/style.module.scss +93 -0
  155. package/components/product-offer/types.ts +125 -0
  156. package/components/product-price/index.tsx +90 -0
  157. package/components/product-price/price.tsx +35 -0
  158. package/components/product-price/stories/index.stories.tsx +33 -0
  159. package/components/product-price/style.module.scss +69 -0
  160. package/components/product-price/test/component.tsx +26 -0
  161. package/components/product-price/types.ts +73 -0
  162. package/components/qr-code/Readme.md +5 -0
  163. package/components/qr-code/index.tsx +78 -0
  164. package/components/qr-code/stories/index.stories.tsx +32 -0
  165. package/components/record-meter-bar/index.tsx +135 -0
  166. package/components/record-meter-bar/stories/index.stories.tsx +39 -0
  167. package/components/record-meter-bar/style.scss +38 -0
  168. package/components/record-meter-bar/test/component.tsx +52 -0
  169. package/components/spinner/README.md +28 -0
  170. package/components/spinner/index.jsx +45 -0
  171. package/components/spinner/stories/index.stories.jsx +20 -0
  172. package/components/spinner/style.scss +31 -0
  173. package/components/spinner/test/component.jsx +17 -0
  174. package/components/split-button/index.tsx +39 -0
  175. package/components/split-button/stories/index.stories.tsx +35 -0
  176. package/components/split-button/style.module.scss +21 -0
  177. package/components/split-button/types.ts +14 -0
  178. package/components/stat-card/index.tsx +49 -0
  179. package/components/stat-card/stories/index.mdx +35 -0
  180. package/components/stat-card/stories/index.stories.tsx +41 -0
  181. package/components/stat-card/style.module.scss +49 -0
  182. package/components/stat-card/test/component.tsx +24 -0
  183. package/components/stat-card/types.ts +28 -0
  184. package/components/status/README.md +42 -0
  185. package/components/status/index.tsx +40 -0
  186. package/components/status/stories/index.stories.tsx +44 -0
  187. package/components/status/style.module.scss +72 -0
  188. package/components/terms-of-service/index.tsx +63 -0
  189. package/components/terms-of-service/styles.scss +10 -0
  190. package/components/terms-of-service/test/index.test.jsx +52 -0
  191. package/components/terms-of-service/types.ts +30 -0
  192. package/components/testimonials/index.tsx +58 -0
  193. package/components/testimonials/style.scss +127 -0
  194. package/components/testimonials/test/component.tsx +103 -0
  195. package/components/testimonials/testimonial.tsx +47 -0
  196. package/components/testimonials/types.ts +17 -0
  197. package/components/text/constants.ts +30 -0
  198. package/components/text/index.tsx +91 -0
  199. package/components/text/stories/headings.index.stories.tsx +80 -0
  200. package/components/text/stories/index.mdx +195 -0
  201. package/components/text/stories/index.stories.tsx +69 -0
  202. package/components/text/stories/style.module.scss +64 -0
  203. package/components/text/stories/title.index.stories.tsx +34 -0
  204. package/components/text/style.module.scss +125 -0
  205. package/components/text/types.ts +53 -0
  206. package/components/theme-provider/Readme.md +49 -0
  207. package/components/theme-provider/globals.module.scss +6 -0
  208. package/components/theme-provider/index.tsx +151 -0
  209. package/components/theme-provider/stories/index.stories.tsx +164 -0
  210. package/components/theme-provider/stories/style.module.scss +79 -0
  211. package/components/theme-provider/types.ts +25 -0
  212. package/components/toggle-control/README.md +5 -0
  213. package/components/toggle-control/index.tsx +67 -0
  214. package/components/toggle-control/stories/index.stories.tsx +83 -0
  215. package/components/toggle-control/styles.module.scss +41 -0
  216. package/components/zendesk-chat/README.md +26 -0
  217. package/components/zendesk-chat/constants.ts +2 -0
  218. package/components/zendesk-chat/index.tsx +22 -0
  219. package/components/zendesk-chat/stories/index.stories.tsx +15 -0
  220. package/components/zendesk-chat/test/component.tsx +16 -0
  221. package/components/zendesk-chat/types.ts +3 -0
  222. package/index.ts +69 -0
  223. package/lib/locale/index.ts +48 -0
  224. package/lib/locale/test/index.ts +21 -0
  225. package/package.json +80 -0
  226. package/tools/get-product-checkout-url/Readme.md +32 -0
  227. package/tools/get-product-checkout-url/index.ts +31 -0
  228. package/tools/jp-redirect/README.md +61 -0
  229. package/tools/jp-redirect/index.ts +62 -0
  230. package/tools/jp-redirect/test/index.tsx +89 -0
  231. package/tools/jp-redirect/types.ts +49 -0
  232. package/tools/pricing-utils/README.md +16 -0
  233. package/tools/pricing-utils/index.ts +11 -0
  234. package/tools/pricing-utils/test/index.ts +39 -0
  235. package/tools/pricing-utils/types.ts +12 -0
@@ -0,0 +1,48 @@
1
+ import type { CSSProperties } from 'react';
2
+
3
+ export type GridiconProps = {
4
+ /**
5
+ * Icon name
6
+ */
7
+ icon: string;
8
+
9
+ /**
10
+ * HTML class name
11
+ */
12
+ className?: string;
13
+
14
+ /**
15
+ * Description for SVG for screen readers
16
+ */
17
+ description?: string;
18
+
19
+ /**
20
+ * Whether SVG is focussable
21
+ */
22
+ focusable?: boolean;
23
+
24
+ /**
25
+ * SVG height
26
+ */
27
+ height?: number;
28
+
29
+ /**
30
+ * Click handler
31
+ */
32
+ onClick?: VoidFunction;
33
+
34
+ /**
35
+ * SVG width and height
36
+ */
37
+ size?: number;
38
+
39
+ /**
40
+ * SVG style
41
+ */
42
+ style?: CSSProperties;
43
+
44
+ /**
45
+ * SVG width
46
+ */
47
+ width?: number;
48
+ };
@@ -0,0 +1,96 @@
1
+ import { Popover } from '@wordpress/components';
2
+ import classNames from 'classnames';
3
+ import React, { useCallback, useState } from 'react';
4
+ import Button from '../button';
5
+ import Gridicon from '../gridicon/index';
6
+ import { IconTooltipProps, Placement, Position } from './types';
7
+
8
+ import './style.scss';
9
+
10
+ const placementsToPositions = ( placement: Placement ): Position => {
11
+ const mapping = {
12
+ 'top-end': 'top left',
13
+ top: 'top center',
14
+ 'top-start': 'top right',
15
+ 'bottom-end': 'bottom left',
16
+ bottom: 'bottom center',
17
+ 'bottom-start': 'bottom right',
18
+ };
19
+
20
+ return mapping[ placement ] as Position;
21
+ };
22
+
23
+ /**
24
+ * Generate Icon Tooltip
25
+ *
26
+ * @param {IconTooltipProps} props - Props
27
+ * @returns {React.ReactElement} - JSX element
28
+ */
29
+ const IconTooltip: React.FC< IconTooltipProps > = ( {
30
+ className = '',
31
+ iconClassName = '',
32
+ placement = 'bottom-end',
33
+ animate = true,
34
+ iconCode = 'info-outline',
35
+ iconSize = 18,
36
+ offset = 10,
37
+ title,
38
+ children,
39
+ popoverAnchorStyle = 'icon',
40
+ forceShow = false,
41
+ wide = false,
42
+ } ) => {
43
+ const POPOVER_HELPER_WIDTH = 124;
44
+ const [ isVisible, setIsVisible ] = useState( false );
45
+ const showTooltip = useCallback( () => setIsVisible( true ), [ setIsVisible ] );
46
+ const hideTooltip = useCallback( () => setIsVisible( false ), [ setIsVisible ] );
47
+
48
+ const args = {
49
+ // To be compatible with deprecating prop `position`.
50
+ position: placementsToPositions( placement ),
51
+ placement,
52
+ animate,
53
+ noArrow: false,
54
+ resize: false,
55
+ flip: false,
56
+ offset, // The distance (in px) between the anchor and the popover.
57
+ focusOnMount: 'container' as const,
58
+ onClose: hideTooltip,
59
+ className: 'icon-tooltip-container',
60
+ };
61
+
62
+ const isAnchorWrapper = popoverAnchorStyle === 'wrapper';
63
+
64
+ const wrapperClassNames = classNames( 'icon-tooltip-wrapper', className );
65
+ const iconShiftBySize = {
66
+ left: isAnchorWrapper ? 0 : -( POPOVER_HELPER_WIDTH / 2 - iconSize / 2 ) + 'px',
67
+ };
68
+
69
+ const isForcedToShow = isAnchorWrapper && forceShow;
70
+
71
+ return (
72
+ <div className={ wrapperClassNames } data-testid="icon-tooltip_wrapper">
73
+ { ! isAnchorWrapper && (
74
+ <Button variant="link" onClick={ showTooltip }>
75
+ <Gridicon className={ iconClassName } icon={ iconCode } size={ iconSize } />
76
+ </Button>
77
+ ) }
78
+
79
+ <div
80
+ className={ classNames( 'icon-tooltip-helper', { 'is-wide': wide } ) }
81
+ style={ iconShiftBySize }
82
+ >
83
+ { ( isForcedToShow || isVisible ) && (
84
+ <Popover { ...args }>
85
+ <div>
86
+ { title && <div className="icon-tooltip-title">{ title }</div> }
87
+ <div className="icon-tooltip-content">{ children }</div>
88
+ </div>
89
+ </Popover>
90
+ ) }
91
+ </div>
92
+ </div>
93
+ );
94
+ };
95
+
96
+ export default IconTooltip;
@@ -0,0 +1,108 @@
1
+ import IconTooltip from '../index';
2
+ import './style.scss';
3
+ import type { Placement } from '../types';
4
+
5
+ const AVAILABLE_PLACEMENTS: Placement[] = [
6
+ 'top',
7
+ 'top-start',
8
+ 'top-end',
9
+ 'bottom',
10
+ 'bottom-start',
11
+ 'bottom-end',
12
+ ];
13
+
14
+ export default {
15
+ title: 'JS Packages/Components/IconTooltip',
16
+ component: IconTooltip,
17
+ argTypes: {
18
+ className: {
19
+ control: { type: 'text' },
20
+ },
21
+ iconClassName: {
22
+ control: { type: 'text' },
23
+ },
24
+ placement: {
25
+ control: { type: 'select' },
26
+ options: AVAILABLE_PLACEMENTS,
27
+ },
28
+ animate: {
29
+ control: { type: 'boolean' },
30
+ },
31
+ iconCode: {
32
+ control: { type: 'text' },
33
+ },
34
+ iconSize: {
35
+ control: { type: 'number' },
36
+ },
37
+ offset: {
38
+ control: { type: 'number' },
39
+ },
40
+ title: {
41
+ control: { type: 'text' },
42
+ },
43
+ children: {
44
+ control: { type: null },
45
+ },
46
+ wide: {
47
+ control: { type: 'boolean' },
48
+ },
49
+ },
50
+ };
51
+
52
+ const Template = args => (
53
+ <div style={ { position: 'absolute', height: '1000px', left: '300px', top: '200px' } }>
54
+ <IconTooltip { ...args } />
55
+ </div>
56
+ );
57
+
58
+ const WrapperAnchorTemplate = args => (
59
+ <div style={ { position: 'absolute', height: '1000px', left: '300px', top: '300px' } }>
60
+ <div className="tooltip-wrapper">
61
+ <div className="tooltip-wrapper-anchor">
62
+ <IconTooltip { ...args }>
63
+ <>
64
+ <div>Thank you for upgrading! Now your visitors can search up to 500 records.</div>
65
+ <div className="tooltip-actions">
66
+ <span>1 of 2</span>
67
+ </div>
68
+ </>
69
+ </IconTooltip>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ );
74
+
75
+ // Export Default story
76
+ export const _default = Template.bind( {} );
77
+
78
+ export const HasContent = Template.bind( {} );
79
+ HasContent.args = {
80
+ title: 'This is title!',
81
+ children: (
82
+ <div>
83
+ This is children block!<br></br>
84
+ <br></br>Break Line!
85
+ <br></br>
86
+ <ul>
87
+ <li>Item 1</li>
88
+ <li>Item 2</li>
89
+ </ul>
90
+ </div>
91
+ ),
92
+ };
93
+
94
+ export const WrapperAnchor = WrapperAnchorTemplate.bind( {} );
95
+ WrapperAnchor.args = {
96
+ popoverAnchorStyle: 'wrapper',
97
+ title: 'Site records increased',
98
+ placement: 'top',
99
+ forceShow: true,
100
+ };
101
+
102
+ export const Wide = Template.bind( {} );
103
+ Wide.args = {
104
+ title: 'This is title!',
105
+ children: <div>This is a wide tooltip!</div>,
106
+ wide: true,
107
+ placement: 'bottom-start',
108
+ };
@@ -0,0 +1,36 @@
1
+ .tooltip-wrapper-anchor {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ width: 64px;
6
+ height: 64px;
7
+
8
+ .icon-tooltip-wrapper {
9
+ width: 100%;
10
+ height: 100%;
11
+
12
+ // To overwrite `margin-bottom`
13
+ .icon-tooltip-title {
14
+ font-size: var( --font-title-small );
15
+ font-weight: 500;
16
+ margin-bottom: 16px;
17
+ }
18
+ }
19
+
20
+ .icon-tooltip-helper {
21
+ width: 100%;
22
+ height: 100%;
23
+ }
24
+
25
+ .icon-tooltip-content {
26
+ font-size: var( --font-body );
27
+ }
28
+
29
+ .tooltip-actions {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+ color: var( --jp-gray-60 );
34
+ margin-top: 24px;
35
+ }
36
+ }
@@ -0,0 +1,121 @@
1
+ @import '@automattic/jetpack-base-styles/style';
2
+
3
+ $arrow-color: var( --jp-gray );
4
+
5
+ // Fix arrow color
6
+ .components-popover:not(.is-without-arrow)::before {
7
+ border-color: $arrow-color;
8
+ }
9
+
10
+ // Namespace to avoid overriding global styles
11
+ .icon-tooltip-helper {
12
+ /*
13
+ * Fix arrow placement - section start
14
+ */
15
+ .components-popover:not([data-y-axis=middle])[data-x-axis=left] .components-popover__content {
16
+ margin-right: -62px;
17
+ }
18
+
19
+ .components-popover:not([data-y-axis=middle])[data-x-axis=right] .components-popover__content {
20
+ margin-left: -62px;
21
+ }
22
+ /*
23
+ * Fix arrow placement - section end
24
+ */
25
+
26
+ /*
27
+ * Fix arrow position for legacy position option - section start
28
+ */
29
+ .components-popover[data-y-axis=bottom] .components-popover__content {
30
+ top: 2px !important;
31
+ }
32
+
33
+ .components-popover:not(.is-without-arrow)[data-y-axis=bottom]::before {
34
+ top: -6px !important;
35
+ }
36
+
37
+ .components-popover:not(.is-without-arrow)[data-y-axis=bottom]::after {
38
+ top: -4px !important;
39
+ }
40
+
41
+ .components-popover[data-y-axis=top] .components-popover__content {
42
+ bottom: 10px !important;
43
+ }
44
+
45
+ .components-popover:not(.is-without-arrow)[data-y-axis=top]::before {
46
+ bottom: 3px;
47
+ }
48
+
49
+ .components-popover:not(.is-without-arrow)[data-y-axis=top]::after {
50
+ bottom: 4px;
51
+ }
52
+ /*
53
+ * Fix arrow position for legacy position option - section end
54
+ */
55
+
56
+ .components-popover__content {
57
+ padding: 24px;
58
+ width: 304px;
59
+ white-space: normal;
60
+ border-radius: 4px;
61
+ outline: none;
62
+ border: 1px solid $arrow-color;
63
+ }
64
+
65
+ &.is-wide .components-popover__content {
66
+ width: 440px;
67
+ }
68
+ }
69
+
70
+ .icon-tooltip-wrapper {
71
+ display: inline-block;
72
+ position: relative;
73
+ color: var( --jp-black );
74
+
75
+ .components-button.is-link:focus:not(:disabled) {
76
+ box-shadow: none;
77
+ }
78
+ }
79
+
80
+ .icon-tooltip-helper {
81
+ // POPOVER_HELPER_WIDTH
82
+ width: 124px;
83
+ height: 18px;
84
+ position: absolute;
85
+ top: 0;
86
+ // -( POPOVER_HELPER_WIDTH / 2 - iconSize / 2 ) + 'px'
87
+ left: -53px;
88
+ pointer-events: none;
89
+ }
90
+
91
+ .icon-tooltip-container {
92
+ // Recover events
93
+ pointer-events: all;
94
+ }
95
+
96
+ .icon-tooltip-title {
97
+ font-weight: 600;
98
+ font-size: 16px;
99
+ line-height: 19px;
100
+
101
+ &:not(:last-child) {
102
+ margin-bottom: 8px;
103
+ }
104
+ }
105
+
106
+ .icon-tooltip-content {
107
+ font-weight: 400;
108
+ font-size: 14px;
109
+ line-height: 24px;
110
+
111
+ // Allow bulleted lists in tooltips.
112
+ ul {
113
+ margin: 0 0 0 1rem;
114
+ list-style-type: disc;
115
+ }
116
+
117
+ // Remove bottom margin from last list item.
118
+ ul li:last-child {
119
+ margin-bottom: 0;
120
+ }
121
+ }
@@ -0,0 +1,15 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import IconTooltip from '../index';
3
+ import { IconTooltipProps } from '../types';
4
+
5
+ describe( 'IconTooltip', () => {
6
+ const testProps: IconTooltipProps = {
7
+ title: 'Title',
8
+ children: <div>Content block</div>,
9
+ };
10
+
11
+ it( 'renders the icon tooltip', () => {
12
+ render( <IconTooltip { ...testProps } /> );
13
+ expect( screen.getByTestId( 'icon-tooltip_wrapper' ) ).toBeInTheDocument();
14
+ } );
15
+ } );
@@ -0,0 +1,76 @@
1
+ export type Placement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
2
+
3
+ export type Position =
4
+ | 'top left'
5
+ | 'top center'
6
+ | 'top right'
7
+ | 'bottom left'
8
+ | 'bottom center'
9
+ | 'bottom right';
10
+
11
+ export type IconTooltipProps = {
12
+ /**
13
+ * The wrapper class name of this IconTooltip component.
14
+ */
15
+ className?: string;
16
+
17
+ /**
18
+ * The class name applied to Gridicon.
19
+ */
20
+ iconClassName?: string;
21
+
22
+ /**
23
+ * The deprecated position of Popover.
24
+ */
25
+ position?: Position;
26
+
27
+ /**
28
+ * The placement of Popover.
29
+ */
30
+ placement?: Placement;
31
+
32
+ /**
33
+ * The animation for Popover appears.
34
+ */
35
+ animate?: boolean;
36
+
37
+ /**
38
+ * The icon code for Gridicon.
39
+ */
40
+ iconCode?: string;
41
+
42
+ /**
43
+ * The title of Popover.
44
+ */
45
+ title?: string;
46
+
47
+ /**
48
+ * The main body content of Popover.
49
+ */
50
+ children?: React.ReactNode;
51
+
52
+ /**
53
+ * The icon square width and height size (in px) also calculate the Popover shift.
54
+ */
55
+ iconSize?: number;
56
+
57
+ /**
58
+ * The distance (in px) between the anchor and the Popover.
59
+ */
60
+ offset?: number;
61
+
62
+ /**
63
+ * Set the Popover anchor for its alignment with placement.
64
+ */
65
+ popoverAnchorStyle?: 'icon' | 'wrapper';
66
+
67
+ /**
68
+ * Force the Popover to show without an event trigger.
69
+ */
70
+ forceShow?: boolean;
71
+
72
+ /**
73
+ * Uses a wider content area when enabled.
74
+ */
75
+ wide?: boolean;
76
+ };
@@ -0,0 +1,98 @@
1
+ ## Jetpack Icons
2
+
3
+ Exports:
4
+
5
+ ### getIconBySlug( slug )
6
+
7
+ Available slugs are:
8
+
9
+ * anti-spam
10
+ * backup
11
+ * boost
12
+ * crm
13
+ * extras
14
+ * scan
15
+ * search
16
+ * star
17
+ * videopress
18
+ * jetpack
19
+ * facebook
20
+ * twitter
21
+ * linkedin
22
+ * tumblr
23
+ * google
24
+ * mastodon
25
+
26
+ ```es6
27
+ import {
28
+ getIconByslug
29
+ } from '@automattic/jetpack-components';
30
+
31
+ const Icon = getIconBySlug( 'boost' );
32
+ return (
33
+ <div>
34
+ <Icon />
35
+ </div>
36
+ )
37
+ ```
38
+
39
+ #### Icons
40
+
41
+ * AntiSpamIcon
42
+ * BackupIcon
43
+ * BoostIcon
44
+ * CheckmarkIcon
45
+ * CrmIcon
46
+ * ScanIcon
47
+ * SearchIcon
48
+ * StarIcon
49
+ * VideopressIcon
50
+ * JetpackIcon
51
+ * FacebookIcon
52
+ * TwitterIcon
53
+ * LinkedinIcon
54
+ * TumblrIcon
55
+ * GoogleIcon
56
+ * MastodonIcon
57
+
58
+ ```es6
59
+ import {
60
+ AntiSpamIcon,
61
+ BackupIcon,
62
+ BoostIcon,
63
+ CheckmarkIcon,
64
+ CrmIcon,
65
+ ScanIcon,
66
+ SearchIcon,
67
+ StarIcon,
68
+ VideoPressIcon,
69
+ JetpackIcon,
70
+ FacebookIcon,
71
+ TwitterIcon,
72
+ LinkedinIcon,
73
+ TumblrIcon,
74
+ GoogleIcon,
75
+ MastodonIcon
76
+ } from '@automattic/jetpack-components';
77
+
78
+ return (
79
+ <div>
80
+ <AntiSpamIcon />
81
+ <BackupIcon />
82
+ <BoostIcon />
83
+ <CheckmarkIcon />
84
+ <CrmIcon />
85
+ <ScanIcon />
86
+ <SearchIcon />
87
+ <StarIcon />
88
+ <VideoPressIcon />
89
+ <JetpackIcon />
90
+ <FacebookIcon />
91
+ <TwitterIcon />
92
+ <LinkedinIcon />
93
+ <TumblrIcon />
94
+ <GoogleIcon />
95
+ <MastodonIcon />
96
+ </div>
97
+ )
98
+ ```