Skip to content

Commit 4487fc9

Browse files
authored
engine: fix doc feedback on mobile, after last upgrade (#847)
1 parent 100c4ad commit 4487fc9

File tree

2 files changed

+59
-58
lines changed

2 files changed

+59
-58
lines changed

docs/.vuepress/components/TocWithFeedback.ts

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -413,66 +413,62 @@ export default defineComponent({
413413
const before = slots.before?.();
414414
const after = slots.after?.();
415415

416-
const tocContent =
417-
tocHeaders || before || after
418-
? h("div", { class: "vp-toc-placeholder" }, [
419-
h("aside", { id: "toc", "vp-toc": "" }, [
420-
// Optional "before" slot
421-
before,
422-
// The TOC itself
423-
tocHeaders
424-
? [
425-
h(
426-
"div",
427-
{ class: "vp-toc-header", onClick: toggleExpanded },
428-
[
429-
metaLocale.value.toc,
430-
h(PrintButton),
431-
h("div", {
432-
class: ["arrow", isExpanded.value ? "down" : "end"],
433-
}),
434-
]
435-
),
436-
h(
437-
"div",
438-
{
439-
class: [
440-
"vp-toc-wrapper",
441-
isExpanded.value ? "open" : "",
442-
],
443-
ref: toc,
416+
return h(ClientOnly, () => {
417+
if (!tocHeaders && !before && !after) return null;
418+
419+
// Main TOC container
420+
const tocContent = h("div", { class: "vp-toc-placeholder" }, [
421+
h("aside", { id: "toc", "vp-toc": "" }, [
422+
before,
423+
tocHeaders
424+
? [
425+
h(
426+
"div",
427+
{
428+
class: "vp-toc-header",
429+
onClick: () => toggleExpanded(),
430+
},
431+
[
432+
metaLocale.value.toc,
433+
h(PrintButton),
434+
h("div", {
435+
class: ["arrow", isExpanded.value ? "down" : "end"],
436+
}),
437+
]
438+
),
439+
h(
440+
"div",
441+
{
442+
class: ["vp-toc-wrapper", isExpanded.value ? "open" : ""],
443+
ref: toc,
444+
},
445+
[
446+
tocHeaders,
447+
h("div", {
448+
class: "vp-toc-marker",
449+
style: {
450+
top: tocMarkerTop.value,
444451
},
445-
[
446-
tocHeaders,
447-
h("div", {
448-
class: "vp-toc-marker",
449-
style: { top: tocMarkerTop.value },
450-
}),
451-
]
452-
),
452+
}),
453453
]
454-
: null,
455-
// Optional "after" slot
456-
after,
457-
// On desktop: render survey form inside the TOC container
458-
!isMobile.value
459-
? h("div", { class: "toc-survey-section" }, [
460-
renderSurveyForm(),
461-
])
462-
: null,
463-
]),
464-
])
454+
),
455+
]
456+
: null,
457+
after,
458+
// Add survey form inside the TOC for desktop
459+
!isMobile.value
460+
? h("div", { class: "toc-survey-section" }, [renderSurveyForm()])
461+
: null,
462+
]),
463+
]);
464+
465+
// For mobile: create a separate teleported component
466+
const mobileSurvey = isMobile.value
467+
? h(Teleport, { to: ".markdown-content" }, [renderSurveyForm()])
465468
: null;
466469

467-
return h(ClientOnly, () =>
468-
h("div", {}, [
469-
tocContent,
470-
// On mobile: teleport the survey form to the element with class "theme-hope-content"
471-
isMobile.value
472-
? h(Teleport, { to: ".theme-hope-content" }, [renderSurveyForm()])
473-
: null,
474-
])
475-
);
470+
return mobileSurvey ? [tocContent, mobileSurvey] : tocContent;
471+
});
476472
};
477473
},
478474
});

docs/.vuepress/styles/toc.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,12 @@ $headings: (2, 3, 4, 5, 6);
278278
/* The free-text textarea */
279279
.survey-textarea {
280280
width: 100%;
281-
margin: 0.5rem 0;
282281
resize: vertical; /* optional, to allow resizing */
283282
}
284283

285284
/* The optional email field */
286285
.survey-email {
287286
width: 100%;
288-
margin-bottom: 0.5rem;
289287
}
290288

291289
/* The "Submit" button */
@@ -307,3 +305,10 @@ $headings: (2, 3, 4, 5, 6);
307305
.survey-question {
308306
font-weight: 600;
309307
}
308+
309+
.toc-survey-section {
310+
margin-top: 1rem;
311+
position: relative;
312+
z-index: 1;
313+
}
314+

0 commit comments

Comments
 (0)