@redocly/theme 0.48.0 → 0.48.2
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/DatePicker/variables.js +1 -1
- 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/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.js +2 -6
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.d.ts +7 -10
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-controls.js +63 -97
- 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/styles/global.js +18 -0
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/utils/download-code-walkthrough.d.ts +4 -2
- 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-code-walkthrough-file-text.d.ts +4 -2
- 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 +25 -4
- package/lib/markdoc/components/CodeWalkthrough/CodeFilters.d.ts +5 -4
- 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 +5 -2
- package/lib/markdoc/components/CodeWalkthrough/CodeToggle.js +5 -5
- package/lib/markdoc/components/CodeWalkthrough/CodeWalkthrough.js +3 -3
- package/lib/markdoc/components/CodeWalkthrough/Input.js +7 -5
- package/lib/markdoc/tags/code-walkthrough.js +5 -0
- package/package.json +3 -3
- package/src/components/DatePicker/variables.ts +1 -1
- 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/contexts/CodeWalkthrough/CodeWalkthroughControlsContext.tsx +2 -8
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-controls.ts +90 -142
- 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/styles/global.ts +18 -0
- package/src/core/types/l10n.ts +3 -1
- package/src/core/utils/download-code-walkthrough.ts +16 -4
- package/src/core/utils/find-closest-common-directory.ts +51 -0
- package/src/core/utils/get-code-walkthrough-file-text.ts +3 -3
- 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 +28 -3
- package/src/markdoc/components/CodeWalkthrough/CodeFilters.tsx +21 -4
- 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 +5 -1
- package/src/markdoc/components/CodeWalkthrough/CodeToggle.tsx +5 -5
- package/src/markdoc/components/CodeWalkthrough/CodeWalkthrough.tsx +11 -5
- package/src/markdoc/components/CodeWalkthrough/Input.tsx +8 -6
- package/src/markdoc/tags/code-walkthrough.ts +5 -0
|
@@ -13,20 +13,20 @@ export type CodeToggleProps = React.PropsWithChildren<{
|
|
|
13
13
|
|
|
14
14
|
export function CodeToggle(props: CodeToggleProps) {
|
|
15
15
|
const { id, label, description, children } = props;
|
|
16
|
-
const {
|
|
16
|
+
const { getControlState, changeControlState } = useContext(CodeWalkthroughControlsStateContext);
|
|
17
17
|
|
|
18
|
-
const toggleState =
|
|
18
|
+
const toggleState = getControlState(id);
|
|
19
19
|
|
|
20
|
-
if (!(toggleState && toggleState.render)) {
|
|
20
|
+
if (!(toggleState && toggleState.render && typeof toggleState.value === 'boolean')) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
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
|
-
<Switch value={checked} onChange={(newValue) =>
|
|
29
|
+
<Switch value={checked} onChange={(newValue) => changeControlState(id, newValue)} />
|
|
30
30
|
<div>{label}</div>
|
|
31
31
|
</ToggleSubtitle>
|
|
32
32
|
{description ? (
|
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
} from '@redocly/theme/core/contexts';
|
|
10
10
|
import { CodePanel } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodePanel';
|
|
11
11
|
import { useCodeWalkthrough } from '@redocly/theme/core/hooks';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CodeFilters,
|
|
14
|
+
GetFilterState,
|
|
15
|
+
} from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeFilters';
|
|
13
16
|
import { StepWrapper } from '@redocly/theme/markdoc/components/CodeWalkthrough/CodeStep';
|
|
14
17
|
|
|
15
18
|
export type CodeWalkthroughProps = PropsWithChildren<CodeWalkthroughAttr>;
|
|
@@ -22,18 +25,21 @@ export function CodeWalkthrough({ children, steps, preview, ...attributes }: Cod
|
|
|
22
25
|
initialSteps,
|
|
23
26
|
attributes,
|
|
24
27
|
);
|
|
25
|
-
const { activeFilters,
|
|
28
|
+
const { activeFilters, getControlState, changeControlState } = controlsState;
|
|
26
29
|
const { filtersElementRef } = stepsState;
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
32
|
<CodeWalkthroughStepsContext.Provider value={stepsState}>
|
|
30
33
|
<CodeWalkthroughControlsStateContext.Provider value={controlsState}>
|
|
31
|
-
<CodeWalkthroughWrapper
|
|
34
|
+
<CodeWalkthroughWrapper
|
|
35
|
+
className="code-walkthrough"
|
|
36
|
+
data-component-name="Markdoc/CodeWalkthrough/CodeWalkthrough"
|
|
37
|
+
>
|
|
32
38
|
<DocsPanel>
|
|
33
39
|
<CodeFilters
|
|
34
40
|
filters={activeFilters}
|
|
35
|
-
getFilterState={
|
|
36
|
-
handleFilterSelect={
|
|
41
|
+
getFilterState={getControlState as GetFilterState}
|
|
42
|
+
handleFilterSelect={changeControlState}
|
|
37
43
|
filtersElementRef={filtersElementRef}
|
|
38
44
|
/>
|
|
39
45
|
<ContentWrapper>{children}</ContentWrapper>
|
|
@@ -15,16 +15,16 @@ const DEBOUNCE_TIME = 500;
|
|
|
15
15
|
|
|
16
16
|
export function Input(props: InputProps) {
|
|
17
17
|
const { id, label, placeholder } = props;
|
|
18
|
-
const {
|
|
18
|
+
const { getControlState, changeControlState } = useContext(CodeWalkthroughControlsStateContext);
|
|
19
19
|
|
|
20
|
-
const inputState =
|
|
20
|
+
const inputState = getControlState(id);
|
|
21
21
|
|
|
22
22
|
const [value, setValue] = useState(inputState?.value || '');
|
|
23
23
|
|
|
24
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
const debouncedSave = useCallback(
|
|
26
26
|
debounce((id: string, value: string) => {
|
|
27
|
-
|
|
27
|
+
changeControlState(id, value);
|
|
28
28
|
}, DEBOUNCE_TIME),
|
|
29
29
|
[],
|
|
30
30
|
);
|
|
@@ -41,11 +41,11 @@ 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}
|
|
48
|
-
value={value}
|
|
48
|
+
value={value as string}
|
|
49
49
|
onChange={handleChange}
|
|
50
50
|
aria-label={label}
|
|
51
51
|
placeholder={placeholder}
|
|
@@ -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`
|