@redocly/theme 0.65.0-next.3 → 0.65.0-next.5
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/Button/Button.d.ts +1 -0
- package/lib/components/Button/Button.js +14 -2
- package/lib/components/Catalog/CatalogTags.js +1 -0
- package/lib/components/Catalog/variables.js +1 -0
- package/lib/components/Dropdown/DropdownMenuItem.js +18 -6
- package/lib/components/LanguagePicker/LanguagePicker.js +3 -2
- package/lib/components/Markdown/Markdown.js +92 -26
- package/lib/components/Markdown/styles/base-table.js +2 -1
- package/lib/components/Markdown/styles/heading-anchor.d.ts +1 -1
- package/lib/components/Markdown/styles/heading-anchor.js +1 -1
- package/lib/components/Search/variables.js +1 -3
- package/lib/components/UserMenu/LoginButton.js +1 -1
- package/lib/core/constants/heading.d.ts +9 -0
- package/lib/core/constants/heading.js +13 -0
- package/lib/core/constants/index.d.ts +2 -0
- package/lib/core/constants/index.js +2 -0
- package/lib/core/constants/markdown.d.ts +1 -0
- package/lib/core/constants/markdown.js +5 -0
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.d.ts +0 -11
- package/lib/core/hooks/code-walkthrough/use-code-walkthrough-steps.js +7 -2
- package/lib/core/hooks/use-active-heading.js +2 -1
- package/lib/core/hooks/use-language-picker.d.ts +6 -1
- package/lib/core/hooks/use-language-picker.js +10 -2
- package/lib/core/styles/palette.dark.js +27 -0
- package/lib/core/styles/palette.js +30 -0
- package/lib/icons/AiStarsGradientIcon/AiStarsGradientIcon.js +2 -2
- package/lib/layouts/CodeWalkthroughLayout.js +3 -1
- package/lib/layouts/DocumentationLayout.js +3 -1
- package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +8 -7
- package/lib/markdoc/components/Heading/Heading.js +12 -24
- package/package.json +2 -2
- package/src/components/Button/Button.tsx +9 -2
- package/src/components/Catalog/CatalogTags.tsx +1 -0
- package/src/components/Catalog/variables.ts +1 -0
- package/src/components/Dropdown/DropdownMenuItem.tsx +27 -27
- package/src/components/LanguagePicker/LanguagePicker.tsx +3 -2
- package/src/components/Markdown/Markdown.tsx +102 -26
- package/src/components/Markdown/styles/base-table.ts +3 -1
- package/src/components/Markdown/styles/heading-anchor.ts +1 -1
- package/src/components/Search/variables.ts +3 -3
- package/src/components/UserMenu/LoginButton.tsx +1 -0
- package/src/core/constants/heading.ts +9 -0
- package/src/core/constants/index.ts +2 -0
- package/src/core/constants/markdown.ts +1 -0
- package/src/core/hooks/code-walkthrough/use-code-walkthrough-steps.ts +10 -2
- package/src/core/hooks/use-active-heading.ts +2 -1
- package/src/core/hooks/use-language-picker.ts +33 -8
- package/src/core/styles/palette.dark.ts +27 -0
- package/src/core/styles/palette.ts +30 -0
- package/src/icons/AiStarsGradientIcon/AiStarsGradientIcon.tsx +8 -2
- package/src/layouts/CodeWalkthroughLayout.tsx +3 -1
- package/src/layouts/DocumentationLayout.tsx +3 -1
- package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +7 -8
- package/src/markdoc/components/Heading/Heading.tsx +36 -29
|
@@ -2,7 +2,7 @@ import { css } from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
import type { FlattenSimpleInterpolation } from 'styled-components';
|
|
4
4
|
|
|
5
|
-
export function headingAnchorCss(className
|
|
5
|
+
export function headingAnchorCss(className: string): FlattenSimpleInterpolation {
|
|
6
6
|
return css`
|
|
7
7
|
.${className}.before {
|
|
8
8
|
position: absolute;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css } from 'styled-components';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
export const search = css`
|
|
5
5
|
/**
|
|
6
6
|
* @tokens Search
|
|
@@ -146,7 +146,7 @@ export const search = css`
|
|
|
146
146
|
* @tokens AI Search
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
-
--search-ai-gradient: linear-gradient(to right,
|
|
149
|
+
--search-ai-gradient: linear-gradient(to right, var(--search-ai-gradient-start-color, var(--search-ai-gradient-start-color-legacy)), var(--search-ai-gradient-end-color, var(--search-ai-gradient-end-color-legacy)));
|
|
150
150
|
|
|
151
151
|
--search-ai-response-padding: var(--spacing-lg);
|
|
152
152
|
--search-ai-response-gap: var(--spacing-sm);
|
|
@@ -262,4 +262,4 @@ export const search = css`
|
|
|
262
262
|
|
|
263
263
|
// @tokens End
|
|
264
264
|
`;
|
|
265
|
-
|
|
265
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const HEADING_ANCHOR_CLASS = 'heading-anchor';
|
|
2
|
+
export const ANCHOR_CLASS = 'anchor';
|
|
3
|
+
export const HEADING_CLASS_PREFIX = 'heading-level';
|
|
4
|
+
export const H1_CLASS = `${HEADING_CLASS_PREFIX}-1`;
|
|
5
|
+
export const H2_CLASS = `${HEADING_CLASS_PREFIX}-2`;
|
|
6
|
+
export const H3_CLASS = `${HEADING_CLASS_PREFIX}-3`;
|
|
7
|
+
export const H4_CLASS = `${HEADING_CLASS_PREFIX}-4`;
|
|
8
|
+
export const H5_CLASS = `${HEADING_CLASS_PREFIX}-5`;
|
|
9
|
+
export const H6_CLASS = `${HEADING_CLASS_PREFIX}-6`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MARKDOWN_CLASS_NAME = 'md';
|
|
@@ -153,7 +153,7 @@ export function useCodeWalkthroughSteps({
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
step.compRef = element;
|
|
156
|
-
setVisibleSteps((prevSteps) =>
|
|
156
|
+
setVisibleSteps((prevSteps) => insertVisibleStepInOrder(prevSteps, step));
|
|
157
157
|
},
|
|
158
158
|
[stepsMap],
|
|
159
159
|
);
|
|
@@ -365,7 +365,7 @@ function getGroups(steps: CodeWalkthroughStep[]): StepsGroup[] {
|
|
|
365
365
|
return groups;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
|
|
368
|
+
function getGroupMarkers(group: StepsGroup) {
|
|
369
369
|
if (!group.steps.length) {
|
|
370
370
|
return [];
|
|
371
371
|
}
|
|
@@ -440,3 +440,11 @@ function getNormalizedNumber(options: { min: number; max: number; value: number
|
|
|
440
440
|
|
|
441
441
|
return (value - min) / (max - min);
|
|
442
442
|
}
|
|
443
|
+
|
|
444
|
+
function insertVisibleStepInOrder(visible: StepWithIndex[], step: StepWithIndex): StepWithIndex[] {
|
|
445
|
+
const others = visible.filter((s) => s.id !== step.id);
|
|
446
|
+
const laterAt = others.findIndex((s) => s.index > step.index);
|
|
447
|
+
const at = laterAt === -1 ? others.length : laterAt;
|
|
448
|
+
|
|
449
|
+
return insertAt(others, at, step);
|
|
450
|
+
}
|
|
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
import { enhancedSmoothstep } from '../utils';
|
|
5
|
+
import { HEADING_ANCHOR_CLASS } from '../constants';
|
|
5
6
|
|
|
6
7
|
type HeadingEntry = {
|
|
7
8
|
[key: string]: IntersectionObserverEntry;
|
|
@@ -59,7 +60,7 @@ export function useActiveHeading(
|
|
|
59
60
|
);
|
|
60
61
|
|
|
61
62
|
const findHeaders = (allContent: HTMLDivElement) => {
|
|
62
|
-
const allHeaders = allContent.querySelectorAll<HTMLElement>(
|
|
63
|
+
const allHeaders = allContent.querySelectorAll<HTMLElement>(`.${HEADING_ANCHOR_CLASS}`);
|
|
63
64
|
const headers = Array.from(allHeaders);
|
|
64
65
|
|
|
65
66
|
if (displayedHeadingsRef.current && displayedHeadingsRef.current.length > 0) {
|
|
@@ -1,34 +1,59 @@
|
|
|
1
|
-
import { useNavigate } from 'react-router-dom';
|
|
1
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
2
2
|
|
|
3
3
|
import type { L10nConfig } from '../types/hooks';
|
|
4
4
|
|
|
5
5
|
import { useThemeHooks } from './use-theme-hooks';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
addLeadingSlash,
|
|
8
|
+
getPathnameForLocale,
|
|
9
|
+
withoutPathPrefix,
|
|
10
|
+
withPathPrefix,
|
|
11
|
+
} from '../utils/urls';
|
|
7
12
|
|
|
8
|
-
export
|
|
13
|
+
export type UseLanguagePickerResult = {
|
|
9
14
|
currentLocale: L10nConfig['locales'][number] | undefined;
|
|
10
15
|
locales: L10nConfig['locales'];
|
|
16
|
+
getLocaleUrl: (value: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `getLocaleUrl` to build the URL for the target locale, then pass it to `<Link>`.
|
|
19
|
+
*/
|
|
11
20
|
setLocale: (value: string) => void;
|
|
12
|
-
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function useLanguagePicker(): UseLanguagePickerResult {
|
|
13
24
|
const { useL10nConfig, useLoadAndNavigate } = useThemeHooks();
|
|
14
25
|
const navigate = useNavigate();
|
|
15
26
|
const loadAndNavigate = useLoadAndNavigate();
|
|
27
|
+
|
|
16
28
|
const { currentLocale, locales, defaultLocale } = useL10nConfig();
|
|
29
|
+
const location = useLocation();
|
|
17
30
|
|
|
18
31
|
const locale = locales.find((l) => l.code === currentLocale);
|
|
19
32
|
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
function getLocaleUrl(value: string): string {
|
|
34
|
+
let newLangPathname = getPathnameForLocale(
|
|
35
|
+
withoutPathPrefix(location.pathname),
|
|
36
|
+
defaultLocale,
|
|
37
|
+
value,
|
|
38
|
+
locales,
|
|
23
39
|
);
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
if (location.search) {
|
|
42
|
+
newLangPathname += location.search;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return addLeadingSlash(newLangPathname);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function setLocale(value: string): void {
|
|
49
|
+
const newUrlWithLanguage = withPathPrefix(getLocaleUrl(value));
|
|
26
50
|
loadAndNavigate({ navigate, to: newUrlWithLanguage });
|
|
27
51
|
}
|
|
28
52
|
|
|
29
53
|
return {
|
|
30
54
|
currentLocale: locale,
|
|
31
55
|
locales,
|
|
56
|
+
getLocaleUrl,
|
|
32
57
|
setLocale,
|
|
33
58
|
};
|
|
34
59
|
}
|
|
@@ -20,6 +20,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
20
20
|
--color-brand-subtle-3: #55576166;
|
|
21
21
|
--color-brand-subtle-4: #6e6f7a66;
|
|
22
22
|
--text-color-on-color: #000000;
|
|
23
|
+
|
|
24
|
+
--search-ai-gradient-start-color: var(--color-brand-3);
|
|
25
|
+
--search-ai-gradient-end-color: var(--color-brand-7);
|
|
23
26
|
`;
|
|
24
27
|
case 'pink':
|
|
25
28
|
return css`
|
|
@@ -39,6 +42,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
39
42
|
--color-brand-subtle-3: #85366866;
|
|
40
43
|
--color-brand-subtle-4: #a03a7b66;
|
|
41
44
|
--text-color-on-color: #ffffff;
|
|
45
|
+
|
|
46
|
+
--search-ai-gradient-start-color: var(--color-brand-5); // @presenter Color
|
|
47
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
42
48
|
`;
|
|
43
49
|
case 'coral':
|
|
44
50
|
return css`
|
|
@@ -58,6 +64,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
58
64
|
--color-brand-subtle-3: #8b3c4266;
|
|
59
65
|
--color-brand-subtle-4: #a9434c66;
|
|
60
66
|
--text-color-on-color: #ffffff;
|
|
67
|
+
|
|
68
|
+
--search-ai-gradient-start-color: var(--color-brand-4); // @presenter Color
|
|
69
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
61
70
|
`;
|
|
62
71
|
case 'amber':
|
|
63
72
|
return css`
|
|
@@ -77,6 +86,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
77
86
|
--color-brand-subtle-3: #93632f66;
|
|
78
87
|
--color-brand-subtle-4: #b6732a66;
|
|
79
88
|
--text-color-on-color: #ffffff;
|
|
89
|
+
|
|
90
|
+
--search-ai-gradient-start-color: var(--color-brand-5); // @presenter Color
|
|
91
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
80
92
|
`;
|
|
81
93
|
case 'jade':
|
|
82
94
|
return css`
|
|
@@ -96,6 +108,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
96
108
|
--color-brand-subtle-3: #2b715e66;
|
|
97
109
|
--color-brand-subtle-4: #2b816b66;
|
|
98
110
|
--text-color-on-color: #ffffff;
|
|
111
|
+
|
|
112
|
+
--search-ai-gradient-start-color: var(--color-brand-4);
|
|
113
|
+
--search-ai-gradient-end-color: var(--color-brand-7);
|
|
99
114
|
`;
|
|
100
115
|
case 'cyan':
|
|
101
116
|
return css`
|
|
@@ -115,6 +130,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
115
130
|
--color-brand-subtle-3: #246e7f66;
|
|
116
131
|
--color-brand-subtle-4: #1b809766;
|
|
117
132
|
--text-color-on-color: #ffffff;
|
|
133
|
+
|
|
134
|
+
--search-ai-gradient-start-color: var(--color-brand-4); // @presenter Color
|
|
135
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
118
136
|
`;
|
|
119
137
|
case 'ocean':
|
|
120
138
|
return css`
|
|
@@ -134,6 +152,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
134
152
|
--color-brand-subtle-3: #2a679566;
|
|
135
153
|
--color-brand-subtle-4: #2277b966;
|
|
136
154
|
--text-color-on-color: #ffffff;
|
|
155
|
+
|
|
156
|
+
--search-ai-gradient-start-color: var(--color-brand-4); // @presenter Color
|
|
157
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
137
158
|
`;
|
|
138
159
|
case 'indigo':
|
|
139
160
|
return css`
|
|
@@ -153,6 +174,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
153
174
|
--color-brand-subtle-3: #36498866;
|
|
154
175
|
--color-brand-subtle-4: #3952a466;
|
|
155
176
|
--text-color-on-color: #ffffff;
|
|
177
|
+
|
|
178
|
+
--search-ai-gradient-start-color: var(--color-brand-4); // @presenter Color
|
|
179
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
156
180
|
`;
|
|
157
181
|
case 'iris':
|
|
158
182
|
return css`
|
|
@@ -172,6 +196,9 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
172
196
|
--color-brand-subtle-3: #43438580;
|
|
173
197
|
--color-brand-subtle-4: #4c4ca080;
|
|
174
198
|
--text-color-on-color: #ffffff;
|
|
199
|
+
|
|
200
|
+
--search-ai-gradient-start-color: var(--color-brand-4); // @presenter Color
|
|
201
|
+
--search-ai-gradient-end-color: var(--color-brand-8); // @presenter Color
|
|
175
202
|
`;
|
|
176
203
|
default:
|
|
177
204
|
return css`
|
|
@@ -18,6 +18,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
18
18
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
19
19
|
|
|
20
20
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
21
|
+
|
|
22
|
+
--search-ai-gradient-start-color: var(--color-brand-10); // @presenter Color
|
|
23
|
+
--search-ai-gradient-end-color: var(--color-brand-7); // @presenter Color
|
|
21
24
|
`;
|
|
22
25
|
case 'pink':
|
|
23
26
|
return css`
|
|
@@ -35,6 +38,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
35
38
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
36
39
|
|
|
37
40
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
41
|
+
|
|
42
|
+
--search-ai-gradient-start-color: var(--color-brand-7); // @presenter Color
|
|
43
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
38
44
|
`;
|
|
39
45
|
case 'coral':
|
|
40
46
|
return css`
|
|
@@ -52,6 +58,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
52
58
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
53
59
|
|
|
54
60
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
61
|
+
|
|
62
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
63
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
55
64
|
`;
|
|
56
65
|
case 'amber':
|
|
57
66
|
return css`
|
|
@@ -69,6 +78,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
69
78
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
70
79
|
|
|
71
80
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
81
|
+
|
|
82
|
+
--search-ai-gradient-start-color: var(--color-brand-7); // @presenter Color
|
|
83
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
72
84
|
`;
|
|
73
85
|
case 'jade':
|
|
74
86
|
return css`
|
|
@@ -86,6 +98,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
86
98
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
87
99
|
|
|
88
100
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
101
|
+
|
|
102
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
103
|
+
--search-ai-gradient-end-color: var(--color-brand-5); // @presenter Color
|
|
89
104
|
`;
|
|
90
105
|
case 'cyan':
|
|
91
106
|
return css`
|
|
@@ -103,6 +118,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
103
118
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
104
119
|
|
|
105
120
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
121
|
+
|
|
122
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
123
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
106
124
|
`;
|
|
107
125
|
case 'ocean':
|
|
108
126
|
return css`
|
|
@@ -120,6 +138,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
120
138
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
121
139
|
|
|
122
140
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
141
|
+
|
|
142
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
143
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
123
144
|
`;
|
|
124
145
|
case 'indigo':
|
|
125
146
|
return css`
|
|
@@ -137,6 +158,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
137
158
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
138
159
|
|
|
139
160
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
161
|
+
|
|
162
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
163
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
140
164
|
`;
|
|
141
165
|
case 'iris':
|
|
142
166
|
return css`
|
|
@@ -154,6 +178,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
154
178
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
155
179
|
|
|
156
180
|
--link-color-primary-palette: var(--text-color-primary); // @presenter Color
|
|
181
|
+
|
|
182
|
+
--search-ai-gradient-start-color: var(--color-brand-8); // @presenter Color
|
|
183
|
+
--search-ai-gradient-end-color: var(--color-brand-4); // @presenter Color
|
|
157
184
|
`;
|
|
158
185
|
default:
|
|
159
186
|
return css`
|
|
@@ -200,6 +227,9 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
200
227
|
--link-color-primary-hover-legacy: var(--color-blue-7); // @presenter Color
|
|
201
228
|
--link-color-primary-pressed-legacy: var(--color-blue-8); // @presenter Color
|
|
202
229
|
--link-color-visited-legacy: var(--color-purple-7); // @presenter Color
|
|
230
|
+
|
|
231
|
+
--search-ai-gradient-start-color-legacy: #715efe; // @presenter Color
|
|
232
|
+
--search-ai-gradient-end-color-legacy: #ff5cdc; // @presenter Color
|
|
203
233
|
`;
|
|
204
234
|
}
|
|
205
235
|
}
|
|
@@ -36,8 +36,14 @@ const Icon = (props: AiStarsGradientIconProps) => {
|
|
|
36
36
|
{!isColorOverridden && (
|
|
37
37
|
<defs>
|
|
38
38
|
<linearGradient id="gradient" x1="0" y1="0" x2="1" y2="0">
|
|
39
|
-
<stop
|
|
40
|
-
|
|
39
|
+
<stop
|
|
40
|
+
offset="0%"
|
|
41
|
+
stopColor="var(--search-ai-gradient-start-color, var(--search-ai-gradient-start-color-legacy))"
|
|
42
|
+
/>
|
|
43
|
+
<stop
|
|
44
|
+
offset="100%"
|
|
45
|
+
stopColor="var(--search-ai-gradient-end-color, var(--search-ai-gradient-end-color-legacy))"
|
|
46
|
+
/>
|
|
41
47
|
</linearGradient>
|
|
42
48
|
</defs>
|
|
43
49
|
)}
|
|
@@ -3,6 +3,7 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import type { JSX } from 'react';
|
|
5
5
|
|
|
6
|
+
import { H1_CLASS } from '@redocly/theme/core/constants';
|
|
6
7
|
import { breakpoints } from '@redocly/theme/core/utils';
|
|
7
8
|
|
|
8
9
|
export type CodeWalkthroughLayoutProps = React.PropsWithChildren<{
|
|
@@ -76,7 +77,8 @@ const ContentWrapper = styled.section`
|
|
|
76
77
|
margin-right: auto;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
&:first-child > h1:first-child
|
|
80
|
+
&:first-child > h1:first-child,
|
|
81
|
+
&:first-child > .${H1_CLASS}:first-child {
|
|
80
82
|
// disable margin top for h1 on the title heading
|
|
81
83
|
margin-top: 0;
|
|
82
84
|
}
|
|
@@ -5,6 +5,7 @@ import type { JSX } from 'react';
|
|
|
5
5
|
import type { ResolvedNavItemWithLink, MarkdownConfig } from '@redocly/config';
|
|
6
6
|
|
|
7
7
|
import { breakpoints } from '@redocly/theme/core/utils';
|
|
8
|
+
import { H1_CLASS } from '@redocly/theme/core/constants';
|
|
8
9
|
import { CodeSnippetProvider } from '@redocly/theme/core/contexts/CodeSnippetContext';
|
|
9
10
|
import { DocumentationLayoutTop } from '@redocly/theme/layouts/DocumentationLayoutTop';
|
|
10
11
|
import { DocumentationLayoutBottom } from '@redocly/theme/layouts/DocumentationLayoutBottom';
|
|
@@ -70,7 +71,8 @@ const ContentWrapper = styled.section<{ withToc: boolean }>`
|
|
|
70
71
|
|
|
71
72
|
padding: var(--md-content-padding);
|
|
72
73
|
|
|
73
|
-
article:first-child > h1:first-child
|
|
74
|
+
article:first-child > h1:first-child,
|
|
75
|
+
article:first-child > .${H1_CLASS}:first-child {
|
|
74
76
|
// disable margin top for h1 on the title heading
|
|
75
77
|
margin-top: 0;
|
|
76
78
|
}
|
|
@@ -8,6 +8,7 @@ import React, {
|
|
|
8
8
|
useCallback,
|
|
9
9
|
} from 'react';
|
|
10
10
|
import styled from 'styled-components';
|
|
11
|
+
import { useLocation } from 'react-router-dom';
|
|
11
12
|
|
|
12
13
|
import type { WithConditions } from '@redocly/config';
|
|
13
14
|
|
|
@@ -29,6 +30,7 @@ export function CodeStep({
|
|
|
29
30
|
unless,
|
|
30
31
|
children,
|
|
31
32
|
}: PropsWithChildren<CodeStepProps>) {
|
|
33
|
+
const location = useLocation();
|
|
32
34
|
const compRef = useRef<HTMLDivElement | null>(null);
|
|
33
35
|
const markerRef = useRef<HTMLDivElement | null>(null);
|
|
34
36
|
|
|
@@ -79,16 +81,13 @@ export function CodeStep({
|
|
|
79
81
|
);
|
|
80
82
|
|
|
81
83
|
useEffect(() => {
|
|
82
|
-
// If the step is active during first render, scroll to it
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setTimeout(handleActivateStep, 5);
|
|
87
|
-
}
|
|
88
|
-
|
|
84
|
+
// If the step is active during navigation or first render, scroll to it
|
|
85
|
+
if (!isActive) return;
|
|
86
|
+
const timer = setTimeout(handleActivateStep, 5);
|
|
87
|
+
return () => clearTimeout(timer);
|
|
89
88
|
// Ignore dependency array because we only need to run this once
|
|
90
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, []);
|
|
90
|
+
}, [location.pathname]);
|
|
92
91
|
|
|
93
92
|
useEffect(() => {
|
|
94
93
|
const currentCompRef = compRef.current;
|
|
@@ -9,6 +9,12 @@ import { concatClassNames } from '@redocly/theme/core/utils';
|
|
|
9
9
|
import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
|
|
10
10
|
import { PageActions } from '@redocly/theme/components/PageActions/PageActions';
|
|
11
11
|
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
12
|
+
import {
|
|
13
|
+
ANCHOR_CLASS,
|
|
14
|
+
HEADING_ANCHOR_CLASS,
|
|
15
|
+
HEADING_CLASS_PREFIX,
|
|
16
|
+
MARKDOWN_CLASS_NAME,
|
|
17
|
+
} from '@redocly/theme/core/constants';
|
|
12
18
|
|
|
13
19
|
function renderWithSpanWrapper(children: ReactNode): ReactNode {
|
|
14
20
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -39,11 +45,6 @@ function renderWithSpanWrapper(children: ReactNode): ReactNode {
|
|
|
39
45
|
);
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
/**
|
|
43
|
-
* Class name for all MD tags
|
|
44
|
-
*/
|
|
45
|
-
const mdClassName = 'md';
|
|
46
|
-
|
|
47
48
|
export function Heading({
|
|
48
49
|
level,
|
|
49
50
|
id,
|
|
@@ -66,31 +67,43 @@ export function Heading({
|
|
|
66
67
|
|
|
67
68
|
const isMarkdownPage =
|
|
68
69
|
pageProps?.metadata?.type === 'markdown' || pageProps?.metadata?.type === 'asciidoc';
|
|
70
|
+
const headingTextId = `${id}-heading-text`;
|
|
69
71
|
|
|
70
72
|
const linkEl = (
|
|
71
73
|
<a
|
|
72
|
-
aria-
|
|
74
|
+
aria-labelledby={headingTextId}
|
|
73
75
|
href={`#${id}`}
|
|
74
|
-
className={concatClassNames(
|
|
76
|
+
className={concatClassNames(ANCHOR_CLASS, 'before')}
|
|
75
77
|
>
|
|
76
|
-
<LinkIcon color="--heading-anchor-color" />
|
|
78
|
+
<LinkIcon aria-hidden="true" focusable="false" color="--heading-anchor-color" />
|
|
77
79
|
</a>
|
|
78
80
|
);
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
const headingText = createElement(
|
|
81
83
|
`h${level}`,
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
{ id: headingTextId },
|
|
85
|
+
renderWithSpanWrapper(children),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div
|
|
90
|
+
id={id}
|
|
91
|
+
className={concatClassNames(
|
|
92
|
+
HEADING_ANCHOR_CLASS,
|
|
93
|
+
MARKDOWN_CLASS_NAME,
|
|
94
|
+
`${HEADING_CLASS_PREFIX}-${level}`,
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
data-component-name="Markdoc/Heading/Heading"
|
|
98
|
+
data-source={dataSource}
|
|
99
|
+
data-hash={dataHash}
|
|
100
|
+
>
|
|
101
|
+
<HeadingContentWrapper>
|
|
102
|
+
{linkEl}
|
|
103
|
+
{headingText}
|
|
104
|
+
{isMarkdownPage && __idx === 0 ? <PageActions pageSlug={pathname} /> : null}
|
|
105
|
+
</HeadingContentWrapper>
|
|
106
|
+
</div>
|
|
94
107
|
);
|
|
95
108
|
}
|
|
96
109
|
|
|
@@ -98,20 +111,14 @@ const HeadingContentWrapper = styled.div`
|
|
|
98
111
|
display: flex;
|
|
99
112
|
gap: var(--spacing-xs);
|
|
100
113
|
|
|
101
|
-
& >
|
|
114
|
+
& > .${ANCHOR_CLASS} {
|
|
102
115
|
display: flex;
|
|
103
116
|
align-items: center;
|
|
104
117
|
height: 1lh;
|
|
105
118
|
}
|
|
106
119
|
|
|
107
|
-
& > span {
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: flex-start;
|
|
110
|
-
gap: var(--spacing-sm);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
120
|
&:has([data-component-name='PageActions/PageActions']:hover) {
|
|
114
|
-
&&
|
|
121
|
+
&& .${ANCHOR_CLASS} svg {
|
|
115
122
|
visibility: hidden;
|
|
116
123
|
}
|
|
117
124
|
}
|