From d95573393206bc3931202d363bfb6c54974e0203 Mon Sep 17 00:00:00 2001 From: muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> Date: Fri, 28 Oct 2022 07:37:55 +0530 Subject: Transform welcome component tree to TS (#715) --- src/components/ui/Link.js | 86 ----------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/components/ui/Link.js (limited to 'src/components/ui/Link.js') diff --git a/src/components/ui/Link.js b/src/components/ui/Link.js deleted file mode 100644 index 714fc5a68..000000000 --- a/src/components/ui/Link.js +++ /dev/null @@ -1,86 +0,0 @@ -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { inject, observer } from 'mobx-react'; -import { RouterStore } from '@superwf/mobx-react-router'; -import classnames from 'classnames'; - -import { oneOrManyChildElements } from '../../prop-types'; -import matchRoute from '../../helpers/routing-helpers'; -import { openExternalUrl } from '../../helpers/url-helpers'; - -// Should this file be converted into the coding style similar to './toggle/index.tsx'? -// TODO: create container component for this component -class Link extends Component { - onClick(e) { - if (this.props.disabled) { - e.preventDefault(); - } else if (this.props.target === '_blank') { - e.preventDefault(); - openExternalUrl(this.props.to, true); - } - // Note: if neither of the above, then let the other onClick handlers process it - } - - render() { - const { - children, - stores, - to, - className, - activeClassName, - strictFilter, - style, - } = this.props; - const { router } = stores; - - let filter = `${to}(*action)`; - if (strictFilter) { - filter = `${to}`; - } - - const match = matchRoute(filter, router.location.pathname); - - const linkClasses = classnames({ - [`${className}`]: true, - [`${activeClassName}`]: match, - 'is-disabled': this.props.disabled, - }); - - return ( - this.onClick(e)} - > - {children} - - ); - } -} - -Link.propTypes = { - stores: PropTypes.shape({ - router: PropTypes.instanceOf(RouterStore).isRequired, - }).isRequired, - children: PropTypes.oneOfType([oneOrManyChildElements, PropTypes.string]) - .isRequired, - to: PropTypes.string.isRequired, - className: PropTypes.string, - activeClassName: PropTypes.string, - strictFilter: PropTypes.bool, - target: PropTypes.string, - style: PropTypes.object, - disabled: PropTypes.bool, -}; - -Link.defaultProps = { - className: '', - activeClassName: '', - strictFilter: false, - disabled: false, - target: '', - style: {}, -}; - -export default inject('stores')(observer(Link)); -- cgit v1.2.3-70-g09d2