Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-46] docs: added 'Leave feedback' button to the top of the component page #2395

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion www/src/components/LeaveFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
import { Nav } from '~paragon-react';
import { useLocation } from '@reach/router';

function LeaveFeedback(props) {
export interface LeaveFeedbackProps {
as?: keyof JSX.IntrinsicElements | React.ElementType;
}

function LeaveFeedback(props: LeaveFeedbackProps) {
const location = useLocation();
const FEEDBACK_URL = `https://github.com/openedx/paragon/issues/new?title=%5Bparagon-openedx.netlify.app%5D%20Feedback%20(on%20${location.pathname})&labels=docs&template=feedback_template.md`;

Expand All @@ -20,10 +24,12 @@ function LeaveFeedback(props) {

LeaveFeedback.propTypes = {
className: PropTypes.string,
as: PropTypes.elementType,
};

LeaveFeedback.defaultProps = {
className: 'muted-link',
as: 'a',
};

export default LeaveFeedback;
7 changes: 6 additions & 1 deletion www/src/templates/component-page-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Alert,
breakpoints,
useMediaQuery,
Hyperlink,
} from '~paragon-react';
import { SettingsContext } from '../context/SettingsContext';
import { DEFAULT_THEME } from '../../theme-config';
Expand All @@ -18,6 +19,7 @@ import Layout from '../components/PageLayout';
import SEO from '../components/SEO';
import LinkedHeading from '../components/LinkedHeading';
import ComponentsUsage from '../components/insights/ComponentsUsage';
import LeaveFeedback from '../components/LeaveFeedback';

export interface IPageTemplate {
data: {
Expand Down Expand Up @@ -136,7 +138,10 @@ export default function PageTemplate({
<p className="small mb-0">{mdx.frontmatter.notes}</p>
</Alert>
)}
<h1 className="mb-4">{mdx.frontmatter.title}</h1>
<div className="d-flex justify-content-between">
<h1 className="mb-4">{mdx.frontmatter.title}</h1>
<LeaveFeedback as={Hyperlink} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're using Hyperlink here to get it to have the external launch icon, we may also want to include it on the other in-page "Leave feedback" link towards the bottom.

Likewise, we could also use as={Hyperlink} in the docs site footer such that we get the correct rel="noopener noreferrer" attribute for security. That said, given none of the other external links in the footer include an external launch icon, we can use Hyperlink's showLaunchIcon={false} to hide the icon for the footer only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the issue, I believe the intent for "Leave feedback" now is to be a small Button (variant="outline-primary") that acts as a Hyperlink here in component-page-template and below the page content (though not the footer).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this defaults to using Nav.Link styles by default, even though most uses of LeaveFeedback don't actually intend to use those styles. I wonder if the use of LeaveFeedback in the footer should be the exception that gets the Nav.Link styles rather than having to override that in 2 of the 3 places the LeaveFeedback component is used.

Is there a way to perhaps make this component a bit more flexible so the differing styles in the various use cases don't conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I replaced the top link and the bottom link with buttons, I also changed the implementation of links in the site footer. It seems to me that all links that lead to third-party resources should have rel="noopener noreferrer" and target="_blank ".

</div>
<MDXProvider components={shortcodes}>
<MDXRenderer>{mdx.body}</MDXRenderer>
</MDXProvider>
Expand Down
Loading