|
1 |
| -import React, { PureComponent } from 'react' |
| 1 | +import React, { PureComponent, Validator } from 'react' |
2 | 2 | import PropTypes from 'prop-types'
|
3 | 3 | import cx from 'classnames'
|
4 |
| -import { withTheme } from '../../theme' |
| 4 | +import { withTheme, Theme } from '../../theme' |
5 | 5 | import Text from './Text'
|
6 | 6 |
|
7 |
| -class Link extends PureComponent<any & React.ComponentProps<typeof Text>> { |
8 |
| - static propTypes = { |
9 |
| - /** |
10 |
| - * This attribute names a relationship of the linked document to the current document. |
11 |
| - * Common use case is: rel="noopener noreferrer". |
12 |
| - */ |
13 |
| - rel: PropTypes.string, |
| 7 | +export interface LinkProps extends React.ComponentProps<typeof Text> { |
| 8 | + /** |
| 9 | + * Class name passed to the link. |
| 10 | + * Only use if you know what you are doing. |
| 11 | + */ |
| 12 | + className?: string |
14 | 13 |
|
15 |
| - /** |
16 |
| - * Specifies the URL of the linked resource. A URL might be absolute or relative. |
17 |
| - */ |
18 |
| - href: PropTypes.string, |
| 14 | + /** |
| 15 | + * The color (and styling) of the Link. Can be default, blue, green or neutral. |
| 16 | + */ |
| 17 | + color?: string |
19 | 18 |
|
20 |
| - /** |
21 |
| - * Target atrribute, common use case is target="_blank." |
22 |
| - */ |
23 |
| - target: PropTypes.string, |
| 19 | + /** |
| 20 | + * Specifies the URL of the linked resource. A URL might be absolute or relative. |
| 21 | + */ |
| 22 | + href?: string |
| 23 | + |
| 24 | + /** |
| 25 | + * This attribute names a relationship of the linked document to the current document. |
| 26 | + * Common use case is: rel="noopener noreferrer". |
| 27 | + */ |
| 28 | + rel?: string |
| 29 | + |
| 30 | + /** |
| 31 | + * Target atrribute, common use case is target="_blank." |
| 32 | + */ |
| 33 | + target?: string |
24 | 34 |
|
25 |
| - /** |
26 |
| - * The color (and styling) of the Link. Can be default, blue, green or neutral. |
27 |
| - */ |
28 |
| - color: PropTypes.string.isRequired, |
29 |
| - |
30 |
| - /** |
31 |
| - * Theme provided by ThemeProvider. |
32 |
| - */ |
33 |
| - theme: PropTypes.object.isRequired, |
34 |
| - |
35 |
| - /** |
36 |
| - * Class name passed to the link. |
37 |
| - * Only use if you know what you are doing. |
38 |
| - */ |
39 |
| - className: PropTypes.string |
| 35 | + /** |
| 36 | + * Theme provided by ThemeProvider. |
| 37 | + */ |
| 38 | + theme: Theme |
| 39 | +} |
| 40 | + |
| 41 | +class Link extends PureComponent<LinkProps> { |
| 42 | + static propTypes = { |
| 43 | + className: PropTypes.string, |
| 44 | + color: PropTypes.string, |
| 45 | + href: PropTypes.string, |
| 46 | + rel: PropTypes.string, |
| 47 | + target: PropTypes.string, |
| 48 | + theme: PropTypes.object.isRequired as Validator<Theme> |
40 | 49 | }
|
41 | 50 |
|
42 | 51 | static defaultProps = {
|
|
0 commit comments