-
Notifications
You must be signed in to change notification settings - Fork 73
Add Rate this Page to all Docs Pages #1057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would also probably lowercase here, but just a nit. Do you also want to use the user hash so that you can tell how many unique people are clicking it and reduce the number of multiple clicks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually want multiple clicks here. Sort of like clapping on Medium vs. upvotes or downvotes.
briandoyle81 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
location: true, | ||
}); | ||
|
||
setTimeout(() => setClickedFace(null), 300); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you want to let someone click more than one time? Do you just want to have in state its been clicked and disable clicking any further? I'd probably store something in local storage so the same person on the same browser can't click again imo. |
||
}; | ||
|
||
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> | ||
); | ||
} |
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> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.tableOfContents { | ||
briandoyle81 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best component name ever haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to make games. I still do, but I used to too. I don't think I'll ever top getting to implement a function called
ExecuteWarpJump