Skip to content

Commit

Permalink
feat(docs) : Feedback Form for documentation (#3327)
Browse files Browse the repository at this point in the history
* Add Feedback Form Component
  • Loading branch information
vivekjain23 authored Oct 23, 2024
1 parent df45633 commit 6166139
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1 deletion.
62 changes: 62 additions & 0 deletions docs/site/src/components/FeedbackForm/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { useState } from 'react';
import clsx from "clsx";
import "./styles.css";

const FeedbackForm = () => {
const [title, setTitle] = useState('');
const [body, setBody] = useState('');

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();

const prefixedTitle = `Docs feedback: ${title}`;
const githubNewIssueUrl = `https://github.com/iotaledger/devx/issues/new?template=doc-bug.md&title=${encodeURIComponent(prefixedTitle)}&body=${encodeURIComponent(body)}`;

// Open the GitHub issue page with pre-filled data in a new tab
window.open(githubNewIssueUrl, '_blank');
setTitle("");
setBody("");
};

return (
<div className="feedback-container">
<div className="divider"></div>
<div className={clsx("h3", "feedback-header")}>Feedback Form</div>
<form onSubmit={handleSubmit}>
<div className="form-group">
<label htmlFor="issue">Title <span className="red">*</span></label>
<input
type="text"
id="title"
value={title}
onChange={(e) => setTitle(e.target.value)}
required
className="input-field"
placeholder='Enter Title'
/>
</div>
<div className="form-group">
<label htmlFor="body">Describe your feedback here</label>
<textarea
id="body"
value={body}
onChange={(e) => setBody(e.target.value)}
required
className="textarea-field"
placeholder='Enter Text'
/>
</div>
<button
className={clsx("button", { "button-disabled": !title })}
type="submit"
disabled={!title}
>
Submit Feedback
</button>
</form>
<div className="divider"></div>
</div>
);
};

export default FeedbackForm;
56 changes: 56 additions & 0 deletions docs/site/src/components/FeedbackForm/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.feedback-container {
/* margin: 20px; */
}

.feedback-header {
font-size: 30px;
margin: 20px 0;
}
.red{
color: red;
}
.form-group {
display: flex;
flex-direction: column;
margin-bottom: 15px;
gap: 5px;
}

.input-field {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}

.textarea-field {
padding: 10px;
font-size: 16px;
height: 100px;
border: 1px solid #ccc;
border-radius: 4px;
resize: vertical;
}

.submit-button {
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}

.submit-button:hover {
background-color: #0056b3;
}

[data-theme="light"] .divider {
border-top: 1px solid var(--ifm-toc-border-color);;
}

.divider {
border-top: 1px solid rgba(255, 255, 255, 0.3);
margin: 20px 0;
}

8 changes: 7 additions & 1 deletion docs/site/src/theme/MDXContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Props } from '@theme/MDXContent';
import { Card, Cards } from "@site/src/components/Cards";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import FeedbackForm from "@site/src/components/FeedbackForm";

export default function MDXContent({ children }: Props): JSX.Element {
const components = {
Expand All @@ -19,5 +20,10 @@ export default function MDXContent({ children }: Props): JSX.Element {
Tabs,
TabItem,
};
return <MDXProvider components={components}>{children}</MDXProvider>;
return (
<MDXProvider components={components}>
{children}
<FeedbackForm />
</MDXProvider>
);
}

0 comments on commit 6166139

Please sign in to comment.