forked from openedx/paragon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added 'Leave feedback' button to the top of the component page (o…
- Loading branch information
1 parent
1ae20f3
commit 00dd998
Showing
5 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,56 @@ | ||
import React from 'react'; | ||
import React, { AnchorHTMLAttributes } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Nav } from '~paragon-react'; | ||
import { Nav, Button, Hyperlink } from '~paragon-react'; | ||
import { useLocation } from '@reach/router'; | ||
|
||
function LeaveFeedback(props) { | ||
export interface LeaveFeedbackProps extends Partial<AnchorHTMLAttributes<HTMLAnchorElement>> { | ||
isNavLink?: boolean; | ||
} | ||
|
||
function LeaveFeedback({ isNavLink, ...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 (isNavLink) { | ||
return ( | ||
<Nav.Link | ||
onClick={handleLinkFeedbackClick} | ||
href={FEEDBACK_URL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
{...props} | ||
> | ||
{leaveFeedbackLinkTitle} | ||
</Nav.Link> | ||
); | ||
} | ||
|
||
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, | ||
isNavLink: PropTypes.bool, | ||
}; | ||
|
||
LeaveFeedback.defaultProps = { | ||
className: 'muted-link', | ||
isNavLink: false, | ||
}; | ||
|
||
export default LeaveFeedback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters