-
Notifications
You must be signed in to change notification settings - Fork 67
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
Changes from 3 commits
f518e5d
92358d0
7a79fa8
c6572a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,57 @@ | ||
import React from 'react'; | ||
import React, { AnchorHTMLAttributes } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Nav } from '~paragon-react'; | ||
import { Button, Hyperlink } from '~paragon-react'; | ||
import { useLocation } from '@reach/router'; | ||
|
||
function LeaveFeedback(props) { | ||
export interface LeaveFeedbackProps extends Partial<AnchorHTMLAttributes<HTMLAnchorElement>> { | ||
isLink?: boolean; | ||
} | ||
|
||
function LeaveFeedback({ isLink, ...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`; | ||
const leaveFeedbackLinkTitle = 'Leave feedback'; | ||
|
||
const handleLinkFeedbackClick = () => { | ||
global.analytics.track('openedx.paragon.docs.leave_feedback.clicked'); | ||
}; | ||
|
||
if (isLink) { | ||
return ( | ||
<Hyperlink | ||
className="muted-link nav-link" | ||
destination={FEEDBACK_URL} | ||
showLaunchIcon={false} | ||
onClick={handleLinkFeedbackClick} | ||
target="_blank" | ||
{...props} | ||
> | ||
{leaveFeedbackLinkTitle} | ||
</Hyperlink> | ||
); | ||
} | ||
|
||
return ( | ||
<Nav.Link onClick={handleLinkFeedbackClick} href={FEEDBACK_URL} target="_blank" {...props}> | ||
Leave feedback | ||
</Nav.Link> | ||
<Button | ||
as={Hyperlink} | ||
destination={FEEDBACK_URL} | ||
size="sm" | ||
variant="outline-primary" | ||
onClick={handleLinkFeedbackClick} | ||
target="_blank" | ||
{...props} | ||
> | ||
{leaveFeedbackLinkTitle} | ||
</Button> | ||
); | ||
} | ||
|
||
LeaveFeedback.propTypes = { | ||
className: PropTypes.string, | ||
isLink: PropTypes.bool, | ||
}; | ||
|
||
LeaveFeedback.defaultProps = { | ||
className: 'muted-link', | ||
isLink: false, | ||
}; | ||
|
||
export default LeaveFeedback; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { | |
Row, | ||
Col, | ||
Sticky, | ||
Hyperlink, | ||
useMediaQuery, | ||
breakpoints, | ||
} from '~paragon-react'; | ||
|
@@ -83,7 +84,7 @@ function Layout({ | |
{children} | ||
<Container size="md"> | ||
<hr /> | ||
<LeaveFeedback className="pgn__docs-page-feedback-link" /> | ||
<LeaveFeedback className="mb-5" /> | ||
</Container> | ||
</Col> | ||
<Col | ||
|
@@ -114,28 +115,40 @@ function Layout({ | |
</Link> | ||
</Nav.Item> | ||
<Nav.Item> | ||
<Nav.Link | ||
className="muted-link" | ||
href="https://github.com/openedx/.github/blob/master/CODE_OF_CONDUCT.md" | ||
<Hyperlink | ||
className="muted-link nav-link" | ||
destination="https://github.com/openedx/.github/blob/master/CODE_OF_CONDUCT.md" | ||
showLaunchIcon={false} | ||
target="_blank" | ||
> | ||
Code of Conduct | ||
</Nav.Link> | ||
</Hyperlink> | ||
</Nav.Item> | ||
<Nav.Item> | ||
<Nav.Link className="muted-link" href="https://open.edx.org/"> | ||
<Hyperlink | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to replace implementation in all these links. We should always use Instead of using <Nav.Link
className="muted-link"
href="https://open.edx.org/"
target="_blank"
rel="noopener noreferrer"
>
Open edX
</Nav.Link> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @viktorrusakov thanks for the review 👍 The transition from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still just renders an I agree with your semantics reasoning (that nav probably shouldn't have external links in it), but your solution does not solve the underlying problem - in the DOM it still renders a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I agree with you |
||
className="muted-link nav-link" | ||
destination="https://open.edx.org/" | ||
showLaunchIcon={false} | ||
target="_blank" | ||
> | ||
Open edX | ||
</Nav.Link> | ||
</Hyperlink> | ||
</Nav.Item> | ||
<Nav.Item> | ||
<LeaveFeedback /> | ||
<LeaveFeedback isLink /> | ||
</Nav.Item> | ||
<div className="flex-grow-1" /> | ||
<a href="https://www.netlify.com"> | ||
<Hyperlink | ||
className="muted-link nav-link" | ||
destination="https://www.netlify.com" | ||
showLaunchIcon={false} | ||
target="_blank" | ||
> | ||
<img | ||
src="https://www.netlify.com/img/global/badges/netlify-light.svg" | ||
alt="Deploys by Netlify" | ||
/> | ||
</a> | ||
</Hyperlink> | ||
</Nav> | ||
</Container> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it also make more sense to leave
Nav.Link
implementation here since we only use it insideNav
component, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done