Skip to content

Commit

Permalink
add feedback buttons (#128)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Vega <[email protected]>
  • Loading branch information
ObedVega and Vega authored Sep 10, 2024
1 parent 62f44ce commit 8bc2695
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/Feedback/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import clsx from 'clsx';
import styles from './styles.module.css';
import BrowserOnly from '@docusaurus/BrowserOnly';
import { useLocation } from 'react-router-dom';

export default function FeedbackComponent() {
const location = useLocation();
const handleFeedback = (feedback) => {
const articleUrl = location.pathname;
if (typeof window !== 'undefined' && window.gtag) {
window.gtag('event', 'feedback_click', {
event_category: 'Feedback',
event_label: `Feedback Type: ${feedback}`,
event_value: articleUrl,
});
}
};

return (
<BrowserOnly>
{() => {
const Feedback = require('@teradata-web/react-components')?.Feedback;

return (
<div className={clsx(styles.feedbackContainer)}>
<Feedback
label="Did this page help?"
labelForFeedback="Thank you for your feedback!"
onFeedBack={handleFeedback}
/>
</div>
);
}}
</BrowserOnly>
);
}
33 changes: 33 additions & 0 deletions src/components/Feedback/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.feedbackContainer {
width: 100%;
max-width: 664px;
padding: 10px 0;
box-sizing: border-box;
}

@media screen and (min-width: 997px) and (max-width: 1454px) {
.feedbackContainer {
width: 80%;
}
}

@media screen and (max-width: 1000px) {
.feedbackContainer {
max-width: 100%;
padding: 10px 0 10px 0;
}
}


@media screen and (max-width: 664px) {
.feedbackContainer {
padding: 0 15px 10px 15px;
}
}

@media screen and (max-width: 663px) {
.feedbackContainer {
padding: 10px 0px;
}
}

18 changes: 18 additions & 0 deletions src/theme/DocItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import DocItem from '@theme-original/DocItem';
import type DocItemType from '@theme/DocItem';
import type {WrapperProps} from '@docusaurus/types';
import FeedbackComponent from '../../components/Feedback';

type Props = WrapperProps<typeof DocItemType>;

export default function DocItemWrapper(props: Props): JSX.Element {
return (
<>
<DocItem {...props} />
<FeedbackComponent />
</>
);
}


0 comments on commit 8bc2695

Please sign in to comment.