Skip to content

Commit

Permalink
docs(nx-dev): Add feedback CTA
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham committed Mar 22, 2024
1 parent a96b53e commit 4bf32cb
Show file tree
Hide file tree
Showing 15 changed files with 470 additions and 2 deletions.
30 changes: 30 additions & 0 deletions nx-dev/feature-doc-viewer/src/lib/table-of-contents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Link from 'next/link';
import { cx } from '@nx/nx-dev/ui-primitives';
import { useHeadingsObserver } from './use-headings-observer';
import { useState } from 'react';
import { FeedbackDialog } from '@nx/feature-feedback';
import { sendCustomEvent } from '@nx/nx-dev/feature-analytics';

interface Heading {
id: string;
Expand Down Expand Up @@ -70,6 +73,17 @@ export function TableOfContents({
headings.find((i) => i.level === 1)?.title || null
);

const [showFeedback, setShowFeedback] = useState(false);

function submitIdeaFeedback(feedback: string) {
// sanitize the feedback from the user script tags/other malicious code
const sanitizedFeedback = feedback.replace(/(<([^>]+)>)/gi, '');

sendCustomEvent('feedback', 'feedback', 'idea', undefined, {
feedback: sanitizedFeedback,
});
}

return (
<>
<nav className="toc">
Expand Down Expand Up @@ -100,6 +114,22 @@ export function TableOfContents({
) : null}
</nav>
<div className="p-4">{children}</div>
<div className="flex w-full items-center space-x-2 sm:px-6 xl:px-8">
<div className="flex items-center justify-between pl-2 pr-2 space-x-2 border rounded-md border-slate-200 hover:border-slate-400 dark:border-slate-700 print:hidden">
<button
className="px-4 py-2 border-transparent hover:text-slate-900 dark:hover:text-sky-400 whitespace-nowrap"
onClick={() => setShowFeedback(true)}
>
{' '}
Feedback?{' '}
</button>
</div>
</div>
<FeedbackDialog
isOpen={showFeedback}
onClose={() => setShowFeedback(false)}
onFeedbackSubmit={submitIdeaFeedback}
/>
</>
);
}
12 changes: 12 additions & 0 deletions nx-dev/feature-feedback/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions nx-dev/feature-feedback/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions nx-dev/feature-feedback/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# feature-feedback

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test feature-feedback` to execute the unit tests via [Jest](https://jestjs.io).
11 changes: 11 additions & 0 deletions nx-dev/feature-feedback/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'feature-feedback',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/nx-dev/feature-feedback',
};
11 changes: 11 additions & 0 deletions nx-dev/feature-feedback/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "feature-feedback",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "nx-dev/feature-feedback/src",
"projectType": "library",
"tags": ["scope:nx-dev", "type:feature"],
"targets": {
"lint": {},
"test": {}
}
}
1 change: 1 addition & 0 deletions nx-dev/feature-feedback/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/feedback-dialog';
63 changes: 63 additions & 0 deletions nx-dev/feature-feedback/src/lib/feature-feedback.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Replace this with your own classes
*
* e.g.
* .container {
* }
*/

.closebutton {
position: absolute;
top: 0.4rem;
right: 0.7rem;
padding: 0.5rem;
cursor: pointer;
font-size: 1.5rem;
}

.fadeinout {
-webkit-animation: fadeinout 0.5s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadeinout 0.5s; /* Firefox < 16 */
-ms-animation: fadeinout 0.5s; /* Internet Explorer */
-o-animation: fadeinout 0.5s; /* Opera < 12.1 */
animation: fadeinout 0.5s;
}

@keyframes fadeinout {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

/* Firefox < 16 */
@keyframes fadeinout {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadeinout {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

/* Internet Explorer */
@-ms-keyframes fadeinout {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
Loading

0 comments on commit 4bf32cb

Please sign in to comment.