-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1057 from onflow/brian-doyle/add-page-ranking-tags
Add Rate this Page to all Docs Pages
- Loading branch information
Showing
7 changed files
with
4,487 additions
and
4,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState } from "react"; | ||
import { event } from "@site/src/utils/gtags.client"; | ||
|
||
export default function FeedbackFaces() { | ||
const [clickedFace, setClickedFace] = useState<string | null>(null); | ||
|
||
const faces = [ | ||
{ label: "sad", emoji: "😞" }, | ||
{ label: "neutral", emoji: "😐" }, | ||
{ label: "happy", emoji: "😊" }, | ||
]; | ||
|
||
const handleFeedbackClick = (feedbackType: string) => { | ||
setClickedFace(feedbackType); | ||
|
||
const label = `${feedbackType}`; | ||
|
||
event({ | ||
action: "feedback_click", | ||
category: "feedback", | ||
label: label, | ||
location: true, | ||
}); | ||
|
||
setTimeout(() => setClickedFace(null), 300); | ||
}; | ||
|
||
return ( | ||
<div className="flex justify-left items-center gap-1"> | ||
{faces.map((face) => ( | ||
<button | ||
key={face.label} | ||
onClick={() => handleFeedbackClick(face.label)} | ||
className={`text-4xl cursor-pointer p-2 bg-transparent border-none transition-transform duration-200 focus:outline-none ${clickedFace === face.label ? "scale-110 opacity-70" : "scale-100 opacity-100" | ||
}`} | ||
aria-label={face.label} | ||
> | ||
{face.emoji} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import TOCItems from '@theme/TOCItems'; | ||
import type { Props } from '@theme/TOC'; | ||
|
||
import styles from './styles.module.css'; | ||
import FeedbackFaces from '@site/src/components/feedbackFaces'; | ||
|
||
// Using a custom className | ||
// This prevents TOCInline/TOCCollapsible getting highlighted by mistake | ||
const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight'; | ||
const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active'; | ||
|
||
export default function TOC({ className, ...props }: Props): JSX.Element { | ||
return ( | ||
<div className={clsx(styles.tableOfContents, 'thin-scrollbar', className)}> | ||
<div className="p-1"> | ||
<h6 className="mb-0 p-1">Rate this page</h6> | ||
<FeedbackFaces /> | ||
</div> | ||
<TOCItems | ||
{...props} | ||
linkClassName={LINK_CLASS_NAME} | ||
linkActiveClassName={LINK_ACTIVE_CLASS_NAME} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.tableOfContents { | ||
max-height: calc(100vh - (var(--ifm-navbar-height) + 2rem)); | ||
overflow-y: auto; | ||
position: sticky; | ||
top: calc(var(--ifm-navbar-height) + 1rem); | ||
} | ||
|
||
@media (max-width: 996px) { | ||
.tableOfContents { | ||
display: none; | ||
} | ||
|
||
.docItemContainer { | ||
padding: 0 0.3rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.