-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add OpenExternalLinkItem component
And update OpenExternalLinkButton
- Loading branch information
Showing
2 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
|
||
import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' | ||
import Icon from 'cozy-ui/transpiled/react/Icon' | ||
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' | ||
|
||
import { getIconWithlabel } from 'modules/public/OpenExternalLinkButton' | ||
import { openExternalLink } from 'modules/public/helpers' | ||
|
||
const OpenExternalLinkItem = ({ link, isSharingShortcutCreated }) => { | ||
const { t } = useI18n() | ||
|
||
const handleClick = () => { | ||
openExternalLink(link) | ||
} | ||
|
||
const { icon, label } = getIconWithlabel({ | ||
link, | ||
isSharingShortcutCreated, | ||
t | ||
}) | ||
|
||
return ( | ||
<ActionsMenuItem isListItem onClick={handleClick}> | ||
<ListItemIcon> | ||
<Icon icon={icon} /> | ||
</ListItemIcon> | ||
<ListItemText primary={label} /> | ||
</ActionsMenuItem> | ||
) | ||
} | ||
|
||
OpenExternalLinkItem.propTypes = { | ||
link: PropTypes.string.isRequired, | ||
isSharingShortcutCreated: PropTypes.bool | ||
} | ||
|
||
export default OpenExternalLinkItem |