@redocly/theme 0.1.0 → 0.1.3

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 (206) hide show
  1. package/Button/Button.d.ts +17 -0
  2. package/Button/Button.js +34 -0
  3. package/{lib/src/Button/index.ts → Button/index.d.ts} +0 -0
  4. package/Button/index.js +1 -0
  5. package/CodeBlock/CodeBlock.d.ts +1 -0
  6. package/CodeBlock/CodeBlock.js +7 -0
  7. package/{lib/src/CodeBlock/index.ts → CodeBlock/index.d.ts} +0 -0
  8. package/CodeBlock/index.js +1 -0
  9. package/CopyButton/CopyButton.d.ts +6 -0
  10. package/CopyButton/CopyButton.js +69 -0
  11. package/CopyButton/CopyButtonWrapper.d.ts +9 -0
  12. package/CopyButton/CopyButtonWrapper.js +37 -0
  13. package/{lib/src/CopyButton/index.ts → CopyButton/index.d.ts} +0 -0
  14. package/CopyButton/index.js +2 -0
  15. package/Headings/Headings.d.ts +3 -0
  16. package/Headings/Headings.js +10 -0
  17. package/{lib/src/Headings/index.ts → Headings/index.d.ts} +0 -0
  18. package/Headings/index.js +1 -0
  19. package/JsonViewer/JsonViewer.d.ts +10 -0
  20. package/JsonViewer/JsonViewer.js +92 -0
  21. package/{lib/src/JsonViewer/index.ts → JsonViewer/index.d.ts} +0 -0
  22. package/JsonViewer/index.js +1 -0
  23. package/JsonViewer/styled.d.ts +1 -0
  24. package/JsonViewer/styled.js +7 -0
  25. package/Logo/Logo.d.ts +10 -0
  26. package/Logo/Logo.js +25 -0
  27. package/Navbar/Navbar.d.ts +9 -0
  28. package/Navbar/Navbar.js +23 -0
  29. package/Navbar/NavbarItem.d.ts +40 -0
  30. package/Navbar/NavbarItem.js +43 -0
  31. package/Navbar/NavbarMenu.d.ts +4 -0
  32. package/Navbar/NavbarMenu.js +29 -0
  33. package/Panel/CodePanel.d.ts +1 -0
  34. package/Panel/CodePanel.js +13 -0
  35. package/Panel/ContentPanel.d.ts +1 -0
  36. package/Panel/ContentPanel.js +12 -0
  37. package/Panel/DarkHeader.d.ts +1 -0
  38. package/Panel/DarkHeader.js +7 -0
  39. package/Panel/Panel.d.ts +2 -0
  40. package/Panel/Panel.js +10 -0
  41. package/Panel/PanelBody.d.ts +6 -0
  42. package/Panel/PanelBody.js +15 -0
  43. package/Panel/PanelComponent.d.ts +10 -0
  44. package/Panel/PanelComponent.js +40 -0
  45. package/Panel/PanelHeader.d.ts +7 -0
  46. package/Panel/PanelHeader.js +16 -0
  47. package/Panel/PanelHeaderTitle.d.ts +1 -0
  48. package/Panel/PanelHeaderTitle.js +7 -0
  49. package/{lib/src/Panel/index.ts → Panel/index.d.ts} +0 -0
  50. package/Panel/index.js +7 -0
  51. package/SamplesPanelControls/SamplesPanelControls.d.ts +4 -0
  52. package/SamplesPanelControls/SamplesPanelControls.js +17 -0
  53. package/{lib/src/SamplesPanelControls/index.ts → SamplesPanelControls/index.d.ts} +0 -0
  54. package/SamplesPanelControls/index.js +1 -0
  55. package/SidebarLogo/SidebarLogo.d.ts +9 -0
  56. package/SidebarLogo/SidebarLogo.js +29 -0
  57. package/{lib/src/SidebarLogo/index.ts → SidebarLogo/index.d.ts} +0 -0
  58. package/SidebarLogo/index.js +1 -0
  59. package/SourceCode/SourceCode.d.ts +24 -0
  60. package/SourceCode/SourceCode.js +31 -0
  61. package/{lib/src/SourceCode/index.ts → SourceCode/index.d.ts} +0 -0
  62. package/SourceCode/index.js +1 -0
  63. package/Tooltip/Tooltip.d.ts +12 -0
  64. package/Tooltip/Tooltip.js +57 -0
  65. package/{lib/src/Tooltip/index.ts → Tooltip/index.d.ts} +0 -0
  66. package/Tooltip/index.js +1 -0
  67. package/globalStyle.d.ts +1 -0
  68. package/globalStyle.js +7 -0
  69. package/{lib/src/hooks/index.ts → hooks/index.d.ts} +0 -0
  70. package/hooks/index.js +3 -0
  71. package/hooks/useControl.d.ts +6 -0
  72. package/hooks/useControl.js +12 -0
  73. package/hooks/useMount.d.ts +1 -0
  74. package/hooks/useMount.js +7 -0
  75. package/hooks/useUnmount.d.ts +1 -0
  76. package/hooks/useUnmount.js +9 -0
  77. package/icons/ShelfIcon/ShelfIcon.d.ts +10 -0
  78. package/icons/ShelfIcon/ShelfIcon.js +33 -0
  79. package/{lib/src/icons/ShelfIcon/index.ts → icons/ShelfIcon/index.d.ts} +0 -0
  80. package/icons/ShelfIcon/index.js +1 -0
  81. package/{lib/src/icons/index.ts → icons/index.d.ts} +0 -0
  82. package/icons/index.js +1 -0
  83. package/{lib/src/index.ts → index.d.ts} +0 -0
  84. package/index.js +14 -0
  85. package/mocks/Link.d.ts +2 -0
  86. package/mocks/Link.js +17 -0
  87. package/mocks/utils.d.ts +1 -0
  88. package/mocks/utils.js +3 -0
  89. package/package.json +1 -5
  90. package/src/Button/Button.stories.tsx +74 -0
  91. package/{lib/src → src}/Button/Button.tsx +0 -0
  92. package/src/Button/__tests__/Button.test.tsx +42 -0
  93. package/src/Button/__tests__/__snapshots__/Button.test.tsx.snap +274 -0
  94. package/src/Button/index.ts +1 -0
  95. package/{lib/src → src}/CodeBlock/CodeBlock.ts +0 -0
  96. package/src/CodeBlock/__tests__/CodeBlock.test.tsx +12 -0
  97. package/src/CodeBlock/__tests__/__snapshots__/CodeBlock.test.tsx.snap +140 -0
  98. package/src/CodeBlock/index.ts +1 -0
  99. package/src/CopyButton/CopyButton.stories.tsx +18 -0
  100. package/{lib/src → src}/CopyButton/CopyButton.tsx +0 -0
  101. package/{lib/src → src}/CopyButton/CopyButtonWrapper.tsx +0 -0
  102. package/src/CopyButton/__tests__/CopyButton.test.tsx +35 -0
  103. package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +16 -0
  104. package/src/CopyButton/__tests__/__snapshots__/CopyButton.test.tsx.snap +55 -0
  105. package/src/CopyButton/__tests__/__snapshots__/CopyButtonWrapper.test.tsx.snap +46 -0
  106. package/src/CopyButton/index.ts +2 -0
  107. package/src/Headings/Headings.stories.tsx +36 -0
  108. package/{lib/src → src}/Headings/Headings.ts +0 -0
  109. package/src/Headings/__tests__/Headings.test.tsx +24 -0
  110. package/src/Headings/__tests__/__snapshots__/Headings.test.tsx.snap +57 -0
  111. package/src/Headings/index.ts +1 -0
  112. package/src/Introduction.stories.mdx +7 -0
  113. package/src/JsonViewer/JsonViewer.stories.tsx +57 -0
  114. package/{lib/src → src}/JsonViewer/JsonViewer.tsx +0 -0
  115. package/src/JsonViewer/__tests__/JsonViewer.test.tsx +82 -0
  116. package/src/JsonViewer/__tests__/__snapshots__/JsonViewer.test.tsx.snap +2728 -0
  117. package/src/JsonViewer/index.ts +1 -0
  118. package/{lib/src → src}/JsonViewer/styled.ts +0 -0
  119. package/{lib/src → src}/Logo/Logo.tsx +0 -0
  120. package/src/Navbar/Navbar.stories.tsx +38 -0
  121. package/{lib/src → src}/Navbar/Navbar.tsx +0 -0
  122. package/{lib/src → src}/Navbar/NavbarItem.tsx +0 -0
  123. package/{lib/src → src}/Navbar/NavbarMenu.tsx +0 -0
  124. package/src/Panel/CodePanel.stories.tsx +27 -0
  125. package/{lib/src → src}/Panel/CodePanel.ts +0 -0
  126. package/src/Panel/ContentPanel.stories.tsx +27 -0
  127. package/{lib/src → src}/Panel/ContentPanel.ts +0 -0
  128. package/{lib/src → src}/Panel/DarkHeader.ts +0 -0
  129. package/src/Panel/Panel.stories.tsx +58 -0
  130. package/{lib/src → src}/Panel/Panel.ts +0 -0
  131. package/{lib/src → src}/Panel/PanelBody.ts +0 -0
  132. package/{lib/src → src}/Panel/PanelComponent.tsx +0 -0
  133. package/{lib/src → src}/Panel/PanelHeader.ts +0 -0
  134. package/{lib/src → src}/Panel/PanelHeaderTitle.ts +0 -0
  135. package/src/Panel/__tests__/CodePanel.test.tsx +26 -0
  136. package/src/Panel/__tests__/ContentPanel.test.tsx +26 -0
  137. package/src/Panel/__tests__/Panel.test.tsx +54 -0
  138. package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +258 -0
  139. package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +278 -0
  140. package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +398 -0
  141. package/src/Panel/index.ts +7 -0
  142. package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +18 -0
  143. package/{lib/src → src}/SamplesPanelControls/SamplesPanelControls.ts +0 -0
  144. package/src/SamplesPanelControls/__tests__/SamplesPanelControls.test.tsx +36 -0
  145. package/src/SamplesPanelControls/__tests__/__snapshots__/SamplesPanelControls.test.tsx.snap +228 -0
  146. package/src/SamplesPanelControls/index.ts +1 -0
  147. package/src/SidebarLogo/SidebarLogo.stories.tsx +21 -0
  148. package/{lib/src → src}/SidebarLogo/SidebarLogo.tsx +0 -0
  149. package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +32 -0
  150. package/src/SidebarLogo/__tests__/__snapshots__/SidebarLogo.test.tsx.snap +62 -0
  151. package/src/SidebarLogo/index.ts +1 -0
  152. package/src/SourceCode/SourceCode.stories.tsx +29 -0
  153. package/{lib/src → src}/SourceCode/SourceCode.tsx +0 -0
  154. package/src/SourceCode/__tests__/SourceCode.test.tsx +47 -0
  155. package/src/SourceCode/__tests__/__snapshots__/SourceCode.test.tsx.snap +786 -0
  156. package/src/SourceCode/index.ts +1 -0
  157. package/src/Tooltip/Tooltip.stories.tsx +27 -0
  158. package/{lib/src → src}/Tooltip/Tooltip.tsx +0 -0
  159. package/src/Tooltip/__tests__/Tooltip.test.tsx +41 -0
  160. package/src/Tooltip/__tests__/__snapshots__/Tooltip.test.tsx.snap +83 -0
  161. package/src/Tooltip/index.ts +1 -0
  162. package/{lib/src → src}/globalStyle.ts +0 -0
  163. package/src/hooks/index.ts +3 -0
  164. package/{lib/src → src}/hooks/useControl.ts +0 -0
  165. package/{lib/src → src}/hooks/useMount.ts +0 -0
  166. package/{lib/src → src}/hooks/useUnmount.ts +0 -0
  167. package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +36 -0
  168. package/{lib/src → src}/icons/ShelfIcon/ShelfIcon.tsx +0 -0
  169. package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +54 -0
  170. package/src/icons/ShelfIcon/__tests__/__snapshots__/ShelfIcon.test.tsx.snap +235 -0
  171. package/src/icons/ShelfIcon/index.ts +2 -0
  172. package/src/icons/index.ts +1 -0
  173. package/src/index.ts +14 -0
  174. package/{lib/src → src}/mocks/Link.tsx +0 -0
  175. package/{lib/src → src}/mocks/utils.ts +0 -0
  176. package/{lib/src → src}/utils/ClipboardService.ts +0 -0
  177. package/src/utils/__tests__/ClipboardService.test.ts +24 -0
  178. package/src/utils/__tests__/__snapshots__/highlight.test.ts.snap +5 -0
  179. package/src/utils/__tests__/__snapshots__/jsonToHtml.test.ts.snap +5 -0
  180. package/src/utils/__tests__/css-variables.test.ts +20 -0
  181. package/src/utils/__tests__/highlight.test.ts +51 -0
  182. package/src/utils/__tests__/jsonToHtml.test.ts +40 -0
  183. package/src/utils/__tests__/media-css.test.ts +20 -0
  184. package/src/utils/__tests__/theme-helpers.test.ts +25 -0
  185. package/{lib/src → src}/utils/css-variables.ts +0 -0
  186. package/{lib/src → src}/utils/highlight.ts +0 -0
  187. package/{lib/src → src}/utils/index.ts +0 -0
  188. package/{lib/src → src}/utils/jsonToHtml.ts +0 -0
  189. package/{lib/src → src}/utils/media-css.ts +0 -0
  190. package/{lib/src → src}/utils/theme-helpers.ts +0 -0
  191. package/utils/ClipboardService.d.ts +8 -0
  192. package/utils/ClipboardService.js +83 -0
  193. package/utils/css-variables.d.ts +1 -0
  194. package/utils/css-variables.js +4 -0
  195. package/utils/highlight.d.ts +32 -0
  196. package/utils/highlight.js +65 -0
  197. package/utils/index.d.ts +6 -0
  198. package/utils/index.js +6 -0
  199. package/utils/jsonToHtml.d.ts +1 -0
  200. package/utils/jsonToHtml.js +116 -0
  201. package/utils/media-css.d.ts +12 -0
  202. package/utils/media-css.js +9 -0
  203. package/utils/theme-helpers.d.ts +3 -0
  204. package/utils/theme-helpers.js +27 -0
  205. package/LICENSE +0 -1
  206. package/lib/package.json +0 -91
