@automattic/jetpack-components 0.41.2 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/components/boost-score-graph/background.tsx +183 -0
  3. package/components/boost-score-graph/index.tsx +24 -16
  4. package/components/boost-score-graph/style.scss +17 -0
  5. package/components/boost-score-graph/types/declarations.d.ts +4 -0
  6. package/components/boost-score-graph/uplot-line-chart.tsx +11 -5
  7. package/components/boost-score-graph/use-boost-score-transform.ts +21 -18
  8. package/components/gridicon/index.tsx +13 -0
  9. package/components/{pricing-slider → number-slider}/index.tsx +12 -12
  10. package/components/{pricing-slider → number-slider}/style.scss +8 -8
  11. package/components/{pricing-slider → number-slider}/types.ts +2 -2
  12. package/components/popover/index.tsx +19 -0
  13. package/components/popover/style.scss +25 -0
  14. package/index.ts +2 -1
  15. package/package.json +12 -12
  16. package/.gitattributes +0 -8
  17. package/components/action-button/stories/index.stories.jsx +0 -38
  18. package/components/action-button/test/component.jsx +0 -16
  19. package/components/action-popover/stories/index.stories.jsx +0 -115
  20. package/components/action-popover/stories/styles.module.scss +0 -7
  21. package/components/admin-page/stories/index.stories.tsx +0 -35
  22. package/components/admin-page/stories/style.module.scss +0 -13
  23. package/components/admin-section/stories/index.stories.tsx +0 -60
  24. package/components/alert/stories/index.stories.jsx +0 -24
  25. package/components/automattic-byline-logo/stories/index.stories.tsx +0 -20
  26. package/components/automattic-byline-logo/test/component.tsx +0 -28
  27. package/components/boost-score-bar/stories/index.stories.tsx +0 -39
  28. package/components/boost-score-bar/test/component.tsx +0 -102
  29. package/components/boost-score-graph/stories/index.stories.tsx +0 -187
  30. package/components/boost-score-graph/stories/tooltip.stories.tsx +0 -41
  31. package/components/button/stories/index.mdx +0 -90
  32. package/components/button/stories/index.stories.tsx +0 -400
  33. package/components/button/stories/style.module.scss +0 -20
  34. package/components/contextual-upgrade-trigger/stories/index.stories.tsx +0 -25
  35. package/components/decorative-card/stories/index.stories.tsx +0 -18
  36. package/components/dialog/stories/boost.png +0 -0
  37. package/components/dialog/stories/declaration.d.ts +0 -1
  38. package/components/dialog/stories/index.stories.tsx +0 -118
  39. package/components/dialog/stories/js-components.components.dialog.mdx +0 -62
  40. package/components/dialog/stories/js-components.components.dialog.stories.js +0 -37
  41. package/components/dialog/stories/style.module.scss +0 -21
  42. package/components/donut-meter/stories/index.stories.tsx +0 -51
  43. package/components/donut-meter/test/component.tsx +0 -24
  44. package/components/gridicon/stories/index.stories.tsx +0 -18
  45. package/components/icon-tooltip/stories/index.stories.tsx +0 -108
  46. package/components/icon-tooltip/stories/style.scss +0 -36
  47. package/components/icon-tooltip/test/component.tsx +0 -15
  48. package/components/icons/stories/index.stories.tsx +0 -65
  49. package/components/icons/stories/style.module.scss +0 -33
  50. package/components/indeterminate-progress-bar/stories/index.stories.tsx +0 -14
  51. package/components/jetpack-footer/stories/index.stories.tsx +0 -39
  52. package/components/jetpack-footer/test/__snapshots__/component.tsx.snap +0 -186
  53. package/components/jetpack-footer/test/component.tsx +0 -159
  54. package/components/jetpack-logo/stories/index.stories.tsx +0 -20
  55. package/components/jetpack-logo/test/component.tsx +0 -16
  56. package/components/jetpack-search-logo/stories/index.stories.tsx +0 -21
  57. package/components/jetpack-search-logo/test/component.tsx +0 -16
  58. package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +0 -20
  59. package/components/jetpack-vaultpress-backup-logo/test/component.tsx +0 -18
  60. package/components/jetpack-videopress-logo/stories/index.stories.tsx +0 -20
  61. package/components/jetpack-videopress-logo/test/component.tsx +0 -16
  62. package/components/layout/stories/index.stories.tsx +0 -145
  63. package/components/layout/stories/styles.module.scss +0 -22
  64. package/components/loading-placeholder/stories/index.stories.tsx +0 -78
  65. package/components/notice/stories/index.stories.jsx +0 -90
  66. package/components/pricing-card/stories/index.stories.tsx +0 -55
  67. package/components/pricing-card/test/component.tsx +0 -89
  68. package/components/pricing-slider/stories/index.stories.tsx +0 -44
  69. package/components/pricing-slider/test/component.tsx +0 -14
  70. package/components/pricing-table/stories/index.stories.tsx +0 -74
  71. package/components/pricing-table/test/component.tsx +0 -41
  72. package/components/product-offer/stories/index.stories.tsx +0 -104
  73. package/components/product-price/stories/index.stories.tsx +0 -33
  74. package/components/product-price/test/component.tsx +0 -26
  75. package/components/qr-code/stories/index.stories.tsx +0 -32
  76. package/components/record-meter-bar/stories/index.stories.tsx +0 -39
  77. package/components/record-meter-bar/test/component.tsx +0 -52
  78. package/components/spinner/stories/index.stories.jsx +0 -20
  79. package/components/spinner/test/component.jsx +0 -17
  80. package/components/split-button/stories/index.stories.tsx +0 -35
  81. package/components/stat-card/stories/index.mdx +0 -35
  82. package/components/stat-card/stories/index.stories.tsx +0 -41
  83. package/components/stat-card/test/component.tsx +0 -24
  84. package/components/status/stories/index.stories.tsx +0 -44
  85. package/components/terms-of-service/test/index.test.jsx +0 -52
  86. package/components/testimonials/test/component.tsx +0 -103
  87. package/components/text/stories/headings.index.stories.tsx +0 -80
  88. package/components/text/stories/index.mdx +0 -195
  89. package/components/text/stories/index.stories.tsx +0 -69
  90. package/components/text/stories/style.module.scss +0 -64
  91. package/components/text/stories/title.index.stories.tsx +0 -34
  92. package/components/theme-provider/stories/index.stories.tsx +0 -164
  93. package/components/theme-provider/stories/style.module.scss +0 -79
  94. package/components/toggle-control/stories/index.stories.tsx +0 -83
  95. package/components/zendesk-chat/stories/index.stories.tsx +0 -15
  96. package/components/zendesk-chat/test/component.tsx +0 -16
  97. package/lib/locale/test/index.ts +0 -21
  98. package/tools/jp-redirect/test/index.tsx +0 -89
  99. package/tools/pricing-utils/test/index.ts +0 -39
