-
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.
- Loading branch information
1 parent
18a3c99
commit 8c319ee
Showing
7 changed files
with
4,506 additions
and
4,783 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,66 @@ | ||
import React, { useState } from "react"; | ||
import { event } from "@site/src/utils/gtags.client"; | ||
|
||
// Default export function component | ||
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 pagePath = window.location.pathname; | ||
const label = `${feedbackType} - ${pagePath}`; | ||
|
||
event({ | ||
action: "feedback_click", | ||
category: "Feedback", | ||
label: label, | ||
location: pagePath, | ||
}); | ||
|
||
// Reset the clicked state after a brief delay | ||
setTimeout(() => setClickedFace(null), 300); | ||
}; | ||
|
||
return ( | ||
<div style={styles.container}> | ||
{faces.map((face) => ( | ||
<button | ||
key={face.label} | ||
onClick={() => handleFeedbackClick(face.label)} | ||
style={{ | ||
...styles.button, | ||
transform: clickedFace === face.label ? "scale(1.2)" : "scale(1)", | ||
opacity: clickedFace === face.label ? 0.7 : 1, | ||
}} | ||
aria-label={face.label} | ||
> | ||
{face.emoji} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
// Inline CSS styles | ||
const styles = { | ||
container: { | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
} as React.CSSProperties, | ||
button: { | ||
fontSize: "30px", | ||
background: "none", | ||
border: "none", | ||
cursor: "pointer", | ||
transition: "transform 0.2s, opacity 0.2s", | ||
padding: "10px", | ||
} as React.CSSProperties, | ||
}; |
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,26 @@ | ||
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)}> | ||
<h6 className={styles.tableOfContentsTitle}>Rate this page</h6> | ||
<FeedbackFaces /> | ||
<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.