@redocly/theme 0.0.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 (54) hide show
  1. package/LICENSE +1 -0
  2. package/lib/package.json +91 -0
  3. package/lib/src/Button/Button.tsx +122 -0
  4. package/lib/src/Button/index.ts +1 -0
  5. package/lib/src/CodeBlock/CodeBlock.ts +125 -0
  6. package/lib/src/CodeBlock/index.ts +1 -0
  7. package/lib/src/CopyButton/CopyButton.tsx +26 -0
  8. package/lib/src/CopyButton/CopyButtonWrapper.tsx +52 -0
  9. package/lib/src/CopyButton/index.ts +2 -0
  10. package/lib/src/Headings/Headings.ts +23 -0
  11. package/lib/src/Headings/index.ts +1 -0
  12. package/lib/src/JsonViewer/JsonViewer.tsx +130 -0
  13. package/lib/src/JsonViewer/index.ts +1 -0
  14. package/lib/src/JsonViewer/styled.ts +103 -0
  15. package/lib/src/Logo/Logo.tsx +23 -0
  16. package/lib/src/Navbar/Navbar.tsx +60 -0
  17. package/lib/src/Navbar/NavbarItem.tsx +90 -0
  18. package/lib/src/Navbar/NavbarMenu.tsx +29 -0
  19. package/lib/src/Panel/CodePanel.ts +31 -0
  20. package/lib/src/Panel/ContentPanel.ts +43 -0
  21. package/lib/src/Panel/DarkHeader.ts +8 -0
  22. package/lib/src/Panel/Panel.ts +18 -0
  23. package/lib/src/Panel/PanelBody.ts +30 -0
  24. package/lib/src/Panel/PanelComponent.tsx +73 -0
  25. package/lib/src/Panel/PanelHeader.ts +25 -0
  26. package/lib/src/Panel/PanelHeaderTitle.ts +11 -0
  27. package/lib/src/Panel/index.ts +7 -0
  28. package/lib/src/SamplesPanelControls/SamplesPanelControls.ts +70 -0
  29. package/lib/src/SamplesPanelControls/index.ts +1 -0
  30. package/lib/src/SidebarLogo/SidebarLogo.tsx +47 -0
  31. package/lib/src/SidebarLogo/index.ts +1 -0
  32. package/lib/src/SourceCode/SourceCode.tsx +67 -0
  33. package/lib/src/SourceCode/index.ts +1 -0
  34. package/lib/src/Tooltip/Tooltip.tsx +171 -0
  35. package/lib/src/Tooltip/index.ts +1 -0
  36. package/lib/src/globalStyle.ts +512 -0
  37. package/lib/src/hooks/index.ts +3 -0
  38. package/lib/src/hooks/useControl.ts +20 -0
  39. package/lib/src/hooks/useMount.ts +8 -0
  40. package/lib/src/hooks/useUnmount.ts +10 -0
  41. package/lib/src/icons/ShelfIcon/ShelfIcon.tsx +45 -0
  42. package/lib/src/icons/ShelfIcon/index.ts +2 -0
  43. package/lib/src/icons/index.ts +1 -0
  44. package/lib/src/index.ts +14 -0
  45. package/lib/src/mocks/Link.tsx +7 -0
  46. package/lib/src/mocks/utils.ts +3 -0
  47. package/lib/src/utils/ClipboardService.ts +92 -0
  48. package/lib/src/utils/css-variables.ts +2 -0
  49. package/lib/src/utils/highlight.ts +81 -0
  50. package/lib/src/utils/index.ts +6 -0
  51. package/lib/src/utils/jsonToHtml.ts +122 -0
  52. package/lib/src/utils/media-css.ts +16 -0
  53. package/lib/src/utils/theme-helpers.ts +34 -0
  54. package/package.json +91 -0
@@ -0,0 +1,171 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import React, { useCallback, useEffect, memo } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+
5
+ import { useControl } from '../hooks';
6
+
7
+ export interface TooltipProps {
8
+ tip: string;
9
+ open?: boolean;
10
+ placement?: 'top' | 'bottom' | 'left' | 'right';
11
+ className?: string;
12
+ width?: string;
13
+ dataTestId?: string;
14
+ }
15
+
16
+ export function TooltipComponent({
17
+ children,
18
+ open,
19
+ tip,
20
+ placement = 'top',
21
+ className = 'default',
22
+ width,
23
+ dataTestId = tip,
24
+ }: PropsWithChildren<TooltipProps>): JSX.Element {
25
+ const { isOpened, handleOpen, handleClose } = useControl(open);
26
+
27
+ const isControlled = open !== undefined;
28
+
29
+ useEffect(() => {
30
+ if (isControlled) {
31
+ if (open) {
32
+ handleOpen();
33
+ } else {
34
+ handleClose();
35
+ }
36
+ }
37
+ }, [open, isControlled, handleOpen, handleClose]);
38
+
39
+ const handleEnter = useCallback(() => {
40
+ handleOpen();
41
+ }, [handleOpen]);
42
+
43
+ const handleLeave = useCallback(() => {
44
+ handleClose();
45
+ }, [handleClose]);
46
+
47
+ return (
48
+ <TooltipWrapper
49
+ onMouseEnter={isControlled ? undefined : handleEnter}
50
+ onMouseLeave={isControlled ? undefined : handleLeave}
51
+ onClick={isControlled ? undefined : handleLeave}
52
+ className={`tooltip-${className}`}
53
+ >
54
+ {children}
55
+ {isOpened && (
56
+ <TooltipBody data-cy={dataTestId} placement={placement} width={width}>
57
+ {tip}
58
+ </TooltipBody>
59
+ )}
60
+ </TooltipWrapper>
61
+ );
62
+ }
63
+
64
+ export const Tooltip = memo<PropsWithChildren<TooltipProps>>(TooltipComponent);
65
+
66
+ const PLACEMENTS = {
67
+ top: css`
68
+ top: 0;
69
+ left: 50%;
70
+ transform: translate(-50%, -99%);
71
+ margin-top: -10px;
72
+
73
+ &::after {
74
+ border-left: 5px solid transparent;
75
+ border-right: 5px solid transparent;
76
+ border-top-width: 6px;
77
+ border-top-style: solid;
78
+ bottom: 0;
79
+ left: 50%;
80
+ transform: translate(-50%, 99%);
81
+ }
82
+ `,
83
+ bottom: css`
84
+ bottom: 0;
85
+ left: 50%;
86
+ transform: translate(-50%, 99%);
87
+ margin-bottom: -10px;
88
+
89
+ &::after {
90
+ border-left: 5px solid transparent;
91
+ border-right: 5px solid transparent;
92
+ border-bottom-width: 6px;
93
+ border-bottom-style: solid;
94
+ top: 0;
95
+ left: 50%;
96
+ transform: translate(-50%, -99%);
97
+ }
98
+ `,
99
+ left: css`
100
+ top: 50%;
101
+ left: 0;
102
+ transform: translate(-100%, -50%);
103
+ margin-left: -10px;
104
+
105
+ &::after {
106
+ border-top: 5px solid transparent;
107
+ border-bottom: 5px solid transparent;
108
+ border-left-width: 6px;
109
+ border-left-style: solid;
110
+ top: 50%;
111
+ right: 0;
112
+ transform: translate(99%, -50%);
113
+ }
114
+ `,
115
+ right: css`
116
+ top: 50%;
117
+ right: 0;
118
+ transform: translate(100%, -50%);
119
+ margin-right: -10px;
120
+
121
+ &::after {
122
+ border-top: 5px solid transparent;
123
+ border-bottom: 5px solid transparent;
124
+ border-right-width: 6px;
125
+ border-right-style: solid;
126
+ top: 50%;
127
+ left: 0;
128
+ transform: translate(-99%, -50%);
129
+ }
130
+ `,
131
+ };
132
+
133
+ const TooltipWrapper = styled.div`
134
+ position: relative;
135
+ display: inline-block;
136
+ `;
137
+
138
+ const TooltipBody = styled.span<Pick<Required<TooltipProps>, 'placement'> & { width?: string }>`
139
+ display: inline-block;
140
+
141
+ position: absolute;
142
+ text-align: center;
143
+
144
+ padding: 10px 20px;
145
+ max-width: 250px;
146
+ white-space: normal;
147
+ overflow-wrap: break-word;
148
+
149
+ border-radius: var(--global-border-radius);
150
+ pointer-events: none;
151
+ transition: opacity 0.3s ease-out;
152
+
153
+ font-size: 13px;
154
+
155
+ &::after {
156
+ position: absolute;
157
+
158
+ content: ' ';
159
+ display: inline-block;
160
+ width: 0;
161
+ height: 0;
162
+ border-color: var(--tooltip-background-color);
163
+ }
164
+
165
+ background: var(--tooltip-background-color);
166
+ color: var(--tooltip-color);
167
+ box-shadow: rgb(0 0 0 / 25%) 0 2px 4px;
168
+
169
+ width: ${({ width }) => width || '120px'};
170
+ ${({ placement }) => `${PLACEMENTS[placement]};`}
171
+ `;
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1,512 @@
1
+ import { createGlobalStyle } from 'styled-components';
2
+
3
+ export const GlobalStyle = createGlobalStyle`
4
+ /*
5
+ * Static classnames that can be used to override styles for components:
6
+ * download-specification-button, next-section-button, button-base
7
+ */
8
+ :root {
9
+ /* === Palette === */
10
+
11
+ /*
12
+ * Color palette
13
+ */
14
+ --color-primary-100: #62a1ff;
15
+ --color-primary-200: #4892ff;
16
+ --color-primary-300: #2f83ff;
17
+ --color-primary-400: #1573ff;
18
+ --color-primary-500: #0065fb;
19
+ --color-primary-600: #005be2;
20
+ --color-primary-700: #0050c8;
21
+ --color-primary-800: #0046af;
22
+ --color-primary-900: #003c95;
23
+
24
+ --color-secondary-100: #ffffff;
25
+ --color-secondary-200: #f5f7fa;
26
+ --color-secondary-300: #f3f4f6;
27
+ --color-secondary-400: #e4e7eb;
28
+ --color-secondary-500: #d5dae0;
29
+ --color-secondary-600: #c7cdd5;
30
+ --color-secondary-700: #b8c0ca;
31
+ --color-secondary-800: #a9b3c0;
32
+ --color-secondary-900: #9ba6b5;
33
+
34
+ --color-emphasis-100: #ffffff;
35
+ --color-emphasis-200: #e9eaec;
36
+ --color-emphasis-300: #cdd0d5;
37
+ --color-emphasis-400: #b2b6bd;
38
+ --color-emphasis-500: #969ca6;
39
+ --color-emphasis-600: #7a828f;
40
+ --color-emphasis-700: #626974;
41
+ --color-emphasis-800: #4b5058;
42
+ --color-emphasis-900: #1c1e21;
43
+
44
+ --color-accent-100: #b3dcf3;
45
+ --color-accent-200: #a6dfff;
46
+ --color-accent-300: #8cd5ff;
47
+ --color-accent-400: #73ccff;
48
+ --color-accent-500: #59c3ff;
49
+ --color-accent-600: #40baff;
50
+ --color-accent-700: #26b1ff;
51
+ --color-accent-800: #0da7ff;
52
+ --color-accent-900: #009bf2;
53
+
54
+ --color-success-100: #98eda0;
55
+ --color-success-200: #82e98c;
56
+ --color-success-300: #6ce678;
57
+ --color-success-400: #57e264;
58
+ --color-success-500: #41de50;
59
+ --color-success-600: #2bda3c;
60
+ --color-success-700: #23c933;
61
+ --color-success-800: #1fb32d;
62
+ --color-success-900: #1b9e28;
63
+
64
+ --color-warning-100: #ffc966;
65
+ --color-warning-200: #ffc04d;
66
+ --color-warning-300: #ffb733;
67
+ --color-warning-400: #ffae1a;
68
+ --color-warning-500: #ffa500;
69
+ --color-warning-600: #e69400;
70
+ --color-warning-700: #cc8400;
71
+ --color-warning-800: #b37300;
72
+ --color-warning-900: #996300;
73
+
74
+ --color-error-100: #ffc7c7;
75
+ --color-error-200: #ffaeae;
76
+ --color-error-300: #ff9494;
77
+ --color-error-400: #ff7b7b;
78
+ --color-error-500: #ff6161;
79
+ --color-error-600: #ff4747;
80
+ --color-error-700: #ff2e2e;
81
+ --color-error-800: #ff1414;
82
+ --color-error-900: #ff0000;
83
+
84
+ /* === Typography === */
85
+
86
+ --color-content: #1f2933;
87
+ --color-content-inverse: var(--color-secondary-200);
88
+ --color-content-secondary: #7b8794;
89
+
90
+ --font-size-base: 14px;
91
+ --line-height-base: 1.5em;
92
+ --font-weight-regular: 400;
93
+ --font-weight-bold: 600;
94
+ --font-weight-bolder: 700;
95
+ --font-family-base: Source Sans Pro, sans-serif;
96
+ --font-family-monospaced: Source Code Pro, monospace;
97
+
98
+ --smoothing: antialiased; // text-smoothing
99
+ --text-rendering: optimizeSpeed; // text-rendering
100
+
101
+ /*
102
+ * Spacing
103
+ */
104
+ --spacing-unit: 5px;
105
+ --spacing-horizontal: calc(var(--spacing-unit) * 8);
106
+ --spacing-vertical: calc(var(--spacing-unit) * 4);
107
+
108
+ /*
109
+ * Global
110
+ */
111
+ --global-border-radius: 4px;
112
+ --global-border-width: 1px;
113
+ --global-border-color: var(--color-secondary-400);
114
+ --global-border-color-secondary: #616e7c;
115
+ --global-background-color: transparent;
116
+
117
+ /* === Page layout === */
118
+ //TBD
119
+ /* === Navbar === */
120
+ //--navbar-height:
121
+ //TBD
122
+
123
+ /* === Menu (sidebar) === */
124
+
125
+ --sidebar-width: 285px;
126
+ --sidebar-background-color: #fff;
127
+ --sidebar-right-line-color: var(--global-border-color);
128
+ --sidebar-spacing-unit: 8px;
129
+ --sidebar-spacing-horizontal: var(--sidebar-spacing-unit);
130
+ --sidebar-spacing-vertical: var(--sidebar-spacing-unit);
131
+
132
+ --sidebar-word-break: 'inherit';
133
+ --sidebar-separator-label-color: var(--sidebar-item-color);
134
+ --sidebar-separator-line-color: #dadada;
135
+ --sidebar-chevron-color: var(--sidebar-item-color);
136
+ --sidebar-chevron-size: var(--sidebar-spacing-unit);
137
+
138
+ --sidebar-item-spacing-offset-top: calc(var(--sidebar-spacing-unit) * 2);
139
+ --sidebar-item-spacing-offset-left: calc(var(--sidebar-spacing-unit) * 2);
140
+ --sidebar-item-spacing-offset-nesting: calc(var(--sidebar-spacing-unit) * 2);
141
+ --sidebar-item-border-radius: 4px;
142
+ --sidebar-item-font-family: var(--font-family-base);
143
+ --sidebar-item-font-size: var(--font-size-base);
144
+ --sidebar-item-color: var(--color-content);
145
+ --sidebar-item-active-color: var(--color-content);
146
+ --sidebar-item-background-color: #fff;
147
+ --sidebar-item-active-background-color: var(--global-border-color);
148
+
149
+ //TBD
150
+ /* === Footer === */
151
+ //TBD
152
+ /* === Table of contents === */
153
+ //TBD
154
+ /* === Various components: buttons, inputs, alerts, tooltip === */
155
+
156
+ /*
157
+ * Buttons
158
+ */
159
+ --button-color: white;
160
+ --button-background-color: var(--color-emphasis-500);
161
+ --button-hover-background-color: var(--color-emphasis-600);
162
+ --button-active-background-color: var(--color-emphasis-700);
163
+ --button-outlined-active-border-color: var(--color-emphasis-800);
164
+ --button-border-radius: var(--global-border-radius);
165
+ --button-font-family: inherit;
166
+ --button-font-weight: var(--font-weight-bold);
167
+ --button-box-shadow: none;
168
+ --button-active-box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.1);
169
+
170
+ .button-color-primary {
171
+ --button-color: white;
172
+ --button-background-color: var(--color-primary-500);
173
+ --button-hover-background-color: var(--color-primary-600);
174
+ --button-active-background-color: var(--color-primary-700);
175
+ --button-outlined-active-border-color: var(--color-primary-800);
176
+ }
177
+
178
+ .button-color-secondary {
179
+ --button-color: var(--color-emphasis-800);
180
+ --button-background-color: var(--color-secondary-400);
181
+ --button-hover-background-color: var(--color-secondary-500);
182
+ --button-active-background-color: var(--color-secondary-600);
183
+ --button-outlined-active-border-color: var(--color-secondary-700);
184
+ }
185
+
186
+ --button-small-font-size: 12px;
187
+ --button-small-padding: 8px 10px;
188
+ --button-small-min-width: 90px;
189
+ --button-medium-font-size: 14px;
190
+ --button-medium-padding: 8px 20px;
191
+ --button-medium-min-width: 120px;
192
+ --button-large-font-size: 14px;
193
+ --button-large-padding: 12px 24px;
194
+ --button-large-min-width: 150px;
195
+ --button-xlarge-font-size: 16px;
196
+ --button-xlarge-padding: 20px 24px;
197
+ --button-xlarge-min-width: 200px;
198
+
199
+ /*
200
+ * Tooltip
201
+ */
202
+ --tooltip-color: var(--color-secondary-300);
203
+ --tooltip-background-color: #52606d;
204
+
205
+ .tooltip-copy-button {
206
+ --tooltip-color: #000;
207
+ --tooltip-background-color: #fff;
208
+ }
209
+
210
+ /* === Markdown/Page content (tables, inline code, blockquotes) === */
211
+
212
+ /*
213
+ * Headings
214
+ * --h-{css-property-name} is fallback for h1...h6
215
+ */
216
+ --h-font-family: Source Sans Pro, sans-serif;
217
+ --h-font-weight: var(--font-weight-bolder);
218
+ --h-color: var(--color-content);
219
+
220
+ --h1-font-size: 36px;
221
+ --h2-font-size: 28px;
222
+ --h3-font-size: 18px;
223
+ --h4-font-size: 16px;
224
+ --h5-font-size: 14px;
225
+ --h6-font-size: 12px;
226
+
227
+ --h1-line-height: 36px;
228
+ --h2-line-height: 28px;
229
+ --h3-line-height: 18px;
230
+ --h4-line-height: 16px;
231
+ --h5-line-height: 14px;
232
+ --h6-line-height: 12px;
233
+
234
+ --code-font-size: 13px;
235
+ --code-font-family: var(--font-family-monospaced);
236
+ --code-font-weight: 400;
237
+ --code-wrap: pre;
238
+
239
+ --inline-code-font-size: var(--code-font-size);
240
+ --inline-code-font-family: var(--code-font-family);
241
+ --inline-code-color: #e53935;
242
+ --inline-code-background-color: var(--color-secondary-200);
243
+ --inline-code-border-color: var(--global-border-color);
244
+ --inline-code-border-radius: var(--global-border-radius);
245
+
246
+ --code-block-font-size: var(--code-font-size);
247
+ --code-block-font-family: var(--code-font-family);
248
+ --code-block-color: #f1928f;
249
+ --code-block-background-color: rgba(217, 205, 199, 0.05);
250
+ --code-block-border-color: var(--global-border-color);
251
+ --code-block-border-radius: 8px;
252
+ --code-block-max-height: 600px;
253
+ --code-block-word-break: initial;
254
+ --code-block-preformatted-background-color: #323f4b;
255
+
256
+ /*
257
+ * Links
258
+ */
259
+ --link-color: var(--color-primary-500);
260
+ --link-decoration: none;
261
+ --link-hover-color: var(--color-primary-100);
262
+ --link-hover-decoration: underline;
263
+
264
+ /* === ref docs and graphql docs specific === */
265
+ /*
266
+ * Logo
267
+ */
268
+ --logo-max-height: 285px;
269
+ --logo-max-width: 285px;
270
+ --logo-padding: 2px;
271
+
272
+ /*
273
+ * Http colors
274
+ */
275
+ --color-http-get: #3a9601;
276
+ --color-http-post: #0065fb;
277
+ --color-http-put: #93527b;
278
+ --color-http-options: #947014;
279
+ --color-http-patch: #bf581d;
280
+ --color-http-delete: #c83637;
281
+ --color-http-basic: #707070;
282
+ --color-http-link: #07818f;
283
+ --color-http-head: #a23dad;
284
+ --color-http-hook: var(--color-http-post);
285
+
286
+ /*
287
+ * Response colors
288
+ */
289
+ --response-success-border-color: #b1e996;
290
+ --response-success-background-color: #f6fff4;
291
+ --response-success-text-color: var(--response-success-border-color);
292
+
293
+ --response-error-border-color: #ffc9c9;
294
+ --response-error-background-color: #fff4f4;
295
+ --response-error-text-color: var(--response-error-border-color);
296
+
297
+ --response-redirect-border-color: var(--color-warning-500);
298
+ --response-redirect-background-color: #ffa5001a;
299
+ --response-redirect-text-color: var(--response-redirect-border-color);
300
+
301
+ --response-info-border-color: #87ceeb;
302
+ --response-info-background-color: #87ceeb1a;
303
+ --response-info-text-color: var(--response-info-border-color);
304
+
305
+ /*
306
+ * Panels
307
+ */
308
+ --panels-border-radius: 8px;
309
+ --panels-background-color: #fff;
310
+
311
+ --samples-panel-gap: 20px;
312
+ --samples-panel-width: 37.5%;
313
+ --samples-panel-block-background-color: #fff;
314
+ --samples-panel-background-color: #52606d;
315
+ --samples-panel-callback-background-color: var(--samples-panel-callback-background-color);
316
+ --samples-panel-controls-background-color: #323f4b;
317
+ --samples-panel-controls-hover-background-color: #3c4c5a;
318
+ --samples-panel-controls-active-border-color: var(--color-accent-500);
319
+ --samples-panel-text-color: #fff;
320
+ --samples-panel-heading-color: #fff;
321
+
322
+ --samples-panel-markdown-background-color: #3c4c5a;
323
+ --samples-panel-markdown-border-color: #46596a;
324
+
325
+ --try-it-panel-tab-background-color: var(--samples-panel-background-color);
326
+ --try-it-panel-active-tab-background-color: #47535e;
327
+ --try-it-panel-active-tab-border-color: var(--color-accent-500);
328
+ --try-it-panel-disabled-tab-color: rgba(245, 247, 250, 0.7);
329
+ --try-it-panel-controls-background-color: var(--samples-panel-controls-background-color);
330
+ --try-it-panel-action-button-width: auto;
331
+
332
+ --request-and-response-panel-background-color: #fff;
333
+
334
+ /*
335
+ * Layout
336
+ */
337
+ --layout-buttons-top-offset: 20px;
338
+ --layout-buttons-height: 36px;
339
+ --layout-buttons-width: 36px;
340
+
341
+ --layout-stacked-small-max-width: 90%;
342
+ --layout-stacked-medium-max-width: 75%;
343
+ --layout-stacked-large-max-width: 1200px;
344
+
345
+ --layout-three-panel-small-max-width: 100%;
346
+ --layout-three-panel-medium-max-width: 100%;
347
+ --layout-three-panel-large-max-width: 1800px;
348
+
349
+ --layout-middle-panel-small-max-width: none;
350
+ --layout-middle-panel-medium-max-width: none;
351
+ --layout-middle-panel-large-max-width: none;
352
+
353
+ /*
354
+ * Schema
355
+ */
356
+ --schema-lines-color: var(--global-border-color);
357
+ --schema-default-details-width: 70%;
358
+ --schema-type-name-color: var(--color-content-secondary);
359
+ --schema-type-title-color: var(--color-content-secondary);
360
+ --schema-require-label-color: var(--color-error-900);
361
+ --schema-labels-text-size: 0.9em;
362
+ --schema-nesting-spacing: 1em;
363
+ --schema-nested-background-color: var(--color-secondary-200);
364
+ --schema-chevron-color: var(--color-content);
365
+ --schema-chevron-size: 9px;
366
+
367
+ --schema-controls-color: var(--color-emphasis-800);
368
+ --schema-controls-background-color: var(--color-secondary-400);
369
+ --schema-controls-hover-background-color: var(--color-secondary-500);
370
+ --schema-controls-border-color: var(--color-secondary-600);
371
+
372
+ --field-name-font-size: var(--code-font-size);
373
+ --field-name-font-family: var(--code-font-family);
374
+ --field-enum-background-color: var(--inline-code-background-color);
375
+ --field-constraint-background-color: var(--inline-code-background-color);
376
+
377
+ /*
378
+ * Search
379
+ */
380
+ --search-input-border-bottom: #e6e6e6;
381
+ --search-results-background-color: #f2f2f2;
382
+ --search-results-active-item-background-color: #e6e6e6;
383
+ --search-marked-background-color: #ffff03;
384
+ --search-popup-header-background-color: var(--color-secondary-200);
385
+ --search-clear-button-background-color: var(--color-secondary-400);
386
+ --search-clear-button-hover-background-color: var(--color-secondary-600);
387
+
388
+ /*
389
+ * Other
390
+ */
391
+ --badge-color: var(--color-emphasis-100);
392
+ --badge-background-color: var(--color-primary-500);
393
+ --deprecated-badge-color: var(--color-emphasis-100);
394
+ --deprecated-badge-background-color: var(--color-warning-500);
395
+
396
+ --recursive-label-color: var(--color-warning-500);
397
+
398
+ --http-badge-font-size: 12px;
399
+ --http-badge-line-height: 20px;
400
+ --http-badge-font-family: var(--code-font-family);
401
+ --http-badge-font-weight: var(--font-weight-bold);
402
+ --http-badge-border-radius: 16px;
403
+ --http-badge-color: var(--color-content-inverse);
404
+
405
+ --http-badge-menu-font-size: 8px;
406
+ --http-badge-menu-line-height: 14px;
407
+
408
+ --spinner-color: var(--color-primary-500);
409
+
410
+ --linear-progress-color: var(--color-accent-500);
411
+ --linear-progress-background-color: var(--color-accent-100);
412
+
413
+ /* Floating action button */
414
+ --fab-color: #0065FB;
415
+ --fab-background-color: #f2f2f2;
416
+
417
+
418
+ /**
419
+ * Sidebar
420
+ * */
421
+ --sidebar-spacing-unit: 8px;
422
+ --sidebar-margin-left: calc(var(--sidebar-spacing-unit) * 2);
423
+ --sidebar-padding-horizontal: var(--sidebar-spacing-unit);
424
+ --sidebar-padding-vertical: var(--sidebar-spacing-unit);
425
+
426
+ --sidebar-spacing-padding-vertical: var(--sidebar-spacing-unit);
427
+ --sidebar-spacing-padding-horizontal: var(--sidebar-spacing-unit);
428
+ --sidebar-spacing-offset-top: calc(var(--sidebar-spacing-unit) * 2);
429
+ --sidebar-spacing-offset-left: calc(var(--sidebar-spacing-unit) * 2);
430
+ --sidebar-spacing-offset-nesting: calc(var(--sidebar-spacing-unit) * 2);
431
+
432
+ --sidebar-chevron-size: var(--sidebar-spacing-unit);
433
+ --sidebar-chevron-color: var(--sidebar-text-color);
434
+
435
+ --sidebar-border-radius: 4px;
436
+ --sidebar-background-color: #fff;
437
+ --sidebar-font-size: var(--font-size-base);
438
+ --sidebar-font-family: var(--font-family-primary);
439
+ --sidebar-right-line-color: var(--color-border-light);
440
+ --sidebar-text-color: var(--color-text-main);
441
+ --sidebar-text-active-color: var(--sidebar-text-color);
442
+ --sidebar-text-active-background-color: var(--color-border-light);
443
+ --sidebar-width: 285px;
444
+
445
+ --sidebar-separator-line-color: #dadada;
446
+ --sidebar-separator-label-color: var(--sidebar-text-color);
447
+
448
+ /**
449
+ * Portal Logo
450
+ * */
451
+ --logo-height: 2rem;
452
+ --logo-margin: var(--sidebar-margin-left);
453
+
454
+ /**
455
+ * Portal Navbar
456
+ * */
457
+ --navbar-height: 60px;
458
+ --navbar-color-text: var(--color-content-inverse);
459
+ --navbar-color-background: var(--color-primary-500);
460
+
461
+ /**
462
+ * Portal Navbar Item
463
+ * */
464
+ --navbar-item-font-size: 16px;
465
+ --navbar-item-margin-horizontal: 0;
466
+ --navbar-item-margin-vertical: 0;
467
+ --navbar-item-border-radius: 10px;
468
+ --navbar-item-font-weight: var(--font-weight-bold);
469
+ --navbar-item-active-background-color: #1b75fa;
470
+ --navbar-item-active-text-color: var(--color-primary-contrast);
471
+ --navbar-item-active-text-decoration: none;
472
+ }
473
+
474
+ @media (prefers-color-scheme: dark) {
475
+ :root {
476
+ --color-content: #f5f7fa;
477
+ --global-border-color: #4c4c4c;
478
+ --inline-code-color: #ed8282;
479
+ --schema-require-label-color: #e55252;
480
+ --global-background-color: #101010;
481
+ --sidebar-background-color: #101010;
482
+ --sidebar-item-active-background-color: #424242;
483
+ --samples-panel-block-background-color: var(--sidebar-background-color);
484
+ --color-secondary-200: #1f2933;
485
+ --color-primary-900: #4892ff;
486
+ --search-marked-background-color: #707000;
487
+
488
+ --response-success-border-color: #3c8d06;
489
+ --response-success-background-color: #2e7102;
490
+ --response-error-border-color: #8d5c5c;
491
+ --response-error-background-color: #802828;
492
+ --response-redirect-border-color: #ffa500;
493
+ --response-redirect-background-color: #ffa5001a;
494
+ --response-info-border-color: #87ceeb;
495
+ --response-info-background-color: #87ceeb1a;
496
+
497
+ --link-color: #4d91ff;
498
+ --link-hover-color: #3686ff;
499
+
500
+ --navbar-color-background: #f2f2f2;
501
+
502
+ .search-input {
503
+ color: var(--color-content);
504
+ }
505
+
506
+ .button-clear {
507
+ --color-secondary-600: #3e4c59;
508
+ --color-secondary-400: #1b1b1b;
509
+ }
510
+ }
511
+ }
512
+ `;
@@ -0,0 +1,3 @@
1
+ export * from './useControl';
2
+ export * from './useMount';
3
+ export * from './useUnmount';
@@ -0,0 +1,20 @@
1
+ import { useState, useCallback } from 'react';
2
+
3
+ export type UseControlReturnType = {
4
+ isOpened: boolean;
5
+ handleOpen: () => void;
6
+ handleClose: () => void;
7
+ };
8
+
9
+ export const useControl = (initialVal = false): UseControlReturnType => {
10
+ const [isOpened, setIsOpened] = useState<boolean>(initialVal);
11
+
12
+ const handleOpen = useCallback(() => setIsOpened(true), []);
13
+ const handleClose = useCallback(() => setIsOpened(false), []);
14
+
15
+ return {
16
+ isOpened,
17
+ handleOpen,
18
+ handleClose,
19
+ };
20
+ };