@redocly/theme 0.1.10 → 0.1.13

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 (122) hide show
  1. package/CodeBlock/CodeBlock.js +2 -1
  2. package/Markdown/StyledMarkdown.d.ts +0 -2
  3. package/Markdown/StyledMarkdown.js +5 -16
  4. package/Markdown/index.d.ts +0 -1
  5. package/Markdown/index.js +0 -1
  6. package/Navbar/NavbarMenu.js +1 -1
  7. package/OperationBadge/OperationBadge.js +1 -1
  8. package/Search/ClearIcon.js +2 -2
  9. package/Search/Input.js +1 -1
  10. package/Search/Popover.js +1 -1
  11. package/Search/SearchIcon.js +2 -2
  12. package/Sidebar/ApiCallItem.js +1 -1
  13. package/TableOfContent/TableOfContent.js +5 -6
  14. package/globalStyle.d.ts +1 -0
  15. package/globalStyle.js +25 -3
  16. package/mocks/Link.js +4 -1
  17. package/mocks/hooks/usePageData.js +4 -1
  18. package/package.json +1 -1
  19. package/src/CodeBlock/CodeBlock.ts +3 -42
  20. package/src/Markdown/StyledMarkdown.tsx +14 -28
  21. package/src/Markdown/index.ts +0 -1
  22. package/src/Navbar/NavbarMenu.tsx +1 -1
  23. package/src/OperationBadge/OperationBadge.ts +5 -2
  24. package/src/Search/ClearIcon.tsx +12 -13
  25. package/src/Search/Input.tsx +7 -7
  26. package/src/Search/Popover.tsx +2 -2
  27. package/src/Search/SearchIcon.tsx +12 -13
  28. package/src/Sidebar/ApiCallItem.tsx +1 -2
  29. package/src/TableOfContent/TableOfContent.tsx +6 -4
  30. package/src/globalStyle.ts +829 -536
  31. package/src/mocks/Link.tsx +5 -2
  32. package/src/mocks/hooks/usePageData.ts +4 -1
  33. package/src/ui/Typography.tsx +12 -89
  34. package/src/ui/UniversalLink.tsx +3 -8
  35. package/src/utils/ClipboardService.ts +3 -86
  36. package/src/utils/isUrl.ts +4 -4
  37. package/src/utils/theme-helpers.ts +46 -0
  38. package/ui/Typography.d.ts +2 -71
  39. package/ui/Typography.js +15 -93
  40. package/ui/UniversalLink.js +1 -5
  41. package/utils/ClipboardService.d.ts +1 -5
  42. package/utils/ClipboardService.js +2 -73
  43. package/utils/isUrl.d.ts +2 -2
  44. package/utils/isUrl.js +4 -4
  45. package/utils/theme-helpers.d.ts +1 -0
  46. package/utils/theme-helpers.js +42 -2
  47. package/Markdown/CodeSample/CodeSample.d.ts +0 -8
  48. package/Markdown/CodeSample/CodeSample.js +0 -30
  49. package/Markdown/CodeSample/index.d.ts +0 -3
  50. package/Markdown/CodeSample/index.js +0 -19
  51. package/Markdown/CodeSample/styled.d.ts +0 -5
  52. package/Markdown/CodeSample/styled.js +0 -109
  53. package/Markdown/CodeSample/types.d.ts +0 -9
  54. package/Markdown/CodeSample/types.js +0 -2
  55. package/src/Button/Button.stories.tsx +0 -74
  56. package/src/Button/__tests__/Button.test.tsx +0 -42
  57. package/src/Button/__tests__/__snapshots__/Button.test.tsx.snap +0 -274
  58. package/src/CodeBlock/__tests__/CodeBlock.test.tsx +0 -12
  59. package/src/CodeBlock/__tests__/__snapshots__/CodeBlock.test.tsx.snap +0 -140
  60. package/src/CopyButton/CopyButton.stories.tsx +0 -18
  61. package/src/CopyButton/__tests__/CopyButton.test.tsx +0 -35
  62. package/src/CopyButton/__tests__/CopyButtonWrapper.test.tsx +0 -17
  63. package/src/CopyButton/__tests__/__snapshots__/CopyButton.test.tsx.snap +0 -55
  64. package/src/CopyButton/__tests__/__snapshots__/CopyButtonWrapper.test.tsx.snap +0 -46
  65. package/src/Footer/Footer.stories.tsx +0 -57
  66. package/src/Footer/__tests__/Footer.test.tsx +0 -55
  67. package/src/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +0 -253
  68. package/src/Headings/Headings.stories.tsx +0 -36
  69. package/src/Headings/__tests__/Headings.test.tsx +0 -24
  70. package/src/Headings/__tests__/__snapshots__/Headings.test.tsx.snap +0 -57
  71. package/src/JsonViewer/JsonViewer.stories.tsx +0 -57
  72. package/src/JsonViewer/__tests__/JsonViewer.test.tsx +0 -83
  73. package/src/JsonViewer/__tests__/__snapshots__/JsonViewer.test.tsx.snap +0 -2728
  74. package/src/Layout/__tests__/PageLayout.test.tsx +0 -17
  75. package/src/Layout/__tests__/RootLayout.test.tsx +0 -17
  76. package/src/Layout/__tests__/__snapshots__/PageLayout.test.tsx.snap +0 -38
  77. package/src/Layout/__tests__/__snapshots__/RootLayout.test.tsx.snap +0 -18
  78. package/src/Markdown/CodeSample/CodeSample.tsx +0 -39
  79. package/src/Markdown/CodeSample/index.ts +0 -3
  80. package/src/Markdown/CodeSample/styled.ts +0 -289
  81. package/src/Markdown/CodeSample/types.ts +0 -40
  82. package/src/Navbar/Navbar.stories.tsx +0 -32
  83. package/src/NavbarLogo/NavbarLogo.stories.tsx +0 -20
  84. package/src/NavbarLogo/__tests__/NavbarLogo.test.tsx +0 -47
  85. package/src/NavbarLogo/__tests__/__snapshots__/NavbarLogo.test.tsx.snap +0 -38
  86. package/src/OperationBadge/OperationBadge.stories.tsx +0 -35
  87. package/src/OperationBadge/__tests__/OperationBadge.test.tsx +0 -59
  88. package/src/OperationBadge/__tests__/__snapshots__/OperationBadge.test.tsx.snap +0 -651
  89. package/src/Panel/CodePanel.stories.tsx +0 -26
  90. package/src/Panel/ContentPanel.stories.tsx +0 -26
  91. package/src/Panel/Panel.stories.tsx +0 -56
  92. package/src/Panel/__tests__/CodePanel.test.tsx +0 -26
  93. package/src/Panel/__tests__/ContentPanel.test.tsx +0 -26
  94. package/src/Panel/__tests__/Panel.test.tsx +0 -53
  95. package/src/Panel/__tests__/__snapshots__/CodePanel.test.tsx.snap +0 -258
  96. package/src/Panel/__tests__/__snapshots__/ContentPanel.test.tsx.snap +0 -278
  97. package/src/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +0 -398
  98. package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +0 -18
  99. package/src/SamplesPanelControls/__tests__/SamplesPanelControls.test.tsx +0 -36
  100. package/src/SamplesPanelControls/__tests__/__snapshots__/SamplesPanelControls.test.tsx.snap +0 -228
  101. package/src/SidebarLogo/SidebarLogo.stories.tsx +0 -21
  102. package/src/SidebarLogo/__tests__/SidebarLogo.test.tsx +0 -32
  103. package/src/SidebarLogo/__tests__/__snapshots__/SidebarLogo.test.tsx.snap +0 -62
  104. package/src/SourceCode/SourceCode.stories.tsx +0 -29
  105. package/src/SourceCode/__tests__/SourceCode.test.tsx +0 -48
  106. package/src/SourceCode/__tests__/__snapshots__/SourceCode.test.tsx.snap +0 -786
  107. package/src/TableOfContent/TableOfContent.stories.tsx +0 -39
  108. package/src/Tooltip/Tooltip.stories.tsx +0 -27
  109. package/src/Tooltip/__tests__/Tooltip.test.tsx +0 -41
  110. package/src/Tooltip/__tests__/__snapshots__/Tooltip.test.tsx.snap +0 -83
  111. package/src/Welcome.stories.mdx +0 -7
  112. package/src/icons/ShelfIcon/ShelfIcon.stories.tsx +0 -36
  113. package/src/icons/ShelfIcon/__tests__/ShelfIcon.test.tsx +0 -54
  114. package/src/icons/ShelfIcon/__tests__/__snapshots__/ShelfIcon.test.tsx.snap +0 -235
  115. package/src/utils/__tests__/ClipboardService.test.ts +0 -24
  116. package/src/utils/__tests__/__snapshots__/highlight.test.ts.snap +0 -5
  117. package/src/utils/__tests__/__snapshots__/jsonToHtml.test.ts.snap +0 -5
  118. package/src/utils/__tests__/css-variables.test.ts +0 -20
  119. package/src/utils/__tests__/highlight.test.ts +0 -51
  120. package/src/utils/__tests__/jsonToHtml.test.ts +0 -40
  121. package/src/utils/__tests__/media-css.test.ts +0 -20
  122. package/src/utils/__tests__/theme-helpers.test.ts +0 -25
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
-
3
- import { renderWithTheme } from '../../../tests/utils';
4
-
5
- import { PageLayout } from '@theme/Layout/PageLayout';
6
-
7
- describe('PageLayout', () => {
8
- it('renders', () => {
9
- const { container } = renderWithTheme(
10
- <PageLayout sidebar={<div>sidebar</div>}>
11
- <div>test content</div>
12
- </PageLayout>,
13
- );
14
-
15
- expect(container.firstChild).toMatchSnapshot();
16
- });
17
- });
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
-
3
- import { renderWithTheme } from '../../../tests/utils';
4
-
5
- import { RootLayout } from '@theme/Layout/RootLayout';
6
-
7
- describe('RootLayout', () => {
8
- it('renders', () => {
9
- const { container } = renderWithTheme(
10
- <RootLayout footer={<div>footer</div>} navbar={<div>navbar</div>}>
11
- <div>content</div>
12
- </RootLayout>,
13
- );
14
-
15
- expect(container.firstChild).toMatchSnapshot();
16
- });
17
- });
@@ -1,38 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`PageLayout renders 1`] = `
4
- .c0 {
5
- display: -webkit-box;
6
- display: -webkit-flex;
7
- display: -ms-flexbox;
8
- display: flex;
9
- -webkit-flex-direction: row;
10
- -ms-flex-direction: row;
11
- flex-direction: row;
12
- min-height: calc(100vh - var(--navbar-height));
13
- }
14
-
15
- .c1 {
16
- -webkit-flex: 1 0 0;
17
- -ms-flex: 1 0 0;
18
- flex: 1 0 0;
19
- width: 0;
20
- max-width: 100%;
21
- }
22
-
23
- <div
24
- class="c0"
25
- data-component-name="Layout/PageLayout"
26
- >
27
- <div>
28
- sidebar
29
- </div>
30
- <div
31
- class="c1"
32
- >
33
- <div>
34
- test content
35
- </div>
36
- </div>
37
- </div>
38
- `;
@@ -1,18 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`RootLayout renders 1`] = `
4
- <div
5
- class=""
6
- data-component-name="Layout/RootLayout"
7
- >
8
- <div>
9
- navbar
10
- </div>
11
- <div>
12
- content
13
- </div>
14
- <div>
15
- footer
16
- </div>
17
- </div>
18
- `;
@@ -1,39 +0,0 @@
1
- import React, { useState } from 'react';
2
-
3
- import { ClipboardService } from '@theme/utils/ClipboardService';
4
- import {
5
- Wrapper,
6
- DoneIndicator,
7
- CopyCodeButton,
8
- CodeSampleButtonContainer,
9
- } from '@theme/Markdown/CodeSample/styled';
10
-
11
- type CodeSampleProps = {
12
- language: string;
13
- highlighted: string;
14
- rawContent: string;
15
- };
16
-
17
- export function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element {
18
- const langClassName = language ? `language-${language}` : '';
19
-
20
- const [isCopied, setIsCopied] = useState(false);
21
-
22
- const copyCode = (code: string) => {
23
- ClipboardService.copyCustom(code);
24
- setIsCopied(true);
25
- setTimeout(() => setIsCopied(false), 1500);
26
- };
27
-
28
- return (
29
- <Wrapper className="code-sample" data-component-name="Markdown/CodeSample/CodeSample">
30
- <CodeSampleButtonContainer onClick={() => copyCode(rawContent)}>
31
- {!isCopied && <CopyCodeButton title="Copy the code snippet">Copy</CopyCodeButton>}
32
- {isCopied && <DoneIndicator>Copied</DoneIndicator>}
33
- </CodeSampleButtonContainer>
34
- <pre className={langClassName}>
35
- <code className={langClassName} dangerouslySetInnerHTML={{ __html: highlighted }} />
36
- </pre>
37
- </Wrapper>
38
- );
39
- }
@@ -1,3 +0,0 @@
1
- export * from '@theme/Markdown/CodeSample/CodeSample';
2
- export * from '@theme/Markdown/CodeSample/styled';
3
- export * from '@theme/Markdown/CodeSample/types';
@@ -1,289 +0,0 @@
1
- import { getLuminance } from 'polished';
2
- import styled, { css } from 'styled-components';
3
-
4
- import { typography } from '@theme/ui/Typography';
5
- import type { Tokens, Token } from '@theme/Markdown/CodeSample/types';
6
- import { AppTheme } from '@theme/types/portal';
7
-
8
- function genTokens(tokens?: Tokens | null) {
9
- if (!tokens) {
10
- return '';
11
- }
12
-
13
- let res = '';
14
-
15
- for (const token of Object.keys(tokens)) {
16
- if (token !== 'default') {
17
- res += `.token.${token} { color: ${tokens[token as Token]?.color}; }\n`;
18
- }
19
- }
20
-
21
- if (tokens.default) {
22
- return css`
23
- pre& {
24
- ${typography(tokens.default)}
25
- }
26
- ${res}
27
- `;
28
- }
29
-
30
- return res;
31
- }
32
-
33
- const getCodeBlockBackgroundColor = (theme: AppTheme) =>
34
- Array.isArray(theme.codeBlock.backgroundColor)
35
- ? theme.codeBlock.backgroundColor[0]
36
- : theme.codeBlock.backgroundColor;
37
-
38
- export const CodeButton = css`
39
- padding: 0 5px;
40
- border-radius: 4px;
41
- `;
42
-
43
- export const CodeSampleButtonContainer = styled.div`
44
- position: absolute;
45
- top: 12px;
46
- right: 5px;
47
- `;
48
-
49
- export const CopyCodeButton = styled.div`
50
- ${CodeButton}
51
- display: none;
52
-
53
- &:hover {
54
- cursor: pointer;
55
- }
56
- `;
57
-
58
- export const DoneIndicator = styled.div`
59
- ${CodeButton}
60
- cursor: default;
61
- `;
62
-
63
- const lightStyleCodeButton = css`
64
- ${CopyCodeButton},
65
- ${DoneIndicator} {
66
- color: ${({ theme }) => theme.codeBlock.copyButton.visibleText};
67
- }
68
-
69
- ${CopyCodeButton}:hover {
70
- color: ${({ theme }) => theme.codeBlock.copyButton.visibleText};
71
- outline: 1px solid ${({ theme }) => theme.codeBlock.copyButton.visibleText};
72
- }
73
- `;
74
-
75
- const darkStyleCodeButton = css`
76
- ${CopyCodeButton},
77
- ${DoneIndicator} {
78
- color: ${({ theme }) => theme.codeBlock.copyButton.visibleText};
79
- }
80
-
81
- ${CopyCodeButton}:hover {
82
- color: white;
83
- color: ${({ theme }) => theme.codeBlock.copyButton.contrastText};
84
- background-color: ${({ theme }) => theme.codeBlock.copyButton.background};
85
- }
86
- `;
87
-
88
- const lightStyleTokens = css`
89
- .token.comment,
90
- .token.prolog,
91
- .token.doctype,
92
- .token.cdata {
93
- color: #999988;
94
- font-style: italic;
95
- }
96
-
97
- .token.namespace {
98
- opacity: 0.7;
99
- }
100
-
101
- .token.string,
102
- .token.attr-value {
103
- color: #e3116c;
104
- }
105
- .token.punctuation,
106
- .token.operator {
107
- color: #393a34; /* no highlight */
108
- }
109
-
110
- .token.entity,
111
- .token.url,
112
- .token.symbol,
113
- .token.number,
114
- .token.boolean,
115
- .token.variable,
116
- .token.constant,
117
- .token.property,
118
- .token.regex,
119
- .token.inserted {
120
- color: #36acaa;
121
- }
122
-
123
- .token.atrule,
124
- .token.keyword,
125
- .token.attr-name,
126
- .language-autohotkey .token.selector {
127
- color: #00a4db;
128
- }
129
-
130
- .token.function,
131
- .token.deleted,
132
- .language-autohotkey .token.tag {
133
- color: #9a050f;
134
- }
135
-
136
- .token.tag,
137
- .token.selector,
138
- .language-autohotkey .token.keyword {
139
- color: #00009f;
140
- }
141
- `;
142
-
143
- const darkStyleTokens = css`
144
- .token.comment,
145
- .token.prolog,
146
- .token.doctype,
147
- .token.cdata {
148
- color: hsl(30, 20%, 50%);
149
- }
150
-
151
- .token.property,
152
- .token.tag,
153
- .token.number,
154
- .token.constant,
155
- .token.symbol {
156
- color: #62bff9;
157
- }
158
- .token.boolean {
159
- color: firebrick;
160
- }
161
- .token.selector,
162
- .token.attr-name,
163
- .token.string,
164
- .token.char,
165
- .token.builtin,
166
- .token.inserted {
167
- color: #a0fbaa;
168
- & + a,
169
- & + a:visited {
170
- color: #4ed2ba;
171
- text-decoration: underline;
172
- }
173
- }
174
- .token.operator,
175
- .token.entity,
176
- .token.url,
177
- .token.variable {
178
- color: hsl(40, 90%, 60%);
179
- }
180
- .token.atrule,
181
- .token.attr-value,
182
- .token.keyword {
183
- color: hsl(350, 40%, 70%);
184
- }
185
- .token.regex,
186
- .token.important {
187
- color: #e90;
188
- }
189
-
190
- .token.deleted {
191
- color: red;
192
- }
193
- `;
194
-
195
- export const Wrapper = styled.div`
196
- overflow: auto;
197
- border-radius: 4px;
198
- position: relative;
199
-
200
- ${({ theme }) =>
201
- getLuminance(getCodeBlockBackgroundColor(theme)) < 0.25
202
- ? darkStyleCodeButton
203
- : lightStyleCodeButton}
204
-
205
- &:hover {
206
- ${CodeSampleButtonContainer} ${CopyCodeButton} {
207
- display: block;
208
- }
209
- }
210
-
211
- pre {
212
- white-space: ${({ theme }) => (theme.typography.code.wrap ? 'pre-wrap' : 'pre')};
213
- color: white;
214
- padding: 12px 14px 15px 14px;
215
- overflow-x: auto;
216
- line-height: normal;
217
- border-radius: 4px;
218
-
219
- font-family: ${({ theme }) => theme.typography.code.fontFamily};
220
- background-color: ${({ theme }) => theme.codeBlock.backgroundColor};
221
-
222
- code {
223
- background-color: transparent;
224
- border: 0;
225
- padding: 0;
226
-
227
- color: ${({ theme }) =>
228
- getLuminance(theme.codeBlock.backgroundColor) < 0.5 ? 'white' : '#393A34'};
229
-
230
- &:before,
231
- &:after {
232
- content: none;
233
- }
234
- }
235
- }
236
-
237
- pre[class*='language-'] {
238
- padding: 1em;
239
- margin: 0.5em 0;
240
- overflow: auto;
241
- border: 0;
242
- border-radius: ${({ theme }) => theme.shape.borderRadius};
243
- }
244
-
245
- code[class='language-text'] {
246
- line-height: 1.2em;
247
- display: inline-flex;
248
- white-space: pre-wrap;
249
- overflow-wrap: anywhere;
250
- }
251
-
252
- code[class*='language-'],
253
- pre[class*='language-'] {
254
- text-align: left;
255
- white-space: pre;
256
- word-spacing: normal;
257
- word-break: normal;
258
- word-wrap: normal;
259
- line-height: 1.5;
260
- -moz-tab-size: 4;
261
- -o-tab-size: 4;
262
- tab-size: 4;
263
- -webkit-hyphens: none;
264
- -moz-hyphens: none;
265
- -ms-hyphens: none;
266
- hyphens: none;
267
-
268
- .token.important,
269
- .token.bold {
270
- font-weight: bold;
271
- }
272
- .token.italic {
273
- font-style: italic;
274
- }
275
- .token.entity {
276
- cursor: help;
277
- }
278
- .token.punctuation {
279
- opacity: 0.7;
280
- }
281
- .namespace {
282
- opacity: 0.7;
283
- }
284
-
285
- ${({ theme }) =>
286
- getLuminance(getCodeBlockBackgroundColor(theme)) < 0.5 ? darkStyleTokens : lightStyleTokens}
287
- ${({ theme }) => genTokens(theme.codeBlock.tokens)}
288
- }
289
- `;
@@ -1,40 +0,0 @@
1
- import { ITypography } from '@theme/ui/Typography';
2
-
3
- export type Token =
4
- | 'comment'
5
- | 'prolog'
6
- | 'doctype'
7
- | 'cdata'
8
- | 'punctuation'
9
- | 'property'
10
- | 'tag'
11
- | 'number'
12
- | 'constant'
13
- | 'symbol'
14
- | 'boolean'
15
- | 'selector'
16
- | 'string'
17
- | 'char'
18
- | 'builtin'
19
- | 'inserted'
20
- | 'operator'
21
- | 'entity'
22
- | 'url'
23
- | 'variable'
24
- | 'atrule'
25
- | 'keyword'
26
- | 'regex'
27
- | 'important'
28
- | 'important'
29
- | 'bold'
30
- | 'italic'
31
- | 'entity'
32
- | 'deleted';
33
-
34
- export type Tokens = {
35
- [P in Token]?: {
36
- color: string;
37
- };
38
- } & {
39
- default?: ITypography;
40
- };
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
-
4
- import { Navbar } from './Navbar';
5
- import { NavbarMenu } from './NavbarMenu';
6
-
7
- import { NavbarLogo } from '@theme/NavbarLogo/NavbarLogo';
8
-
9
- export default {
10
- title: 'Components/Navbar',
11
- component: Navbar,
12
- } as ComponentMeta<typeof Navbar>;
13
-
14
- const Template: ComponentStory<typeof Navbar> = (args) => <Navbar {...args}>Click</Navbar>;
15
-
16
- export const Main = Template.bind({});
17
- Main.args = {
18
- logo: (
19
- <NavbarLogo
20
- logo={{ link: '/test/', image: 'https://picsum.photos/id/2/400/100', altText: 'test' }}
21
- />
22
- ),
23
- menu: (
24
- <NavbarMenu
25
- menuItems={[
26
- { type: 'link', link: 'https://google.com', label: 'Google' },
27
- { type: 'link', link: '/test/', label: 'Test' },
28
- ]}
29
- />
30
- ),
31
- search: <span> search </span>,
32
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
-
4
- import { NavbarLogo } from '@theme/NavbarLogo/NavbarLogo';
5
-
6
- export default {
7
- title: 'Components/NavbarLogo',
8
- component: NavbarLogo,
9
- } as ComponentMeta<typeof NavbarLogo>;
10
-
11
- const Template: ComponentStory<typeof NavbarLogo> = (args) => <NavbarLogo {...args} />;
12
-
13
- export const Default = Template.bind({});
14
- Default.args = {
15
- logo: {
16
- image: 'https://redocly.github.io/redoc/petstore-logo.png',
17
- link: 'http://redocly.com/',
18
- altText: 'Pet Store',
19
- },
20
- };
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
-
3
- import { renderWithTheme } from '../../../tests/utils';
4
-
5
- import { NavbarLogo } from '@theme/NavbarLogo';
6
-
7
- describe('NavbarLogo', () => {
8
- it('renders', () => {
9
- const { container } = renderWithTheme(
10
- <NavbarLogo
11
- logo={{
12
- image: 'https://test.com/logo.png',
13
- altText: 'Navbar Logo',
14
- link: 'https://test.com/',
15
- }}
16
- />,
17
- );
18
-
19
- expect(container.firstChild).toMatchSnapshot();
20
- });
21
-
22
- it('renders without link', () => {
23
- const { container } = renderWithTheme(
24
- <NavbarLogo
25
- logo={{
26
- image: 'https://test.com/logo.png',
27
- altText: 'Navbar Logo',
28
- }}
29
- />,
30
- );
31
-
32
- expect(container.firstChild).toMatchSnapshot();
33
- });
34
-
35
- it('renders nothing, if no image provided', () => {
36
- const { container } = renderWithTheme(
37
- <NavbarLogo
38
- logo={{
39
- altText: 'Navbar Logo',
40
- link: 'https://test.com/',
41
- }}
42
- />,
43
- );
44
-
45
- expect(container.firstChild).toBeNull();
46
- });
47
- });
@@ -1,38 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`NavbarLogo renders 1`] = `
4
- .c0 {
5
- max-width: var(--logo-max-width);
6
- max-height: var(--logo-max-height);
7
- height: var(--logo-height);
8
- margin: var(--logo-margin);
9
- }
10
-
11
- <a
12
- href="https://test.com/"
13
- to="https://test.com/"
14
- >
15
- <img
16
- alt="Navbar Logo"
17
- class="c0"
18
- data-component-name="NavbarLogo/NavbarLogo"
19
- src="https://test.com/logo.png"
20
- />
21
- </a>
22
- `;
23
-
24
- exports[`NavbarLogo renders without link 1`] = `
25
- .c0 {
26
- max-width: var(--logo-max-width);
27
- max-height: var(--logo-max-height);
28
- height: var(--logo-height);
29
- margin: var(--logo-margin);
30
- }
31
-
32
- <img
33
- alt="Navbar Logo"
34
- class="c0"
35
- data-component-name="NavbarLogo/NavbarLogo"
36
- src="https://test.com/logo.png"
37
- />
38
- `;
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { ComponentStory, ComponentMeta } from '@storybook/react';
3
-
4
- import { OperationBadge } from '@theme/OperationBadge';
5
-
6
- export default {
7
- title: 'Components/OperationBadge',
8
- component: OperationBadge,
9
- argTypes: {},
10
- } as ComponentMeta<typeof OperationBadge>;
11
-
12
- const Template: ComponentStory<typeof OperationBadge> = (args) => (
13
- <OperationBadge {...args}>Default</OperationBadge>
14
- );
15
-
16
- export const Default = Template.bind({});
17
- Default.args = {};
18
-
19
- const TemplateAll: ComponentStory<typeof OperationBadge> = () => (
20
- <>
21
- <OperationBadge type="get">get</OperationBadge>
22
- <OperationBadge type="post">post</OperationBadge>
23
- <OperationBadge type="put">put</OperationBadge>
24
- <OperationBadge type="delete">delete</OperationBadge>
25
- <OperationBadge type="options">options</OperationBadge>
26
- <OperationBadge type="patch">patch</OperationBadge>
27
- <OperationBadge type="basic">basic</OperationBadge>
28
- <OperationBadge type="link">link</OperationBadge>
29
- <OperationBadge type="head">head</OperationBadge>
30
- <OperationBadge type="hook">hook</OperationBadge>
31
- </>
32
- );
33
-
34
- export const All = TemplateAll.bind({});
35
- All.args = {};
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
-
4
- import { OperationBadge } from '@theme/OperationBadge';
5
-
6
- describe('OperationBadge', () => {
7
- it('renders basic', () => {
8
- const { container } = render(<OperationBadge type={'basic'}>basic</OperationBadge>);
9
-
10
- expect(container.firstChild).toMatchSnapshot();
11
- });
12
-
13
- it('renders get', () => {
14
- const { container } = render(<OperationBadge type={'get'}>get</OperationBadge>);
15
-
16
- expect(container.firstChild).toMatchSnapshot();
17
- });
18
-
19
- it('renders post', () => {
20
- const { container } = render(<OperationBadge type={'post'}>post</OperationBadge>);
21
-
22
- expect(container.firstChild).toMatchSnapshot();
23
- });
24
- it('renders put', () => {
25
- const { container } = render(<OperationBadge type={'put'}>put</OperationBadge>);
26
-
27
- expect(container.firstChild).toMatchSnapshot();
28
- });
29
- it('renders delete', () => {
30
- const { container } = render(<OperationBadge type={'delete'}>delete</OperationBadge>);
31
-
32
- expect(container.firstChild).toMatchSnapshot();
33
- });
34
- it('renders options', () => {
35
- const { container } = render(<OperationBadge type={'options'}>options</OperationBadge>);
36
-
37
- expect(container.firstChild).toMatchSnapshot();
38
- });
39
- it('renders patch', () => {
40
- const { container } = render(<OperationBadge type={'patch'}>patch</OperationBadge>);
41
-
42
- expect(container.firstChild).toMatchSnapshot();
43
- });
44
- it('renders link', () => {
45
- const { container } = render(<OperationBadge type={'link'}>link</OperationBadge>);
46
-
47
- expect(container.firstChild).toMatchSnapshot();
48
- });
49
- it('renders head', () => {
50
- const { container } = render(<OperationBadge type={'head'}>head</OperationBadge>);
51
-
52
- expect(container.firstChild).toMatchSnapshot();
53
- });
54
- it('renders hook', () => {
55
- const { container } = render(<OperationBadge type={'hook'}>hook</OperationBadge>);
56
-
57
- expect(container.firstChild).toMatchSnapshot();
58
- });
59
- });