Skip to content

Commit 21a8823

Browse files
authored
feat(Feedback): Add a feedback button with qualtrics form (#4755)
1 parent 1c8e427 commit 21a8823

File tree

8 files changed

+104
-3
lines changed

8 files changed

+104
-3
lines changed

packages/documentation-framework/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import './components/cssVariables/cssVariables.css';
1111
import './components/tableOfContents/tableOfContents.css';
1212
import './components/example/example.css';
1313
import './components/footer/footer.css';
14+
import './components/feedbackButton/feedbackButton.css';
1415
import './layouts/sideNavLayout/sideNavLayout.css';
1516

1617
const AppRoute = ({ child, title, path }) => {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.ws-feedback-button-container {
2+
position: fixed;
3+
right: 0;
4+
top: 50vh;
5+
transform: translateY(-50%);
6+
transform: rotate(-90deg);
7+
z-index: 9999;
8+
pointer-events: auto;
9+
}
10+
11+
.ws-feedback-button {
12+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
13+
}
14+
15+
/* Ensure the button is visible on all screen sizes */
16+
@media (max-width: 768px) {
17+
.ws-feedback-button-container {
18+
right: -20px;
19+
}
20+
}
21+
22+
/* Ensure the button doesn't interfere with other elements */
23+
.ws-feedback-button-container .pf-v6-c-button {
24+
min-width: auto;
25+
}
26+
27+
/* Make the feedback modal taller */
28+
.ws-feedback-modal {
29+
max-height: 90vh !important;
30+
}
31+
32+
.ws-feedback-modal .pf-v6-c-modal-box {
33+
max-height: 90vh !important;
34+
height: 90vh !important;
35+
}
36+
37+
.ws-feedback-modal .pf-v6-c-modal-box__body {
38+
height: calc(90vh - 120px) !important;
39+
overflow-y: auto;
40+
}
41+
42+
/* Make the iframe fill the modal body */
43+
.ws-feedback-iframe {
44+
width: 100% !important;
45+
height: 100% !important;
46+
border: none;
47+
display: block;
48+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { useState } from 'react';
2+
import {
3+
Button,
4+
Modal,
5+
ModalBody,
6+
ModalHeader,
7+
ModalFooter,
8+
ModalVariant,
9+
Label
10+
} from '@patternfly/react-core';
11+
import './feedbackButton.css';
12+
13+
export const FeedbackButton = () => {
14+
const [isModalOpen, setIsModalOpen] = useState(false);
15+
16+
const handleModalToggle = () => {
17+
setIsModalOpen(!isModalOpen);
18+
};
19+
20+
return (
21+
<>
22+
<div className="ws-feedback-button-container">
23+
<Button variant="primary" size="sm" className="ws-feedback-button" onClick={handleModalToggle}>Give feedback</Button>
24+
</div>
25+
26+
<Modal
27+
variant={ModalVariant.large}
28+
isOpen={isModalOpen}
29+
onClose={handleModalToggle}
30+
aria-label="PatternFly feedback modal"
31+
aria-describedby="feedback-modal-description"
32+
className="ws-feedback-modal"
33+
>
34+
<ModalBody tabIndex="0" id="feedback-modal-description">
35+
<iframe
36+
src="https://www.feedback.redhat.com/jfe/form/SV_9MKBjq8H7muINMy"
37+
title="Give PatternFly feedback"
38+
className="ws-feedback-iframe"
39+
></iframe>
40+
</ModalBody>
41+
</Modal>
42+
</>
43+
);
44+
};

packages/documentation-framework/components/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export * from './topNav/topNav';
1010
export * from './link/link';
1111
export * from './tableOfContents/tableOfContents';
1212
export * from './inlineAlert/inlineAlert';
13-
export * from './themeSelector/themeSelector';
13+
export * from './themeSelector/themeSelector';
14+
export * from './feedbackButton/feedbackButton';

packages/documentation-framework/scripts/webpack/webpack.base.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = (_env, argv) => {
1515
hasThemeSwitcher = false,
1616
hasHighContrastSwitcher = false,
1717
hasRTLSwitcher = false,
18+
hasFeedbackButton = false,
1819
componentsData = {},
1920
sideNavItems = [],
2021
topNavItems = [],
@@ -145,6 +146,7 @@ module.exports = (_env, argv) => {
145146
'process.env.hasThemeSwitcher': JSON.stringify(hasThemeSwitcher),
146147
'process.env.hasHighContrastSwitcher': JSON.stringify(hasHighContrastSwitcher),
147148
'process.env.hasRTLSwitcher': JSON.stringify(hasRTLSwitcher),
149+
'process.env.hasFeedbackButton': JSON.stringify(hasFeedbackButton),
148150
'process.env.componentsData': JSON.stringify(componentsData),
149151
'process.env.sideNavItems': JSON.stringify(sideNavItems),
150152
'process.env.topNavItems': JSON.stringify(topNavItems),

packages/documentation-framework/templates/mdx.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { css } from '@patternfly/react-styles';
1919
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
2020
import { Router, useLocation } from '@reach/router';
21-
import { CSSVariables, PropsTable, TableOfContents, Link, AutoLinkHeader, InlineAlert } from '../components';
21+
import { CSSVariables, PropsTable, TableOfContents, Link, AutoLinkHeader, InlineAlert, FeedbackButton } from '../components';
2222
import { capitalize, getTitle, slugger, trackEvent } from '../helpers';
2323
import './mdx.css';
2424
import { convertToReactComponent } from '@patternfly/ast-helpers';
@@ -167,6 +167,7 @@ const MDXChildTemplate = ({ Component, source, toc = [], index = 0, id }) => {
167167
};
168168

169169
export const MDXTemplate = ({ title, sources = [], path, id, componentsData }) => {
170+
const hasFeedbackButton = process.env.hasFeedbackButton;
170171
const isDeprecated =
171172
sources.some((source) => source.source === 'react-deprecated' || source.source === 'html-deprecated') &&
172173
!sources.some((source) => source.source === 'react' || source.source === 'html');
@@ -339,6 +340,7 @@ export const MDXTemplate = ({ title, sources = [], path, id, componentsData }) =
339340
)}
340341
</PageSection>
341342
<BackToTop className="ws-back-to-top" scrollableSelector="#ws-page-main" />
343+
{hasFeedbackButton && <FeedbackButton />}
342344
</PageGroup>
343345
</React.Fragment>
344346
);

packages/documentation-site/patternfly-docs/pages/home.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Link } from '@patternfly/documentation-framework/components';
2+
import { Link, FeedbackButton } from '@patternfly/documentation-framework/components';
33
import {
44
Banner,
55
Button,
@@ -289,6 +289,7 @@ const HomePage = () => (
289289
<PageSection isWidthLimited className="v6-stay-informed-cards">
290290
<AggregateCards />
291291
</PageSection>
292+
<FeedbackButton />
292293
</React.Fragment>
293294
);
294295

packages/documentation-site/patternfly-docs/patternfly-docs.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if (process.env.EXTENSIONS_ONLY === 'true') {
99
hasThemeSwitcher: true,
1010
hasHighContrastSwitcher: false,
1111
hasRTLSwitcher: false,
12+
hasFeedbackButton: true,
1213
sideNavItems: [
1314
{ section: 'extensions' }
1415
],
@@ -29,6 +30,7 @@ if (process.env.EXTENSIONS_ONLY === 'true') {
2930
hasVersionSwitcher: true,
3031
hasDesignGuidelines: true,
3132
hasThemeSwitcher: true,
33+
hasFeedbackButton: true,
3234
hasHighContrastSwitcher: false,
3335
componentsData,
3436
sideNavItems: [

0 commit comments

Comments
 (0)