@redocly/theme 0.65.0-next.2 → 0.65.0-next.4
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/Banner/Banner.js +10 -2
- package/lib/components/Banner/variables.js +8 -1
- package/lib/components/Catalog/CatalogTags.js +1 -0
- package/lib/components/Catalog/variables.js +1 -0
- 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/Markdown/styles/links.js +2 -1
- package/lib/components/PageActions/PageActions.js +1 -0
- package/lib/components/Search/variables.js +1 -3
- 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/use-active-heading.js +2 -1
- package/lib/core/styles/dark.js +3 -3
- package/lib/core/styles/global.js +9 -8
- package/lib/core/styles/palette.dark.js +31 -0
- package/lib/core/styles/palette.js +53 -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/Cards/Card.js +1 -0
- package/lib/markdoc/components/Heading/Heading.js +12 -24
- package/package.json +1 -1
- package/src/components/Banner/Banner.tsx +11 -3
- package/src/components/Banner/variables.ts +8 -1
- package/src/components/Catalog/CatalogTags.tsx +1 -0
- package/src/components/Catalog/variables.ts +1 -0
- 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/Markdown/styles/links.ts +2 -1
- package/src/components/PageActions/PageActions.tsx +1 -0
- package/src/components/Search/variables.ts +3 -3
- 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/use-active-heading.ts +2 -1
- package/src/core/styles/dark.ts +3 -3
- package/src/core/styles/global.ts +9 -8
- package/src/core/styles/palette.dark.ts +31 -0
- package/src/core/styles/palette.ts +53 -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/Cards/Card.tsx +1 -0
- package/src/markdoc/components/Heading/Heading.tsx +36 -29
|
@@ -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) {
|
package/src/core/styles/dark.ts
CHANGED
|
@@ -294,10 +294,10 @@ export const darkMode = css`
|
|
|
294
294
|
* @tokens Links
|
|
295
295
|
*/
|
|
296
296
|
|
|
297
|
-
--link-color-primary: var(--color-
|
|
298
|
-
--link-color-primary-hover: var(--color-
|
|
297
|
+
--link-color-primary: var(--link-color-primary-palette, var(--link-color-primary-legacy)); // @presenter Color
|
|
298
|
+
--link-color-primary-hover: var(--link-color-primary-palette, var(--link-color-primary-hover-legacy)); // @presenter Color
|
|
299
299
|
--link-color-inverse: var(--color-blue-6); // @presenter Color
|
|
300
|
-
--link-color-visited: var(--color-
|
|
300
|
+
--link-color-visited: var(--link-color-primary-palette, var(--link-color-visited-legacy)); // @presenter Color
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
303
|
* @tokens Tab Colors
|
|
@@ -572,18 +572,19 @@ const links = css`
|
|
|
572
572
|
* @tokens Links
|
|
573
573
|
*/
|
|
574
574
|
|
|
575
|
-
--link-color-primary: var(--color-
|
|
576
|
-
--link-decoration:
|
|
577
|
-
--link-
|
|
575
|
+
--link-color-primary: var(--link-color-primary-palette, var(--link-color-primary-legacy)); // @presenter Color
|
|
576
|
+
--link-decoration: underline 1px var(--color-primary-base, var(--link-color-primary-legacy));
|
|
577
|
+
--link-underline-offset: 4px;
|
|
578
|
+
--link-font-weight: var(--font-weight-medium); // @presenter FontWeight
|
|
578
579
|
|
|
579
|
-
--link-color-primary-hover: var(--color-
|
|
580
|
-
--link-color-primary-pressed: var(--color-
|
|
581
|
-
--link-decoration-hover: underline;
|
|
580
|
+
--link-color-primary-hover: var(--link-color-primary-palette, var(--link-color-primary-hover-legacy)); // @presenter Color
|
|
581
|
+
--link-color-primary-pressed: var(--link-color-primary-palette, var(--link-color-primary-pressed-legacy));
|
|
582
|
+
--link-decoration-hover: underline 2px var(--color-primary-base, var(--link-color-primary-hover-legacy));
|
|
582
583
|
|
|
583
584
|
--link-color-inverse: var(--color-blue-5); // @presenter Color
|
|
584
585
|
|
|
585
|
-
--link-color-visited: var(--color-
|
|
586
|
-
--link-visited
|
|
586
|
+
--link-color-visited: var(--link-color-primary-palette, var(--link-color-visited-legacy)); // @presenter Color
|
|
587
|
+
--link-decoration-visited: underline 1px var(--color-primary-base, var(--link-color-visited-legacy));
|
|
587
588
|
|
|
588
589
|
// @tokens End
|
|
589
590
|
`;
|
|
@@ -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`
|
|
@@ -192,6 +219,10 @@ function brandPaletteDark(palette: string | undefined): FlattenSimpleInterpolati
|
|
|
192
219
|
--admonition-default-border-color-legacy: var(--color-warm-grey-5);
|
|
193
220
|
|
|
194
221
|
--code-block-highlighted-bg-color-legacy: color-mix(in srgb, var(--color-warm-grey-4) 40%, transparent);
|
|
222
|
+
|
|
223
|
+
--link-color-primary-legacy: var(--color-blue-7);
|
|
224
|
+
--link-color-primary-hover-legacy: var(--color-blue-8);
|
|
225
|
+
--link-color-visited-legacy: var(--color-purple-8);
|
|
195
226
|
`;
|
|
196
227
|
}
|
|
197
228
|
}
|
|
@@ -16,6 +16,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
16
16
|
--color-brand-10: #555761; // @presenter Color
|
|
17
17
|
--color-brand-11: #6e6f7a; // @presenter Color
|
|
18
18
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
19
|
+
|
|
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
|
|
19
24
|
`;
|
|
20
25
|
case 'pink':
|
|
21
26
|
return css`
|
|
@@ -31,6 +36,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
31
36
|
--color-brand-10: #6a3055; // @presenter Color
|
|
32
37
|
--color-brand-11: #4f2841; // @presenter Color
|
|
33
38
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
39
|
+
|
|
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
|
|
34
44
|
`;
|
|
35
45
|
case 'coral':
|
|
36
46
|
return css`
|
|
@@ -46,6 +56,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
46
56
|
--color-brand-10: #6d3338; // @presenter Color
|
|
47
57
|
--color-brand-11: #4f282b; // @presenter Color
|
|
48
58
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
59
|
+
|
|
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
|
|
49
64
|
`;
|
|
50
65
|
case 'amber':
|
|
51
66
|
return css`
|
|
@@ -61,6 +76,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
61
76
|
--color-brand-10: #71512e; // @presenter Color
|
|
62
77
|
--color-brand-11: #4f3c28; // @presenter Color
|
|
63
78
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
79
|
+
|
|
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
|
|
64
84
|
`;
|
|
65
85
|
case 'jade':
|
|
66
86
|
return css`
|
|
@@ -76,6 +96,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
76
96
|
--color-brand-10: #2a6052; // @presenter Color
|
|
77
97
|
--color-brand-11: #284f45; // @presenter Color
|
|
78
98
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
99
|
+
|
|
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
|
|
79
104
|
`;
|
|
80
105
|
case 'cyan':
|
|
81
106
|
return css`
|
|
@@ -91,6 +116,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
91
116
|
--color-brand-10: #285c67; // @presenter Color
|
|
92
117
|
--color-brand-11: #28484f; // @presenter Color
|
|
93
118
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
119
|
+
|
|
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
|
|
94
124
|
`;
|
|
95
125
|
case 'ocean':
|
|
96
126
|
return css`
|
|
@@ -106,6 +136,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
106
136
|
--color-brand-10: #2d5472; // @presenter Color
|
|
107
137
|
--color-brand-11: #283e4f; // @presenter Color
|
|
108
138
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
139
|
+
|
|
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
|
|
109
144
|
`;
|
|
110
145
|
case 'indigo':
|
|
111
146
|
return css`
|
|
@@ -121,6 +156,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
121
156
|
--color-brand-10: #303e6b; // @presenter Color
|
|
122
157
|
--color-brand-11: #28314f; // @presenter Color
|
|
123
158
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
159
|
+
|
|
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
|
|
124
164
|
`;
|
|
125
165
|
case 'iris':
|
|
126
166
|
return css`
|
|
@@ -136,6 +176,11 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
136
176
|
--color-brand-10: #3a3a6a; // @presenter Color
|
|
137
177
|
--color-brand-11: #2e2e4f; // @presenter Color
|
|
138
178
|
--text-color-on-color: #ffffff; // @presenter Color
|
|
179
|
+
|
|
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
|
|
139
184
|
`;
|
|
140
185
|
default:
|
|
141
186
|
return css`
|
|
@@ -177,6 +222,14 @@ function brandPaletteLight(palette: string | undefined): FlattenSimpleInterpolat
|
|
|
177
222
|
--button-content-color-link-legacy: var(--link-color-primary); // @presenter Color
|
|
178
223
|
--button-content-color-link-hover-legacy: var(--link-color-primary-hover); // @presenter Color
|
|
179
224
|
--button-content-color-link-pressed-legacy: var(--link-color-primary-pressed); // @presenter Color
|
|
225
|
+
|
|
226
|
+
--link-color-primary-legacy: var(--color-blue-6); // @presenter Color
|
|
227
|
+
--link-color-primary-hover-legacy: var(--color-blue-7); // @presenter Color
|
|
228
|
+
--link-color-primary-pressed-legacy: var(--color-blue-8); // @presenter Color
|
|
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
|
|
180
233
|
`;
|
|
181
234
|
}
|
|
182
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
|
}
|
|
@@ -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
|
}
|