@@ -1,195 +0,0 @@
1
- import { Meta, Source, Story } from '@storybook/blocks';
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)
@@ -1,69 +0,0 @@
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( {} );
@@ -1,64 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
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;
@@ -1,164 +0,0 @@
1
- import { Button } from '@wordpress/components';
2
- import { useCopyToClipboard } from '@wordpress/compose';
3
- import Col from '../../layout/col';
4
- import Container from '../../layout/container';
5
- import ThemeProvider, { typography, colors, borders, spacing } from '../index';
6
- import styles from './style.module.scss';
7
- import type { ComponentStory, ComponentMeta } from '@storybook/react';
8
-
9
- /**
10
- * Get the contrasting color for any hex color
11
- * (c) 2019 Chris Ferdinandi, MIT License, https://gomakethings.com
12
- * Derived from work by Brian Suda, https://24ways.org/2010/calculating-color-contrast/
13
- *
14
- * @param {string} hexcolor - hexcolor value
15
- * @returns {string} The contrasting color (black or white)
16
- */
17
- function getContrast( hexcolor ) {
18
- // If a leading # is provided, remove it
19
- if ( hexcolor.slice( 0, 1 ) === '#' ) {
20
- hexcolor = hexcolor.slice( 1 );
21
- }
22
-
23
- // If a three-character hexcode, make six-character
24
- if ( hexcolor.length === 3 ) {
25
- hexcolor = hexcolor
26
- .split( '' )
27
- .map( function ( hex ) {
28
- return hex + hex;
29
- } )
30
- .join( '' );
31
- }
32
-
33
- // Convert to RGB value
34
- const r = parseInt( hexcolor.substring( 0, 2 ), 16 );
35
- const g = parseInt( hexcolor.substring( 2, 4 ), 16 );
36
- const b = parseInt( hexcolor.substring( 4, 6 ), 16 );
37
-
38
- // Get YIQ ratio
39
- const yiq = ( r * 299 + g * 587 + b * 114 ) / 1000;
40
-
41
- // Check contrast
42
- return yiq >= 128 ? 'black' : 'white';
43
- }
44
- export default {
45
- title: 'JS Packages/Components/Theme Provider',
46
- } as ComponentMeta< typeof ThemeProvider >;
47
-
48
- const noop = () => {
49
- //
50
- };
51
-
52
- const ClipboardButton: React.FC< React.ComponentProps< typeof Button > > = ( {
53
- text,
54
- ...buttonProps
55
- } ) => {
56
- const ref = useCopyToClipboard( text, noop );
57
- return <Button { ...buttonProps } ref={ ref } />;
58
- };
59
-
60
- const Section = ( { title, data, children = null } ) => (
61
- <div className={ styles.section }>
62
- <h1 className={ styles.title }>{ title }</h1>
63
- <Container fluid>
64
- { Object.keys( data ).map( key => (
65
- <Col lg={ 3 } className={ styles.box }>
66
- <Container fluid horizontalGap={ 2 }>
67
- <Col className={ styles.key }>{ key }</Col>
68
- { children && <Col className={ styles.example }>{ children( data[ key ] ) }</Col> }
69
- <Col>
70
- <div className={ styles[ 'value-label' ] }>Value</div>
71
- <input
72
- type="text"
73
- value={ data[ key ] }
74
- readOnly={ true }
75
- className={ styles.value }
76
- />
77
- </Col>
78
- </Container>
79
- </Col>
80
- ) ) }
81
- </Container>
82
- </div>
83
- );
84
-
85
- export const Tokens = () => (
86
- <>
87
- <Section title="Typography" data={ typography }>
88
- { value => <div style={ { fontSize: value } }>Text</div> }
89
- </Section>
90
- <Section title="Colors" data={ colors }>
91
- { value => (
92
- <div className={ styles[ 'colors-example' ] } style={ { backgroundColor: value } } />
93
- ) }
94
- </Section>
95
- <Section title="Borders" data={ borders } />
96
- <Section title="Spacing" data={ spacing } />
97
- </>
98
- );
99
- Tokens.parameters = {
100
- docs: { source: { code: null } },
101
- };
102
-
103
- export const Typographies = args => (
104
- <div className={ styles[ 'instances-wrapper' ] }>
105
- { Object.keys( typography ).map( key => (
106
- <div className={ styles[ 'font-instance' ] } style={ { fontSize: typography[ key ] } }>
107
- { args?.[ 'Text Instance' ] || `${ key } (${ typography[ key ] } )` }
108
-
109
- <ClipboardButton variant="tertiary" text={ key } className={ styles[ 'copy-button' ] }>
110
- Copy
111
- </ClipboardButton>
112
- </div>
113
- ) ) }
114
- </div>
115
- );
116
-
117
- Typographies.args = {
118
- [ 'Text Instance' ]: '',
119
- };
120
- Typographies.parameters = {
121
- docs: { source: { code: null } },
122
- };
123
-
124
- export const Colors = () => (
125
- <div className={ styles[ 'instances-wrapper' ] }>
126
- { Object.keys( colors ).map( key => (
127
- <div
128
- className={ styles[ 'color-instance' ] }
129
- style={ { backgroundColor: colors[ key ], color: getContrast( colors[ key ] ) } }
130
- >
131
- { `${ key } (${ colors[ key ].toUpperCase() } )` }
132
-
133
- <ClipboardButton
134
- variant="tertiary"
135
- text={ key }
136
- className={ styles[ 'copy-button' ] }
137
- style={ { color: getContrast( colors[ key ] ) } }
138
- >
139
- Copy
140
- </ClipboardButton>
141
- </div>
142
- ) ) }
143
- </div>
144
- );
145
- Colors.parameters = {
146
- docs: { source: { code: null } },
147
- };
148
-
149
- const Template: ComponentStory< typeof ThemeProvider > = args => (
150
- <ThemeProvider { ...args }>
151
- <div
152
- style={ {
153
- color: 'var( --jp-white )',
154
- backgroundColor: 'var( --jp-pink )',
155
- fontSize: 'var( --font-title-small )',
156
- padding: 'var( --spacing-base ) calc( var( --spacing-base ) * 2 )',
157
- borderRadius: 'var( --jp-border-radius )',
158
- } }
159
- >
160
- Pink Jetpack Show
161
- </div>
162
- </ThemeProvider>
163
- );
164
- export const BasicUsage = Template.bind( {} );
@@ -1,79 +0,0 @@
1
- .section {
2
- width: 100%;
3
- margin: auto;
4
- padding: 8px 32px;
5
- }
6
-
7
- .key {
8
- background-color: var(--jp-green-80);
9
- border-radius: var(--jp-border-radius);
10
- padding: 8px;
11
- color: var(--jp-white);
12
- font-weight: 600;
13
- }
14
-
15
- .box {
16
- border: 1px solid var(--jp-gray);
17
- border-radius: var(--jp-border-radius);
18
- padding: 16px;
19
- }
20
-
21
- .example {
22
- height: 40px;
23
- display: flex;
24
- align-items: center;
25
- border: 1px solid var(--jp-gray);
26
- border-radius: var(--jp-border-radius);
27
- padding: 8px;
28
- }
29
-
30
- .value-label {
31
- font-weight: 600;
32
- font-size: var(--font-label);
33
- margin: 8px 0;
34
- }
35
-
36
- .value {
37
- width: 100%;
38
- }
39
-
40
- .colors-example {
41
- width: 100%;
42
- height: 100%;
43
- }
44
-
45
- .instances-wrapper {
46
- display: flex;
47
- flex-direction: column;
48
- }
49
-
50
- .font-instance {
51
- margin: 10px 0;
52
- padding: 20px 30px;
53
- background-color: var( --jp-white );
54
- border: 1px dotted var( --jp-gray-10 );
55
- position: relative;
56
- &:hover .copy-button {
57
- opacity: 1;
58
- }
59
- }
60
-
61
- .color-instance {
62
- font-size: var( --font-title-small );
63
- border: 1px dotted var( --jp-gray-10 );
64
- min-height: 60px;
65
- line-height: 60px;
66
- padding: 10px;
67
- margin: 10px 0;
68
- position: relative;
69
- &:hover .copy-button {
70
- opacity: 1;
71
- }
72
- }
73
-
74
- .copy-button {
75
- opacity: 0.3;
76
- position: absolute;
77
- top: 5px;
78
- right: 5px;
79
- }
@@ -1,83 +0,0 @@
1
- import React, { useCallback, useState } from 'react';
2
- import ToggleControl from '..';
3
-
4
- export default {
5
- title: 'JS Packages/Components/Toggle Control',
6
- component: ToggleControl,
7
- parameters: {
8
- layout: 'centered',
9
- },
10
- };
11
-
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- export const Default = args => {
14
- const [ checked, setChecked ] = useState( false );
15
-
16
- const handleChecked = useCallback( () => {
17
- setChecked( ! checked );
18
- }, [ checked ] );
19
-
20
- return <ToggleControl checked={ checked } onChange={ handleChecked } label="Code is poetry." />;
21
- };
22
-
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- export const Slow = args => {
25
- const [ loading, setLoading ] = useState( false );
26
- const [ checked, setChecked ] = useState( false );
27
-
28
- const handleChecked = useCallback( () => {
29
- setLoading( true );
30
- setTimeout( () => {
31
- setLoading( false );
32
- setChecked( ! checked );
33
- }, 2000 );
34
- }, [ checked ] );
35
-
36
- return (
37
- <ToggleControl
38
- checked={ checked }
39
- toggling={ loading }
40
- onChange={ handleChecked }
41
- label="Code is poetry."
42
- />
43
- );
44
- };
45
-
46
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
- export const Disabled = args => {
48
- const [ checked, setChecked ] = useState( false );
49
-
50
- const handleChecked = useCallback( () => {
51
- setChecked( ! checked );
52
- }, [ checked ] );
53
-
54
- return (
55
- <>
56
- <ToggleControl checked={ true } disabled label="Code is poetry." onChange={ handleChecked } />
57
- <ToggleControl
58
- checked={ false }
59
- disabled
60
- label="Code is poetry."
61
- onChange={ handleChecked }
62
- />
63
- </>
64
- );
65
- };
66
-
67
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
68
- export const HelpText = args => {
69
- const [ checked, setChecked ] = useState( false );
70
-
71
- const handleChecked = useCallback( () => {
72
- setChecked( ! checked );
73
- }, [ checked ] );
74
-
75
- return (
76
- <ToggleControl
77
- checked={ checked }
78
- label="Code is poetry."
79
- help="Code is poetry. Code is poetry. Code is poetry."
80
- onChange={ handleChecked }
81
- />
82
- );
83
- };
@@ -1,15 +0,0 @@
1
- import ZendeskChat from '../index';
2
-
3
- export default {
4
- title: 'JS Packages/Components/Zendesk Chat',
5
- component: ZendeskChat,
6
- parameters: {
7
- backgrounds: {
8
- default: 'dark',
9
- },
10
- },
11
- };
12
-
13
- const Template = args => <ZendeskChat { ...args } />;
14
-
15
- export const _default = Template.bind( {} );