@redocly/theme 0.48.0 → 0.48.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/components/Feedback/Mood.js +14 -9
- package/lib/components/Search/SearchDialog.js +9 -3
- package/lib/components/Search/variables.js +4 -0
- package/lib/components/Segmented/Segmented.d.ts +4 -4
- package/lib/components/Segmented/Segmented.js +4 -7
- package/lib/components/Tag/Tag.d.ts +1 -0
- package/lib/components/Tag/Tag.js +3 -2
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.d.ts +1 -1
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +10 -5
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +1 -2
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +20 -15
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.d.ts +2 -7
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough.js +10 -3
- package/lib/core/hooks/code-walkthrough/use-renderable-files.d.ts +9 -0
- package/lib/core/hooks/code-walkthrough/use-renderable-files.js +28 -0
- package/lib/core/hooks/index.d.ts +1 -0
- package/lib/core/hooks/index.js +1 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/utils/download-code-walkthrough.js +9 -1
- package/lib/core/utils/find-closest-common-directory.d.ts +6 -0
- package/lib/core/utils/find-closest-common-directory.js +51 -0
- package/lib/core/utils/get-file-icon.js +6 -0
- package/lib/core/utils/index.d.ts +1 -0
- package/lib/core/utils/index.js +1 -0
- package/lib/core/utils/replace-inputs-with-value.d.ts +1 -1
- package/lib/core/utils/replace-inputs-with-value.js +9 -10
- package/lib/icons/DocumentJavaIcon/DocumentJavaIcon.d.ts +9 -0
- package/lib/icons/DocumentJavaIcon/DocumentJavaIcon.js +22 -0
- package/lib/icons/DocumentJavaIcon/index.d.ts +1 -0
- package/lib/icons/DocumentJavaIcon/index.js +6 -0
- package/lib/icons/DocumentPythonIcon/DocumentPythonIcon.d.ts +9 -0
- package/lib/icons/DocumentPythonIcon/DocumentPythonIcon.js +23 -0
- package/lib/icons/DocumentPythonIcon/index.d.ts +1 -0
- package/lib/icons/DocumentPythonIcon/index.js +6 -0
- package/lib/icons/DocumentShellIcon/DocumentShellIcon.d.ts +9 -0
- package/lib/icons/DocumentShellIcon/DocumentShellIcon.js +22 -0
- package/lib/icons/DocumentShellIcon/index.d.ts +1 -0
- package/lib/icons/DocumentShellIcon/index.js +6 -0
- package/lib/icons/__tests__/IconTestUtils.d.ts +7 -0
- package/lib/icons/__tests__/IconTestUtils.js +33 -0
- package/lib/layouts/CodeWalkthroughLayout.js +4 -1
- package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/CodeFilters.js +15 -2
- package/lib/markdoc/components/CodeWalkthrough/CodePanel.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +29 -23
- package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/CodePanelToolbar.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +6 -3
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +1 -1
- package/lib/markdoc/components/CodeWalkthrough/Input.js +4 -2
- package/lib/markdoc/tags/code-walkthrough.js +5 -0
- package/package.json +3 -3
- package/src/components/Feedback/Mood.tsx +16 -7
- package/src/components/Search/SearchDialog.tsx +52 -36
- package/src/components/Search/variables.ts +4 -0
- package/src/components/Segmented/Segmented.tsx +10 -10
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +9 -3
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +30 -18
- package/src/core/hooks/code-walkthrough/use-code-walkthrough.ts +13 -13
- package/src/core/hooks/code-walkthrough/use-renderable-files.ts +51 -0
- package/src/core/hooks/index.ts +1 -0
- package/src/core/types/l10n.ts +3 -1
- package/src/core/utils/download-code-walkthrough.ts +14 -2
- package/src/core/utils/find-closest-common-directory.ts +51 -0
- package/src/core/utils/get-file-icon.ts +7 -0
- package/src/core/utils/index.ts +1 -0
- package/src/core/utils/replace-inputs-with-value.ts +12 -9
- package/src/icons/DocumentJavaIcon/DocumentJavaIcon.tsx +33 -0
- package/src/icons/DocumentJavaIcon/index.ts +1 -0
- package/src/icons/DocumentPythonIcon/DocumentPythonIcon.tsx +37 -0
- package/src/icons/DocumentPythonIcon/index.ts +1 -0
- package/src/icons/DocumentShellIcon/DocumentShellIcon.tsx +33 -0
- package/src/icons/DocumentShellIcon/index.ts +1 -0
- package/src/icons/__tests__/IconTestUtils.tsx +31 -0
- package/src/layouts/CodeWalkthroughLayout.tsx +5 -1
- package/src/markdoc/components/CodeWalkthrough/CodeContainer.tsx +1 -0
- package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +19 -3
- package/src/markdoc/components/CodeWalkthrough/CodePanel.tsx +1 -1
- package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +64 -47
- package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +1 -1
- package/src/markdoc/components/CodeWalkthrough/CodePanelToolbar.tsx +1 -1
- package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +6 -2
- package/src/markdoc/components/CodeWalkthrough/CodeToggle.tsx +1 -1
- package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +4 -1
- package/src/markdoc/components/CodeWalkthrough/Input.tsx +4 -2
- package/src/markdoc/tags/code-walkthrough.ts +5 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '@redocly/theme/icons/types';
|
|
5
|
+
|
|
6
|
+
import { getCssColorVariable } from '@redocly/theme/core/utils';
|
|
7
|
+
|
|
8
|
+
const Icon = (props: IconProps) => (
|
|
9
|
+
<svg
|
|
10
|
+
width="16"
|
|
11
|
+
height="16"
|
|
12
|
+
viewBox="0 0 16 16"
|
|
13
|
+
fill="none"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
<path
|
|
18
|
+
d="M14.5351 2.99992H3.83862C3.6752 3.00407 3.51738 3.06029 3.38814 3.16039C3.25891 3.26049 3.16501 3.39924 3.12012 3.55642L1.02012 12.4434C0.998149 12.5106 0.993246 12.5822 1.00585 12.6518C1.01845 12.7213 1.04817 12.7867 1.09232 12.8419C1.13646 12.8971 1.19365 12.9404 1.25874 12.968C1.32382 12.9956 1.39474 13.0066 1.46512 12.9999H12.1616C12.3249 12.9957 12.4827 12.9394 12.6118 12.8393C12.7409 12.7392 12.8348 12.6005 12.8796 12.4434L14.9801 3.55592C15.002 3.48876 15.0068 3.41722 14.9942 3.34773C14.9815 3.27825 14.9518 3.213 14.9076 3.15785C14.8635 3.10271 14.8064 3.05941 14.7413 3.03184C14.6763 3.00427 14.6054 2.9933 14.5351 2.99992ZM4.31312 11.8984C4.16872 11.9865 3.99731 12.0194 3.83057 11.9909C3.66383 11.9624 3.51306 11.8745 3.40612 11.7434L3.40262 11.7389C3.35483 11.6781 3.32075 11.6076 3.30269 11.5324C3.28463 11.4572 3.28302 11.3789 3.29797 11.303C3.31292 11.2271 3.34409 11.1554 3.38933 11.0926C3.43457 11.0298 3.49283 10.9776 3.56012 10.9394L8.36012 7.90892L5.30912 4.98292L5.30412 4.97792C5.24784 4.92482 5.20377 4.86011 5.17497 4.78829C5.14616 4.71647 5.13332 4.63924 5.13731 4.56196C5.14131 4.48469 5.16205 4.4092 5.1981 4.34073C5.23416 4.27226 5.28466 4.21244 5.34612 4.16542L5.36462 4.15042C5.49395 4.04749 5.65594 3.9944 5.82112 4.00082C5.98629 4.00725 6.14367 4.07275 6.26462 4.18542L9.88112 7.66392C9.96402 7.76867 10.006 7.90001 9.99912 8.03342C9.99485 8.11013 9.97427 8.18504 9.93875 8.25316C9.90323 8.32127 9.85358 8.38102 9.79312 8.42842C9.75612 8.44842 9.72012 8.48792 4.31762 11.8959L4.31312 11.8984ZM12.0001 11.4699C11.9905 11.6194 11.9221 11.7589 11.81 11.8582C11.6979 11.9575 11.5511 12.0084 11.4016 11.9999H8.58462C8.51096 12.0071 8.43662 11.9987 8.36638 11.9754C8.29614 11.9521 8.23156 11.9144 8.17677 11.8646C8.12199 11.8149 8.07822 11.7542 8.04828 11.6865C8.01834 11.6188 8.00289 11.5457 8.00293 11.4716C8.00296 11.3976 8.01848 11.3245 8.04848 11.2568C8.07849 11.1892 8.12231 11.1285 8.17714 11.0788C8.23197 11.0291 8.2966 10.9915 8.36686 10.9682C8.43712 10.945 8.51147 10.9367 8.58512 10.9439H11.4016C11.5503 10.9353 11.6965 10.9855 11.8085 11.0837C11.9205 11.182 11.9893 11.3203 12.0001 11.4689V11.4699Z"
|
|
19
|
+
fill="#3B3C45"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export const DocumentShellIcon = styled(Icon).attrs(() => ({
|
|
25
|
+
'data-component-name': 'icons/DocumentShellIcon/DocumentShellIcon',
|
|
26
|
+
}))<IconProps>`
|
|
27
|
+
path {
|
|
28
|
+
fill: ${({ color }) => getCssColorVariable(color)};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
height: ${({ size }) => size || '16px'};
|
|
32
|
+
width: ${({ size }) => size || '16px'};
|
|
33
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DocumentShellIcon } from '@redocly/theme/icons/DocumentShellIcon/DocumentShellIcon';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
export function testIconComponent(IconComponent: React.ComponentType<any>, componentName: string) {
|
|
6
|
+
const dataName = `icons/${componentName}/${componentName}`;
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
rendersCorrectlyWithDefaultProps: () => {
|
|
10
|
+
const { container } = render(<IconComponent />);
|
|
11
|
+
const svgElement = container.querySelector('svg');
|
|
12
|
+
expect(svgElement).toBeInTheDocument();
|
|
13
|
+
expect(container.firstChild).toHaveStyle('height: 16px; width: 16px;');
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
appliesCustomSizeAndColor: () => {
|
|
17
|
+
const { container } = render(<IconComponent size="24px" color="--color-primary" />);
|
|
18
|
+
|
|
19
|
+
const svgElement = container.querySelector('svg');
|
|
20
|
+
expect(svgElement).toBeInTheDocument();
|
|
21
|
+
expect(container.firstChild).toHaveStyle('height: 24px; width: 24px;');
|
|
22
|
+
const pathElement = container.querySelector('path');
|
|
23
|
+
expect(pathElement).toHaveStyle('fill: var(--color-primary);');
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
hasCorrectDataComponentName: () => {
|
|
27
|
+
const { container } = render(<IconComponent />);
|
|
28
|
+
expect(container.firstChild).toHaveAttribute('data-component-name', dataName);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
+
import { breakpoints } from '@redocly/theme/core';
|
|
5
|
+
|
|
4
6
|
export type CodeWalkthroughLayoutProps = React.PropsWithChildren<{
|
|
5
7
|
className?: string;
|
|
6
8
|
}>;
|
|
@@ -66,8 +68,10 @@ const ContentWrapper = styled.section`
|
|
|
66
68
|
|
|
67
69
|
/* Full-width styling for all .code-walkthroughs */
|
|
68
70
|
.code-walkthrough {
|
|
69
|
-
max-width: none;
|
|
70
71
|
width: 100%;
|
|
72
|
+
max-width: ${breakpoints.max};
|
|
73
|
+
margin-left: auto;
|
|
74
|
+
margin-right: auto;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
&:first-child > h1:first-child {
|
|
@@ -3,7 +3,7 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import type { CodeWalkthroughFilter } from '@redocly/config';
|
|
5
5
|
|
|
6
|
-
import { Tag } from '@redocly/theme/components/Tag/Tag';
|
|
6
|
+
import { Tag, ContentWrapper as TagContentWrapper } from '@redocly/theme/components/Tag/Tag';
|
|
7
7
|
|
|
8
8
|
export type CodeFilterProps = {
|
|
9
9
|
filters: CodeWalkthroughFilter[];
|
|
@@ -23,7 +23,10 @@ export function CodeFilters({
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<FilterWrapper
|
|
26
|
+
<FilterWrapper
|
|
27
|
+
ref={filtersElementRef}
|
|
28
|
+
data-component-name="Markdoc/CodeWalkthrough/CodeFilters"
|
|
29
|
+
>
|
|
27
30
|
{filters.map(({ label, items, id }) => {
|
|
28
31
|
return (
|
|
29
32
|
<Filter key={id}>
|
|
@@ -50,8 +53,9 @@ export function CodeFilters({
|
|
|
50
53
|
|
|
51
54
|
const Filter = styled.div`
|
|
52
55
|
display: flex;
|
|
53
|
-
align-items:
|
|
56
|
+
align-items: flex-start;
|
|
54
57
|
gap: var(--spacing-xs);
|
|
58
|
+
max-width: 100%;
|
|
55
59
|
`;
|
|
56
60
|
|
|
57
61
|
const FilterName = styled.div`
|
|
@@ -74,14 +78,26 @@ const FilterWrapper = styled.div`
|
|
|
74
78
|
top: calc(var(--navbar-height));
|
|
75
79
|
background-color: var(--bg-color);
|
|
76
80
|
z-index: 1;
|
|
81
|
+
max-width: var(--md-content-max-width);
|
|
77
82
|
`;
|
|
78
83
|
|
|
79
84
|
const ButtonsWrapper = styled.div`
|
|
80
85
|
display: flex;
|
|
86
|
+
min-width: 0;
|
|
87
|
+
flex-wrap: wrap;
|
|
81
88
|
`;
|
|
82
89
|
|
|
83
90
|
const TagButton = styled(Tag)`
|
|
84
91
|
cursor: pointer;
|
|
85
92
|
padding: 0px var(--spacing-xs);
|
|
86
93
|
margin-right: var(--spacing-xs);
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
margin-bottom: var(--spacing-xs);
|
|
96
|
+
|
|
97
|
+
${TagContentWrapper} {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
}
|
|
87
103
|
`;
|
|
@@ -25,7 +25,7 @@ export function CodePanel({
|
|
|
25
25
|
const { handleDownloadCode } = useContext(CodeWalkthroughControlsStateContext);
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<CodePanelWrapper>
|
|
28
|
+
<CodePanelWrapper data-component-name="Markdoc/CodeWalkthrough/CodePanel">
|
|
29
29
|
{preview ? (
|
|
30
30
|
<CodePanelPreview>
|
|
31
31
|
{preview.map((element, idx) => (
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import type { CodeWalkthroughFile } from '@redocly/config';
|
|
5
5
|
|
|
6
|
-
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
7
|
-
import { getFileIconByExt } from '@redocly/theme/core/utils';
|
|
6
|
+
import { useThemeHooks, useRenderableFiles, type RenderableFile } from '@redocly/theme/core/hooks';
|
|
8
7
|
import { OverflowMenuVerticalIcon } from '@redocly/theme/icons/OverflowMenuVerticalIcon/OverflowMenuVerticalIcon';
|
|
9
8
|
import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
|
|
10
9
|
import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
|
|
@@ -25,32 +24,45 @@ export function CodePanelHeader({
|
|
|
25
24
|
activeTabName,
|
|
26
25
|
onDownloadCode,
|
|
27
26
|
}: CodePanelHeaderProps): JSX.Element {
|
|
27
|
+
const renderableFiles = useRenderableFiles(files);
|
|
28
28
|
const { useTranslate } = useThemeHooks();
|
|
29
29
|
const { translate } = useTranslate();
|
|
30
30
|
const tabRefs = useRef<HTMLButtonElement[]>([]);
|
|
31
31
|
const tabsWrapperRef = useRef<HTMLDivElement>(null);
|
|
32
|
-
const [hiddenFiles, setHiddenFiles] = useState<
|
|
32
|
+
const [hiddenFiles, setHiddenFiles] = useState<RenderableFile[]>([]);
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
35
35
|
const activeTab = tabRefs.current.find((tab) => tab?.dataset.name === activeTabName);
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const tabsWrapper = tabsWrapperRef.current;
|
|
37
|
+
|
|
38
|
+
if (activeTab && tabsWrapper) {
|
|
39
|
+
const { left: wrapperLeft, right: wrapperRight } = tabsWrapper.getBoundingClientRect();
|
|
40
|
+
const { left: tabLeft, right: tabRight } = activeTab.getBoundingClientRect();
|
|
41
|
+
const tabHidden = tabLeft < wrapperLeft || tabRight > wrapperRight;
|
|
42
|
+
|
|
43
|
+
if (tabHidden) {
|
|
44
|
+
activeTab.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
|
-
}, [activeTabName]);
|
|
40
47
|
|
|
41
|
-
useEffect(() => {
|
|
42
48
|
const calculateHiddenFiles = () => {
|
|
43
49
|
if (!tabsWrapperRef.current) return;
|
|
44
50
|
const { left: wrapperLeft, right: wrapperRight } =
|
|
45
51
|
tabsWrapperRef.current.getBoundingClientRect();
|
|
46
52
|
|
|
47
|
-
const hidden =
|
|
53
|
+
const hidden: RenderableFile[] = [];
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < renderableFiles.length; i++) {
|
|
48
56
|
const tab = tabRefs.current[i];
|
|
49
|
-
if (!tab)
|
|
57
|
+
if (!tab) continue;
|
|
58
|
+
|
|
50
59
|
const { left: tabLeft, right: tabRight } = tab.getBoundingClientRect();
|
|
60
|
+
const visible = tabLeft > wrapperLeft && tabRight < wrapperRight;
|
|
51
61
|
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
if (!visible) {
|
|
63
|
+
hidden.push(renderableFiles[i]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
54
66
|
|
|
55
67
|
setHiddenFiles(hidden);
|
|
56
68
|
};
|
|
@@ -58,32 +70,29 @@ export function CodePanelHeader({
|
|
|
58
70
|
calculateHiddenFiles();
|
|
59
71
|
window.addEventListener('resize', calculateHiddenFiles);
|
|
60
72
|
return () => window.removeEventListener('resize', calculateHiddenFiles);
|
|
61
|
-
}, [files]);
|
|
62
|
-
|
|
63
|
-
const getFileTypeIcon = useCallback((basename: string) => {
|
|
64
|
-
const extension = basename.split('.').pop()?.toLowerCase() || '';
|
|
65
|
-
return getFileIconByExt(extension);
|
|
66
|
-
}, []);
|
|
73
|
+
}, [activeTabName, files, renderableFiles]);
|
|
67
74
|
|
|
68
75
|
return (
|
|
69
76
|
<CodePanelHeaderWrapper data-component-name="Markdoc/CodeWalkthrough/CodePanelHeader">
|
|
70
77
|
<TabsWrapper ref={tabsWrapperRef}>
|
|
71
78
|
<Tabs>
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
{renderableFiles.map(
|
|
80
|
+
({ path, basename, FileIcon, parentFolder, isNameDuplicate, inRootDir }, i) => {
|
|
81
|
+
return (
|
|
82
|
+
<Tab
|
|
83
|
+
ref={(el: HTMLButtonElement) => (tabRefs.current[i] = el)}
|
|
84
|
+
data-name={path}
|
|
85
|
+
active={path === activeTabName}
|
|
86
|
+
key={i}
|
|
87
|
+
onClick={() => handleTabSwitch(path)}
|
|
88
|
+
>
|
|
89
|
+
<FileIcon />
|
|
90
|
+
{basename}
|
|
91
|
+
{isNameDuplicate && !inRootDir ? <Dirname>{parentFolder}</Dirname> : null}
|
|
92
|
+
</Tab>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
)}
|
|
87
96
|
</Tabs>
|
|
88
97
|
<Gradient />
|
|
89
98
|
</TabsWrapper>
|
|
@@ -92,18 +101,21 @@ export function CodePanelHeader({
|
|
|
92
101
|
{hiddenFiles.length ? (
|
|
93
102
|
<Dropdown trigger={<StyledOverflowMenuVerticalIcon size="14px" />} alignment="end">
|
|
94
103
|
<StyledDropdownMenu>
|
|
95
|
-
{hiddenFiles.map(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
{hiddenFiles.map(
|
|
105
|
+
({ path, basename, FileIcon, isNameDuplicate, inRootDir, parentFolder }, i) => {
|
|
106
|
+
return (
|
|
107
|
+
<DropdownMenuItem
|
|
108
|
+
active={path === activeTabName}
|
|
109
|
+
key={i}
|
|
110
|
+
onAction={() => handleTabSwitch(path)}
|
|
111
|
+
prefix={<FileIcon />}
|
|
112
|
+
content={
|
|
113
|
+
isNameDuplicate && !inRootDir ? `${parentFolder}/${basename}` : basename
|
|
114
|
+
}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
)}
|
|
107
119
|
</StyledDropdownMenu>
|
|
108
120
|
</Dropdown>
|
|
109
121
|
) : null}
|
|
@@ -141,7 +153,7 @@ const Gradient = styled.div`
|
|
|
141
153
|
|
|
142
154
|
const Tabs = styled.div`
|
|
143
155
|
display: flex;
|
|
144
|
-
overflow-x:
|
|
156
|
+
overflow-x: hidden;
|
|
145
157
|
padding-right: var(--spacing-base);
|
|
146
158
|
|
|
147
159
|
&::-webkit-scrollbar {
|
|
@@ -149,6 +161,11 @@ const Tabs = styled.div`
|
|
|
149
161
|
}
|
|
150
162
|
`;
|
|
151
163
|
|
|
164
|
+
const Dirname = styled.span`
|
|
165
|
+
font-size: var(--font-size-sm);
|
|
166
|
+
color: var(--text-color-description);
|
|
167
|
+
`;
|
|
168
|
+
|
|
152
169
|
const ActionBar = styled.div`
|
|
153
170
|
display: flex;
|
|
154
171
|
`;
|
|
@@ -164,7 +181,7 @@ const Tab = styled.button<{ active: boolean }>`
|
|
|
164
181
|
gap: var(--spacing-xs);
|
|
165
182
|
color: var(--text-color-secondary);
|
|
166
183
|
white-space: nowrap;
|
|
167
|
-
|
|
184
|
+
scroll-margin-right: var(--spacing-base);
|
|
168
185
|
${({ active }) =>
|
|
169
186
|
active
|
|
170
187
|
? css`
|
|
@@ -11,7 +11,7 @@ export function CodePanelPreview({ children }: PropsWithChildren): JSX.Element {
|
|
|
11
11
|
const { translate } = useTranslate();
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<CodePanelPreviewWrapper>
|
|
14
|
+
<CodePanelPreviewWrapper data-component-name="Markdoc/CodeWalkthrough/CodePanelPreview">
|
|
15
15
|
<PreviewDropdown onClick={() => setIsOpen(!isOpen)}>
|
|
16
16
|
{translate('codeWalkthrough.preview', 'Preview')}
|
|
17
17
|
{isOpen ? <ChevronUpIcon /> : <ChevronDownIcon />}
|
|
@@ -16,7 +16,7 @@ export function CodePanelToolbar({ file }: CodeToolbarProps): JSX.Element {
|
|
|
16
16
|
const fileContent = getFileText(file);
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<CodeToolbarWrapper>
|
|
19
|
+
<CodeToolbarWrapper data-component-name="Markdoc/CodeWalkthrough/CodePanelToolbar">
|
|
20
20
|
<CopyButton data={fileContent} type="compound" variant="secondary" size="medium" />
|
|
21
21
|
</CodeToolbarWrapper>
|
|
22
22
|
);
|
|
@@ -35,7 +35,7 @@ export function CodeStep({
|
|
|
35
35
|
lockObserver.current = true;
|
|
36
36
|
|
|
37
37
|
if (compRef.current) {
|
|
38
|
-
compRef.current.scrollIntoView({ behavior: 'smooth', block: '
|
|
38
|
+
compRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
setActiveStep(id);
|
|
@@ -70,7 +70,7 @@ export function CodeStep({
|
|
|
70
70
|
|
|
71
71
|
const filtersElementHeight = filtersElementRef?.current?.clientHeight || 0;
|
|
72
72
|
const navbarHeight = document.querySelector('nav')?.clientHeight || 0;
|
|
73
|
-
setScrollMarginTop(filtersElementHeight + navbarHeight);
|
|
73
|
+
setScrollMarginTop(filtersElementHeight + navbarHeight + 10);
|
|
74
74
|
|
|
75
75
|
return () => {
|
|
76
76
|
if (currentCompRef) {
|
|
@@ -80,11 +80,15 @@ export function CodeStep({
|
|
|
80
80
|
}, [activeStep, register, unregister, filtersElementRef]);
|
|
81
81
|
|
|
82
82
|
if (!areConditionsMet({ when, unless })) {
|
|
83
|
+
if (isActive) {
|
|
84
|
+
setActiveStep(null);
|
|
85
|
+
}
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
return (
|
|
87
90
|
<StepWrapper
|
|
91
|
+
data-component-name="Markdoc/CodeWalkthrough/CodeStep"
|
|
88
92
|
ref={compRef}
|
|
89
93
|
isActive={isActive}
|
|
90
94
|
scrollMarginTop={scrollMarginTop}
|
|
@@ -23,7 +23,7 @@ export function CodeToggle(props: CodeToggleProps) {
|
|
|
23
23
|
const checked = toggleState.value;
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<ToggleWrapper>
|
|
26
|
+
<ToggleWrapper data-component-name="Markdoc/CodeWalkthrough/CodeToggle">
|
|
27
27
|
<ToggleContentWrapper>
|
|
28
28
|
<ToggleSubtitle>
|
|
29
29
|
<Switch value={checked} onChange={(newValue) => changeToggleState(id, newValue)} />
|
|
@@ -28,7 +28,10 @@ export function CodeWalkthrough({ children, steps, preview, ...attributes }: Cod
|
|
|
28
28
|
return (
|
|
29
29
|
<CodeWalkthroughStepsContext.Provider value={stepsState}>
|
|
30
30
|
<CodeWalkthroughControlsStateContext.Provider value={controlsState}>
|
|
31
|
-
<CodeWalkthroughWrapper
|
|
31
|
+
<CodeWalkthroughWrapper
|
|
32
|
+
className="code-walkthrough"
|
|
33
|
+
data-component-name="Markdoc/CodeWalkthrough/CodeWalkthrough"
|
|
34
|
+
>
|
|
32
35
|
<DocsPanel>
|
|
33
36
|
<CodeFilters
|
|
34
37
|
filters={activeFilters}
|
|
@@ -41,7 +41,7 @@ export function Input(props: InputProps) {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
|
-
<InputWrapper>
|
|
44
|
+
<InputWrapper data-component-name="Markdoc/CodeWalkthrough/Input">
|
|
45
45
|
{label && <Label>{label}</Label>}
|
|
46
46
|
<StyledInput
|
|
47
47
|
id={id}
|
|
@@ -57,7 +57,8 @@ export function Input(props: InputProps) {
|
|
|
57
57
|
const InputWrapper = styled.div`
|
|
58
58
|
display: flex;
|
|
59
59
|
flex-direction: column;
|
|
60
|
-
margin: var(--
|
|
60
|
+
margin-top: var(--spacing-base);
|
|
61
|
+
margin-bottom: var(--spacing-base);
|
|
61
62
|
`;
|
|
62
63
|
|
|
63
64
|
const Label = styled.p`
|
|
@@ -66,6 +67,7 @@ const Label = styled.p`
|
|
|
66
67
|
line-height: var(--line-height-base);
|
|
67
68
|
font-family: var(--font-family-base);
|
|
68
69
|
font-weight: var(--font-weight-medium);
|
|
70
|
+
margin-bottom: var(--spacing-xxs) !important;
|
|
69
71
|
`;
|
|
70
72
|
|
|
71
73
|
const StyledInput = styled.input`
|