@redocly/theme 0.1.0 → 0.1.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.
- package/{lib/src/index.ts → index.js} +0 -0
- package/package.json +1 -2
- package/LICENSE +0 -1
- package/lib/package.json +0 -91
- package/lib/src/Button/Button.tsx +0 -122
- package/lib/src/Button/index.ts +0 -1
- package/lib/src/CodeBlock/CodeBlock.ts +0 -125
- package/lib/src/CodeBlock/index.ts +0 -1
- package/lib/src/CopyButton/CopyButton.tsx +0 -26
- package/lib/src/CopyButton/CopyButtonWrapper.tsx +0 -52
- package/lib/src/CopyButton/index.ts +0 -2
- package/lib/src/Headings/Headings.ts +0 -23
- package/lib/src/Headings/index.ts +0 -1
- package/lib/src/JsonViewer/JsonViewer.tsx +0 -130
- package/lib/src/JsonViewer/index.ts +0 -1
- package/lib/src/JsonViewer/styled.ts +0 -103
- package/lib/src/Logo/Logo.tsx +0 -23
- package/lib/src/Navbar/Navbar.tsx +0 -60
- package/lib/src/Navbar/NavbarItem.tsx +0 -90
- package/lib/src/Navbar/NavbarMenu.tsx +0 -29
- package/lib/src/Panel/CodePanel.ts +0 -31
- package/lib/src/Panel/ContentPanel.ts +0 -43
- package/lib/src/Panel/DarkHeader.ts +0 -8
- package/lib/src/Panel/Panel.ts +0 -18
- package/lib/src/Panel/PanelBody.ts +0 -30
- package/lib/src/Panel/PanelComponent.tsx +0 -73
- package/lib/src/Panel/PanelHeader.ts +0 -25
- package/lib/src/Panel/PanelHeaderTitle.ts +0 -11
- package/lib/src/Panel/index.ts +0 -7
- package/lib/src/SamplesPanelControls/SamplesPanelControls.ts +0 -70
- package/lib/src/SamplesPanelControls/index.ts +0 -1
- package/lib/src/SidebarLogo/SidebarLogo.tsx +0 -47
- package/lib/src/SidebarLogo/index.ts +0 -1
- package/lib/src/SourceCode/SourceCode.tsx +0 -67
- package/lib/src/SourceCode/index.ts +0 -1
- package/lib/src/Tooltip/Tooltip.tsx +0 -171
- package/lib/src/Tooltip/index.ts +0 -1
- package/lib/src/globalStyle.ts +0 -512
- package/lib/src/hooks/index.ts +0 -3
- package/lib/src/hooks/useControl.ts +0 -20
- package/lib/src/hooks/useMount.ts +0 -8
- package/lib/src/hooks/useUnmount.ts +0 -10
- package/lib/src/icons/ShelfIcon/ShelfIcon.tsx +0 -45
- package/lib/src/icons/ShelfIcon/index.ts +0 -2
- package/lib/src/icons/index.ts +0 -1
- package/lib/src/mocks/Link.tsx +0 -7
- package/lib/src/mocks/utils.ts +0 -3
- package/lib/src/utils/ClipboardService.ts +0 -92
- package/lib/src/utils/css-variables.ts +0 -2
- package/lib/src/utils/highlight.ts +0 -81
- package/lib/src/utils/index.ts +0 -6
- package/lib/src/utils/jsonToHtml.ts +0 -122
- package/lib/src/utils/media-css.ts +0 -16
- package/lib/src/utils/theme-helpers.ts +0 -34
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { highlight } from '../utils/highlight';
|
|
4
|
-
import { SampleControls, SampleControlsWrap, PreformattedCodeBlock } from '../SamplesPanelControls';
|
|
5
|
-
import { CopyButtonWrapper } from '../CopyButton';
|
|
6
|
-
|
|
7
|
-
export interface SourceCodeProps {
|
|
8
|
-
lang: string;
|
|
9
|
-
source?: string;
|
|
10
|
-
externalSource?: ExternalSource;
|
|
11
|
-
withCopyButton?: boolean;
|
|
12
|
-
dataTestId?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface Sample {
|
|
16
|
-
lang: string;
|
|
17
|
-
label?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type UnstableExternalCodeSample = Sample & {
|
|
21
|
-
get: (source: ExternalSource) => string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export interface ExternalSource {
|
|
25
|
-
sample: UnstableExternalCodeSample;
|
|
26
|
-
exampleName?: string;
|
|
27
|
-
pathParams?: any;
|
|
28
|
-
properties?: any;
|
|
29
|
-
operation?: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function Code({
|
|
33
|
-
source,
|
|
34
|
-
lang,
|
|
35
|
-
dataTestId,
|
|
36
|
-
}: Required<Omit<SourceCodeProps, 'externalSource' | 'withCopyButton'>>): JSX.Element {
|
|
37
|
-
return (
|
|
38
|
-
<PreformattedCodeBlock
|
|
39
|
-
dangerouslySetInnerHTML={{ __html: highlight(source, lang) }}
|
|
40
|
-
data-cy={dataTestId}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function SourceCode({
|
|
46
|
-
lang,
|
|
47
|
-
source,
|
|
48
|
-
externalSource,
|
|
49
|
-
withCopyButton,
|
|
50
|
-
dataTestId = 'source-code',
|
|
51
|
-
}: SourceCodeProps): JSX.Element {
|
|
52
|
-
const _source = source || externalSource?.sample?.get?.(externalSource) || '';
|
|
53
|
-
if (withCopyButton) {
|
|
54
|
-
return (
|
|
55
|
-
<CopyButtonWrapper data={source}>
|
|
56
|
-
{({ renderCopyButton }) => (
|
|
57
|
-
<SampleControlsWrap>
|
|
58
|
-
<SampleControls data-cy="copy-button">{renderCopyButton()}</SampleControls>
|
|
59
|
-
<Code lang={lang} source={_source} dataTestId={dataTestId} />
|
|
60
|
-
</SampleControlsWrap>
|
|
61
|
-
)}
|
|
62
|
-
</CopyButtonWrapper>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return <Code dataTestId={dataTestId} lang={lang} source={_source} />;
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SourceCode';
|
|
@@ -1,171 +0,0 @@
|
|
|
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
|
-
`;
|
package/lib/src/Tooltip/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Tooltip';
|