@@ -0,0 +1,36 @@
1
+ import { render } from '@testing-library/react';
2
+ import React from 'react';
3
+
4
+ import { renderWithTheme } from '../../../tests/utils';
5
+ import {
6
+ SampleControls,
7
+ SamplesControlButton,
8
+ PreformattedCodeBlock,
9
+ } from '../SamplesPanelControls';
10
+
11
+ describe('SampleControls & SamplesControlButton', () => {
12
+ it('renders', () => {
13
+ const { container } = renderWithTheme(
14
+ <SampleControls>
15
+ <SamplesControlButton>Copy</SamplesControlButton>
16
+ </SampleControls>,
17
+ );
18
+
19
+ expect(container.firstChild).toMatchSnapshot();
20
+ });
21
+ });
22
+
23
+ describe('StyledPre', () => {
24
+ it('renders', () => {
25
+ const { container } = render(
26
+ <PreformattedCodeBlock>
27
+ Test: <br />
28
+ <a className="token string" href="#" target="_blank" rel="noopener noreferrer">
29
+ Click
30
+ </a>
31
+ </PreformattedCodeBlock>,
32
+ );
33
+
34
+ expect(container.firstChild).toMatchSnapshot();
35
+ });
36
+ });
@@ -0,0 +1,228 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`SampleControls & SamplesControlButton renders 1`] = `
4
+ .c2 {
5
+ background-color: var(--samples-panel-controls-background-color);
6
+ border: 0;
7
+ outline: 0;
8
+ border-radius: var(--global-border-radius);
9
+ height: 20px;
10
+ color: var(--color-content-inverse);
11
+ font-size: 12px;
12
+ line-height: 12px;
13
+ cursor: pointer;
14
+ padding: 1px 6px;
15
+ min-width: 90px;
16
+ }
17
+
18
+ .c2:hover,
19
+ .c2:focus {
20
+ background-color: var(--samples-panel-controls-hover-background-color);
21
+ }
22
+
23
+ .c0 {
24
+ padding: 10px 0;
25
+ opacity: 0.7;
26
+ -webkit-transition: opacity 0.3s ease;
27
+ transition: opacity 0.3s ease;
28
+ text-align: right;
29
+ }
30
+
31
+ .c0:focus-within {
32
+ opacity: 1;
33
+ }
34
+
35
+ .c0 > div,
36
+ .c0 > .c1 {
37
+ margin-top: 5px;
38
+ margin-left: 10px;
39
+ }
40
+
41
+ .c0 > div:first-child,
42
+ .c0 > .c1:first-child {
43
+ margin-left: 0;
44
+ }
45
+
46
+ @media screen and (min-width:50rem) {
47
+ .c2 {
48
+ padding: 2px 20px;
49
+ }
50
+ }
51
+
52
+ @media screen and (min-width:50rem) {
53
+ .c0 > div,
54
+ .c0 > .c1 {
55
+ margin-top: 0;
56
+ }
57
+ }
58
+
59
+ <div
60
+ class="c0"
61
+ >
62
+ <button
63
+ class="c1 c2"
64
+ >
65
+ Copy
66
+ </button>
67
+ </div>
68
+ `;
69
+
70
+ exports[`StyledPre renders 1`] = `
71
+ .c0 {
72
+ max-height: var(--code-block-max-height,600px);
73
+ word-break: var(--code-block-word-break,initial);
74
+ }
75
+
76
+ .c0 code[class*='language-'],
77
+ .c0 pre[class*='language-'] {
78
+ text-shadow: 0 -0.1em 0.2em black;
79
+ text-align: left;
80
+ white-space: pre;
81
+ word-spacing: normal;
82
+ word-break: normal;
83
+ word-wrap: normal;
84
+ line-height: 1.5;
85
+ -moz-tab-size: 4;
86
+ -o-tab-size: 4;
87
+ tab-size: 4;
88
+ -webkit-hyphens: none;
89
+ -moz-hyphens: none;
90
+ -ms-hyphens: none;
91
+ -webkit-hyphens: none;
92
+ -moz-hyphens: none;
93
+ -ms-hyphens: none;
94
+ hyphens: none;
95
+ }
96
+
97
+ .c0 pre[class*='language-'] {
98
+ padding: 1em;
99
+ margin: 0.5em 0;
100
+ overflow: auto;
101
+ }
102
+
103
+ .c0 .token.comment,
104
+ .c0 .token.prolog,
105
+ .c0 .token.doctype,
106
+ .c0 .token.cdata {
107
+ color: hsl(30,20%,50%);
108
+ }
109
+
110
+ .c0 .token.punctuation {
111
+ opacity: 1;
112
+ }
113
+
114
+ .c0 .namespace {
115
+ opacity: 0.7;
116
+ }
117
+
118
+ .c0 .token.property,
119
+ .c0 .token.tag,
120
+ .c0 .token.number,
121
+ .c0 .token.constant,
122
+ .c0 .token.symbol {
123
+ color: var(--color-content-inverse);
124
+ }
125
+
126
+ .c0 .token.boolean {
127
+ color: var(--color-error-500);
128
+ }
129
+
130
+ .c0 .token.selector,
131
+ .c0 .token.attr-name,
132
+ .c0 .token.string,
133
+ .c0 .token.char,
134
+ .c0 .token.builtin,
135
+ .c0 .token.inserted {
136
+ color: #fee39e;
137
+ }
138
+
139
+ .c0 .token.selector + a,
140
+ .c0 .token.attr-name + a,
141
+ .c0 .token.string + a,
142
+ .c0 .token.char + a,
143
+ .c0 .token.builtin + a,
144
+ .c0 .token.inserted + a,
145
+ .c0 .token.selector + a:visited,
146
+ .c0 .token.attr-name + a:visited,
147
+ .c0 .token.string + a:visited,
148
+ .c0 .token.char + a:visited,
149
+ .c0 .token.builtin + a:visited,
150
+ .c0 .token.inserted + a:visited {
151
+ color: #4ed2ba;
152
+ -webkit-text-decoration: underline;
153
+ text-decoration: underline;
154
+ }
155
+
156
+ .c0 .token.property.string {
157
+ color: #9efaa7;
158
+ }
159
+
160
+ .c0 .token.operator,
161
+ .c0 .token.entity,
162
+ .c0 .token.url,
163
+ .c0 .token.variable {
164
+ color: #f5b83d;
165
+ }
166
+
167
+ .c0 .token.atrule,
168
+ .c0 .token.attr-value,
169
+ .c0 .token.keyword {
170
+ color: #ffdbf4;
171
+ }
172
+
173
+ .c0 .token.regex,
174
+ .c0 .token.important {
175
+ color: #e90;
176
+ }
177
+
178
+ .c0 .token.important,
179
+ .c0 .token.bold {
180
+ font-weight: bold;
181
+ }
182
+
183
+ .c0 .token.italic {
184
+ font-style: italic;
185
+ }
186
+
187
+ .c0 .token.entity {
188
+ cursor: help;
189
+ }
190
+
191
+ .c0 .token.deleted {
192
+ color: red;
193
+ }
194
+
195
+ .c1 {
196
+ overflow-x: auto;
197
+ margin: 0;
198
+ font-family: var(--code-font-family);
199
+ padding: 20px;
200
+ border-radius: var(--global-border-radius);
201
+ background-color: var(--samples-panel-controls-background-color);
202
+ color: var(--color-content-inverse);
203
+ font-size: var(--code-font-size);
204
+ white-space: var(--code-wrap,pre);
205
+ }
206
+
207
+ @media print {
208
+ .c0 code[class*='language-'],
209
+ .c0 pre[class*='language-'] {
210
+ text-shadow: none;
211
+ }
212
+ }
213
+
214
+ <pre
215
+ class="c0 c1"
216
+ >
217
+ Test:
218
+ <br />
219
+ <a
220
+ class="token string"
221
+ href="#"
222
+ rel="noopener noreferrer"
223
+ target="_blank"
224
+ >
225
+ Click
226
+ </a>
227
+ </pre>
228
+ `;
@@ -0,0 +1 @@
1
+ export * from './SamplesPanelControls';
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+
4
+ import { SidebarLogo } from './SidebarLogo';
5
+
6
+ export default {
7
+ title: 'SidebarLogo',
8
+ component: SidebarLogo,
9
+ argTypes: {
10
+ backgroundColor: { control: 'color' },
11
+ },
12
+ } as ComponentMeta<typeof SidebarLogo>;
13
+
14
+ const Template: ComponentStory<typeof SidebarLogo> = (args) => <SidebarLogo {...args} />;
15
+
16
+ export const Default = Template.bind({});
17
+ Default.args = {
18
+ imageUrl: 'https://redocly.github.io/redoc/petstore-logo.png',
19
+ altText: 'Pet Store',
20
+ href: 'http://redocly.com/',
21
+ };
File without changes
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+
4
+ import { SidebarLogo } from '../SidebarLogo';
5
+
6
+ describe('SidebarLogo', () => {
7
+ it('renders', () => {
8
+ const { container } = render(
9
+ <SidebarLogo
10
+ imageUrl="https://test.com/logo.png"
11
+ href="https://test.com"
12
+ dataTestId="test"
13
+ />,
14
+ );
15
+
16
+ expect(container.firstChild).toMatchSnapshot();
17
+ });
18
+
19
+ it('renders without href', () => {
20
+ const { container } = render(
21
+ <SidebarLogo imageUrl="https://test.com/logo.png" dataTestId="test" />,
22
+ );
23
+
24
+ expect(container.firstChild).toMatchSnapshot();
25
+ });
26
+
27
+ it('renders nothing, if imageUrl not provided', () => {
28
+ const { container } = render(<SidebarLogo href="https://test.com" />);
29
+
30
+ expect(container.firstChild).toBeNull();
31
+ });
32
+ });
@@ -0,0 +1,62 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`SidebarLogo renders 1`] = `
4
+ .c2 {
5
+ max-height: var(--logo-max-height);
6
+ max-width: var(--logo-max-width);
7
+ padding: var(--logo-padding);
8
+ width: 100%;
9
+ display: block;
10
+ }
11
+
12
+ .c0 {
13
+ text-align: center;
14
+ line-height: 0;
15
+ }
16
+
17
+ .c1 {
18
+ display: inline-block;
19
+ }
20
+
21
+ <div
22
+ class="c0"
23
+ data-cy="test"
24
+ >
25
+ <a
26
+ class="c1"
27
+ href="https://test.com"
28
+ >
29
+ <img
30
+ alt="logo"
31
+ class="c2"
32
+ src="https://test.com/logo.png"
33
+ />
34
+ </a>
35
+ </div>
36
+ `;
37
+
38
+ exports[`SidebarLogo renders without href 1`] = `
39
+ .c1 {
40
+ max-height: var(--logo-max-height);
41
+ max-width: var(--logo-max-width);
42
+ padding: var(--logo-padding);
43
+ width: 100%;
44
+ display: block;
45
+ }
46
+
47
+ .c0 {
48
+ text-align: center;
49
+ line-height: 0;
50
+ }
51
+
52
+ <div
53
+ class="c0"
54
+ data-cy="test"
55
+ >
56
+ <img
57
+ alt="logo"
58
+ class="c1"
59
+ src="https://test.com/logo.png"
60
+ />
61
+ </div>
62
+ `;
@@ -0,0 +1 @@
1
+ export * from './SidebarLogo';
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+
4
+ import { SourceCode } from './SourceCode';
5
+
6
+ export default {
7
+ title: 'SourceCode',
8
+ component: SourceCode,
9
+ } as ComponentMeta<typeof SourceCode>;
10
+
11
+ const Template: ComponentStory<typeof SourceCode> = (args) => <SourceCode {...args} />;
12
+
13
+ export const WithoutCopyButton = Template.bind({});
14
+ WithoutCopyButton.args = {
15
+ lang: 'php',
16
+ source: `$client = new Rebilly\\Client([
17
+ 'apiKey' => 'YourApiKeyHere',
18
+ 'baseUrl' => 'https://api.rebilly.com',
19
+ ]);`,
20
+ };
21
+ export const WithCopyButton = Template.bind({});
22
+ WithCopyButton.args = {
23
+ lang: 'php',
24
+ withCopyButton: true,
25
+ source: `$client = new Rebilly\\Client([
26
+ 'apiKey' => 'YourApiKeyHere',
27
+ 'baseUrl' => 'https://api.rebilly.com',
28
+ ]);`,
29
+ };
File without changes
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+
3
+ import { SourceCode } from '../SourceCode';
4
+ import { renderWithTheme } from '../../../tests/utils';
5
+
6
+ describe('SourceCode', () => {
7
+ it('renders without copy button', () => {
8
+ const { container } = renderWithTheme(
9
+ <SourceCode source={`let count = 1; count++;`} lang="js" dataTestId="without-copy-button" />,
10
+ );
11
+
12
+ expect(container.firstChild).toMatchSnapshot();
13
+ });
14
+
15
+ it('renders with copy button', () => {
16
+ const { container } = renderWithTheme(
17
+ <SourceCode
18
+ source={`let count = 1; count++;`}
19
+ lang="js"
20
+ withCopyButton
21
+ dataTestId="with-copy-button"
22
+ />,
23
+ );
24
+
25
+ expect(container.firstChild).toMatchSnapshot();
26
+ });
27
+
28
+ it('renders with external source', () => {
29
+ const { container } = renderWithTheme(
30
+ <SourceCode
31
+ externalSource={{ sample: { get: () => `let count = 1; count++;`, lang: 'js' } }}
32
+ lang="js"
33
+ dataTestId="with-external-source"
34
+ />,
35
+ );
36
+
37
+ expect(container.firstChild).toMatchSnapshot();
38
+ });
39
+
40
+ it('renders with external source when it returns null', () => {
41
+ const { container } = renderWithTheme(
42
+ <SourceCode externalSource={{ sample: { get: () => '', lang: 'js' } }} lang="js" />,
43
+ );
44
+
45
+ expect(container.firstChild).toMatchSnapshot();
46
+ });
47
+ });