@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,195 @@
1
+ import { Meta, Source, Story } from '@storybook/addon-docs';
2
+ import dedent from 'ts-dedent';
3
+ import Text, { BOX_MODEL_VALUES, H2, H3, Title } from '../index';
4
+ import * as Stories from './index.stories';
5
+
6
+ <Meta of={Stories} />
7
+
8
+ # Text
9
+ Set of React jetpack-components intended to facilitate when dealing with rendering text content.
10
+
11
+ ## &lt;Text /&gt;
12
+
13
+ `Text` is the primary component that renders text, supporting the following features:
14
+
15
+ * **Typography**: provided by the ThemeProvider component.
16
+ * **Spacing**: A simple range of shorthand classes to modify the text element's margin and padding.
17
+
18
+ ### Props
19
+
20
+ #### variant
21
+
22
+ **Type**: `headline-medium`, `headline-small`, `headline-small-regular`, `title-medium`,
23
+ `title-medium-semi-bold`, `title-small`, `body`, `body-small`, `body-extra-small`,
24
+ `body-extra-small-bold`, `label`.
25
+
26
+ Define the text Typography variant among the options offered by the ThemeProvider component.
27
+
28
+ <Source
29
+ language='jsx'
30
+ code={dedent`
31
+ import Text from '@automattic/jetpack-components';
32
+
33
+ function Hello() {
34
+ return (
35
+ <Text variant="headline-medium">
36
+ Hello, Text component!
37
+ </Text>
38
+ );
39
+ }
40
+ `}
41
+ />
42
+
43
+ #### Spacing properties
44
+
45
+ **Type**: number, one of `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`.
46
+
47
+ Use the following properties to define margin and padding of the text. The unit is defined by the `--spacing-base` value.
48
+ You can see how it works playing with the [Box Model](./?path=/story/js-packages-components-text--box-model) story.
49
+
50
+ Prop | Description
51
+ ---|---
52
+ **m** | margin
53
+ **mt** | margin-top
54
+ **mr** | margin-right
55
+ **mb** | margin-bottom
56
+ **ml** | margin-left
57
+ **mx** | margin left and right
58
+ **my** | margin top and bottom
59
+ **p** | padding
60
+ **pt** | padding-top
61
+ **pr** | padding-right
62
+ **pb** | padding-bottom
63
+ **pl** | padding-left
64
+ **px** | padding left and right
65
+ **py** | padding top and bottom
66
+
67
+ <Source
68
+ language='jsx'
69
+ code={dedent`
70
+ import Text from '@automattic/jetpack-components';
71
+
72
+ function HelloBoxModel() {
73
+ return (
74
+ <Text mt={ 2 } px={ 4 }>
75
+ Hello, Text component!
76
+ </Text>
77
+ );
78
+ }
79
+ `}
80
+ />
81
+
82
+ #### component
83
+
84
+ **Type**: `elementType`, `string`.
85
+
86
+ Force an specific tag (`"span"`, `"div"`) or use a custom component that will receive className and children.
87
+
88
+ The example below renders the component with a `<span />` element.
89
+
90
+ <Source
91
+ language='jsx'
92
+ code={dedent`
93
+ import Text from '@automattic/jetpack-components';
94
+ function SpanTextComponent() {
95
+ return (
96
+ <Text component="span" variant="title-medium">
97
+ Never underestimate the span element
98
+ </Text>
99
+ );
100
+ }
101
+ `}
102
+ />
103
+
104
+ The following example shows how to define the typography and the margin for a Custom component.
105
+ The className is passed down to the custom component, while the properties that belong to the Text component (in this case, `component`, `variant` and `mb`) are not.
106
+
107
+ <Source
108
+ language='jsx'
109
+ code={dedent`
110
+ import Text from '@automattic/jetpack-components';
111
+
112
+ function CustomComponent( { children, className } ) {
113
+ // className, provided by Text, is "custom-classname"
114
+ return (
115
+ <div className={ className }>{ children }</div>
116
+ );
117
+ }
118
+
119
+ // Use a custom component when rendering the <Text />,
120
+ // it passes down the className property to it.
121
+ function CustomTextComponent() {
122
+ return (
123
+ <Text
124
+ component={ CustomComponent }
125
+ className="custom-classname"
126
+ variant="title-medium"
127
+ mb={ 3 }
128
+ >
129
+ Hello, Custom Text component!
130
+ </Text>
131
+ );
132
+ }
133
+ `}
134
+ />
135
+
136
+ [▶️ Custom Tag story](.?path=/story/js-packages-components-text--custom-tag) and [▶️ Custom Component story](.?path=/story/js-packages-components-text--custom-component)
137
+
138
+ #### Children
139
+
140
+ **Type**: `node`.
141
+
142
+ The text itself that will be rendered.
143
+
144
+ # Text based components
145
+
146
+ ## &lt;H2 /&gt;
147
+ Text shorthand to render a `heading-medium` text, applying proper spacing.
148
+
149
+ [▶️ Story](.?path=/story/js-packages-components-text-heading--headline-h-2)
150
+
151
+ ## &lt;H3 /&gt;
152
+ Text shorthand to render a `heading-small` text, applying proper spacing.
153
+
154
+ [▶️ Story](.?path=/story/js-packages-components-text-heading--headline-h-3)
155
+
156
+ ### Props
157
+
158
+ #### Weight: `bold` (default) | `regular`
159
+
160
+ <Source
161
+ language='jsx'
162
+ code={dedent`
163
+ import { H3 } from '@automattic/jetpack-components';
164
+
165
+ function Subtitle() {
166
+ return (
167
+ <H3 weight="regular">Let's explaining what H3 is</H3>
168
+ );
169
+ }
170
+ `}
171
+ />
172
+
173
+ ## &lt;Title /&gt;
174
+ Text shorthand to render a `body` text, applying proper spacing.
175
+
176
+ ### Props
177
+
178
+ #### Size: `medium` (default) | `small`
179
+
180
+ <Source
181
+ language='jsx'
182
+ code={dedent`
183
+ import { Title } from '@automattic/jetpack-components';
184
+
185
+ function Subtitle() {
186
+ return (
187
+ <Title size="small">
188
+ To explain what a Title component does, we should before...
189
+ </Title>
190
+ );
191
+ }
192
+ `}
193
+ />
194
+
195
+ [▶️ Story](.?path=/story/js-packages-components-text-title--default)
@@ -0,0 +1,69 @@
1
+ import Text, { BOX_MODEL_VALUES, H2, H3, Title, VARIANTS_MAPPING } from '../index';
2
+ import styles from './style.module.scss';
3
+ import type { SpacingValue } from '../types';
4
+
5
+ const SPACING_VALUES: Array< SpacingValue > = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ];
6
+
7
+ export default {
8
+ title: 'JS Packages/Components/Text',
9
+ component: Text,
10
+ argTypes: {
11
+ ...BOX_MODEL_VALUES.reduce(
12
+ ( obj, cur ) => ( {
13
+ ...obj,
14
+ [ cur ]: {
15
+ control: { type: 'select' },
16
+ options: SPACING_VALUES,
17
+ },
18
+ } ),
19
+ {}
20
+ ),
21
+ variant: {
22
+ control: {
23
+ type: 'select',
24
+ },
25
+ options: Object.keys( VARIANTS_MAPPING ),
26
+ },
27
+ },
28
+ subcomponents: { H2, H3, Title },
29
+ };
30
+
31
+ const Template = args => <Text { ...args }>{ args.variant ?? 'body' }</Text>;
32
+
33
+ export const Default = Template.bind( {} );
34
+
35
+ Default.args = {
36
+ variant: 'headline-medium',
37
+ };
38
+
39
+ export const CustomTag = Template.bind( {} );
40
+
41
+ CustomTag.args = {
42
+ variant: 'title-small',
43
+ component: 'div',
44
+ };
45
+
46
+ const Custom = ( { className, children } ) => (
47
+ <span className={ className }>{ children } Composition</span>
48
+ );
49
+
50
+ export const CustomComponent = Template.bind( {} );
51
+
52
+ CustomComponent.args = {
53
+ variant: 'headline-small',
54
+ component: Custom,
55
+ };
56
+
57
+ const BoxModelTemplate = args => (
58
+ <div className={ styles[ 'box-model-wrapper' ] }>
59
+ <div className={ styles[ 'box-model-side-left' ] } />
60
+ <div className={ styles[ 'box-model-side-center' ] }>
61
+ <Text { ...args }>
62
+ <div className={ styles[ 'box-model-inner' ] }>Box Model</div>
63
+ </Text>
64
+ </div>
65
+ <div className={ styles[ 'box-model-side-right' ] } />
66
+ </div>
67
+ );
68
+
69
+ export const BoxModel = BoxModelTemplate.bind( {} );
@@ -0,0 +1,64 @@
1
+ .instance {
2
+ span {
3
+ color: var( --jp-gray-40 );
4
+ display: inline-block;
5
+ width: 100%;
6
+ background-color: var( --jp-white-off );
7
+ }
8
+ }
9
+
10
+ .box-model-wrapper {
11
+ height: 100%;
12
+ display: flex;
13
+ margin-top: 50px;
14
+ }
15
+ .box-model-side-left,
16
+ .box-model-side-right {
17
+ flex-grow: 1;
18
+ }
19
+ .box-model-side-center {
20
+ background-color: #A68169;
21
+ position: relative;
22
+ &:after {
23
+ content:" ";
24
+ border: 1px dashed rgba( 0, 0, 0, 0.6 );
25
+ display: block;
26
+ position: absolute;
27
+ top: 0;
28
+ left: 0;
29
+ height: 100%;
30
+ width: 100%;
31
+ }
32
+ > p {
33
+ background-color: #B9C386;
34
+ position: relative;
35
+ &:after {
36
+ content:" ";
37
+ border: 1px dashed rgba( 0, 0, 0, 0.6 );
38
+ display: block;
39
+ position: absolute;
40
+ top: 0;
41
+ left: 0;
42
+ height: 100%;
43
+ width: 100%;
44
+ }
45
+ .box-model-inner {
46
+ min-width: 200px;
47
+ min-height: 50px;
48
+ line-height: 50px;
49
+ background-color: #8FAFBA;
50
+ text-align: center;
51
+ position: relative;
52
+ &:after {
53
+ content: " ";
54
+ border: 1px dashed rgba( 0, 0, 0, 0.4 );
55
+ display: block;
56
+ position: absolute;
57
+ top: 0;
58
+ left: 0;
59
+ height: 100%;
60
+ width: 100%;
61
+ }
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,34 @@
1
+ import { Title } from '../index';
2
+ import styles from './style.module.scss';
3
+ import type { TitleProps } from '../types';
4
+
5
+ const TIPOGRAPHY_SIZES: Array< TitleProps[ 'size' ] > = [ 'medium', 'small' ];
6
+
7
+ export default {
8
+ title: 'JS Packages/Components/Text/Title',
9
+ component: Title,
10
+ argTypes: {
11
+ children: {
12
+ control: { type: 'text' },
13
+ },
14
+ size: {
15
+ control: { type: 'select' },
16
+ options: TIPOGRAPHY_SIZES,
17
+ },
18
+ },
19
+ };
20
+
21
+ const Template = args => (
22
+ <div className={ styles.instance }>
23
+ <span>Text above to the the component...</span>
24
+ <Title { ...args }>
25
+ { args?.children || 'Title Medium - Secure, grow, and increase your site speed' }
26
+ </Title>
27
+ <span>Text below to the the component...</span>
28
+ </div>
29
+ );
30
+
31
+ export const Default = Template.bind( {} );
32
+ Default.args = {
33
+ size: 'medium',
34
+ } as TitleProps;
@@ -0,0 +1,125 @@
1
+ /* Reset all margin and padding for used components */
2
+ .reset {
3
+ margin: 0;
4
+ padding: 0;
5
+ }
6
+
7
+ /* Emerald Typography/Headline Medium */
8
+ .headline-medium {
9
+ font-size: var(--font-headline-medium);
10
+ font-weight: 700;
11
+ line-height: 52px;
12
+ }
13
+
14
+ /* Emerald Typography/Headline Small */
15
+ .headline-small {
16
+ font-size: var(--font-headline-small);
17
+ font-weight: 700;
18
+ line-height: 40px;
19
+ }
20
+
21
+ /* Emerald Typography/Headline Small Regular */
22
+ .headline-small-regular {
23
+ font-size: var(--font-headline-small);
24
+ font-weight: 400;
25
+ line-height: 40px;
26
+ }
27
+
28
+ /* Emerald Typography/Title Medium */
29
+ .title-medium {
30
+ font-size: var(--font-title-medium);
31
+ font-weight: 500;
32
+ line-height: 32px;
33
+ }
34
+
35
+ /* Emerald Typography/Title Medium Semi Bold */
36
+ .title-medium-semi-bold {
37
+ font-size: var(--font-title-medium);
38
+ font-weight: 600;
39
+ line-height: 32px;
40
+ }
41
+
42
+ /* Emerald Typography/Title Small */
43
+ .title-small {
44
+ font-size: var(--font-title-small);
45
+ font-weight: 500;
46
+ line-height: 30px;
47
+ }
48
+
49
+ /* Emerald Typography/Body */
50
+ .body {
51
+ font-size: var(--font-body);
52
+ font-weight: 400;
53
+ line-height: 24px;
54
+ }
55
+
56
+ /* Emerald Typography/Body Small */
57
+ .body-small {
58
+ font-size: var(--font-body-small);
59
+ font-weight: 400;
60
+ line-height: 24px;
61
+ }
62
+
63
+ /* Emerald Typography/Body Extra Small */
64
+ .body-extra-small {
65
+ font-size: var(--font-body-extra-small);
66
+ font-weight: 400;
67
+ line-height: 20px;
68
+ }
69
+
70
+ /* Emerald Typography/Body Extra Small Bold */
71
+ .body-extra-small-bold {
72
+ font-size: var(--font-body-extra-small);
73
+ font-weight: 700;
74
+ line-height: 20px;
75
+ }
76
+
77
+ /* Emerald Typography/Body Extra Small Label */
78
+ .label {
79
+ font-size: var(--font-body-extra-small);
80
+ font-weight: 600;
81
+ line-height: 16px;
82
+ }
83
+
84
+ /** Box-Model: Spacing (margin) */
85
+ $props: (
86
+ "margin": "m",
87
+ "padding": "p",
88
+ );
89
+
90
+ $sides: (
91
+ "top": "t",
92
+ "right": "r",
93
+ "bottom": "b",
94
+ "left": "l",
95
+ );
96
+
97
+ @each $prop, $p in $props {
98
+ $sizes: ( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
99
+
100
+ @each $size in $sizes {
101
+ /* m, p */
102
+ .#{$p}-#{$size} {
103
+ #{$prop}: calc( var( --spacing-base ) * #{$size} );
104
+ }
105
+
106
+ /* mx, px */
107
+ .#{$p}x-#{$size} {
108
+ #{$prop}-left: calc( var( --spacing-base ) * #{$size} );
109
+ #{$prop}-right: calc( var( --spacing-base ) * #{$size} );
110
+ }
111
+
112
+ .#{$p}y-#{$size} {
113
+ #{$prop}-top: calc( var( --spacing-base ) * #{$size} );
114
+ #{$prop}-bottom: calc( var( --spacing-base ) * #{$size} );
115
+ }
116
+
117
+ /* mt, mr, mb, ml */
118
+ /* pt, pr, pb, pl */
119
+ @each $side, $s in $sides {
120
+ .#{$p}#{$s}-#{$size} {
121
+ #{$prop}-#{$side}: calc( var( --spacing-base ) * #{$size} );
122
+ }
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,53 @@
1
+ import { VARIANTS_MAPPING } from './constants';
2
+ import type React from 'react';
3
+
4
+ export type SpacingValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
5
+
6
+ export type TextProps = {
7
+ variant?: keyof typeof VARIANTS_MAPPING;
8
+ /** margin */
9
+ m?: SpacingValue;
10
+ /** margin-top */
11
+ mt?: SpacingValue;
12
+ /** margin-right */
13
+ mr?: SpacingValue;
14
+ /** margin-bottom */
15
+ mb?: SpacingValue;
16
+ /** margin-left */
17
+ ml?: SpacingValue;
18
+ /** margin left and right */
19
+ mx?: SpacingValue;
20
+ /** margin top and bottom */
21
+ my?: SpacingValue;
22
+ /** padding */
23
+ p?: SpacingValue;
24
+ /** padding-top */
25
+ pt?: SpacingValue;
26
+ /** padding-right */
27
+ pr?: SpacingValue;
28
+ /** padding-bottom */
29
+ pb?: SpacingValue;
30
+ /** padding-left */
31
+ pl?: SpacingValue;
32
+ /** padding left and right */
33
+ px?: SpacingValue;
34
+ /** padding top and bottom */
35
+ py?: SpacingValue;
36
+ /** HTML Class */
37
+ className?: string;
38
+ /** The text itself that will be rendered. */
39
+ children: React.ReactNode;
40
+ /** Force an specific tag (span, div) or use a custom component that will receive className and children */
41
+ component?: React.FC< { [ prop: string ]: unknown } > | React.ElementType;
42
+ [ prop: string ]: unknown;
43
+ };
44
+
45
+ export type H3Props = TextProps & {
46
+ /** Font weight: 'bold' (default) | 'regular'. */
47
+ weight?: 'bold' | 'regular';
48
+ };
49
+
50
+ export type TitleProps = TextProps & {
51
+ /** Heading size: 'medium' (default) | 'small'. */
52
+ size?: 'medium' | 'small';
53
+ };
@@ -0,0 +1,49 @@
1
+ = ThemeProvider
2
+
3
+ ThemeProvider is a React component that, at the moment, defines and sets CSS variables to a wrapper element to make them accessible by the children components.
4
+ Usually, you'd like to provide the styles by wrappig your App component:
5
+
6
+ ```jsx
7
+ import { ThemeProvider } from '@automattic/jetpack-components';
8
+
9
+ function MyComponent() {
10
+ return (
11
+ <ThemeProvider>
12
+ <div style={ { color: var( --jp-green ) } }>Jetpack</div>
13
+ </ThemeProvider>
14
+ );
15
+ }
16
+ ```
17
+
18
+ Unlike other more complex implementations that use React context to share data, the CSS vars are defined in the DOM element, and consequently, propagated to child DOM elements.
19
+
20
+ ## API
21
+
22
+ ### Children
23
+
24
+ ReactNode children to be wrapped by the ThemeProvider element.
25
+
26
+ ### targetDom
27
+
28
+ Optional target DOM element to set the styles. By default, they are set in a new wrapper element created by the provider.
29
+ But when targetDom is defined, the styles are set straight into the given target, thus, the wrapper is not created.
30
+
31
+ When defining it, it's up to you the proper target to store the styles.
32
+
33
+ The following example stores the styles at the top of the page, in the body.
34
+
35
+ ```jsx
36
+ import { ThemeProvider } from '@automattic/jetpack-components';
37
+
38
+ function MyComponent() {
39
+ return (
40
+ <ThemeProvider targetDom={ document.body }>
41
+ <div style={ { color: var( --jp-green ) } }>Jetpack</div>
42
+ </ThemeProvider>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ### id
48
+
49
+ Pass an id to register the ThemeProvider instance to avoid redefining the styles every time that a ThemeProvider instance is created, avoiding unneeded redefinitions of the styles.
@@ -0,0 +1,6 @@
1
+ /* DO NOT USE THIS TO OVERRIDE STYLES */
2
+ .global {
3
+ & * {
4
+ box-sizing: border-box;
5
+ }
6
+ }