Skip to content

Commit

Permalink
refactor(ui): add Link component
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Jan 4, 2019
1 parent ce63c9d commit c3b4434
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
'prettier/prettier': 'error',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/no-did-mount-set-state': 0,
'jsx-a11y/anchor-is-valid': [1, { components: [] }],
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/click-events-have-key-events': 0,
Expand Down
28 changes: 28 additions & 0 deletions app/components/UI/Link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Text } from 'components/UI'

/**
* @render react
* @name Link
* @example
* <Link>Some text</Link>
*/
class Link extends React.PureComponent {
static displayName = 'Link'

static propTypes = {
children: PropTypes.node
}

render() {
const { children } = this.props
return (
<Text as="a" css={{ cursor: 'pointer', 'text-decoration': 'underline' }} {...this.props}>
{children}
</Text>
)
}
}

export default Link
1 change: 1 addition & 0 deletions app/components/UI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export Heading from './Heading'
export Input from './Input'
export Label from './Label'
export LightningInvoiceInput from './LightningInvoiceInput'
export Link from './Link'
export MainContent from './MainContent'
export Modal from './Modal'
export Notification from './Notification'
Expand Down
10 changes: 10 additions & 0 deletions test/unit/components/UI/Link.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { Link } from 'components/UI'

describe('component.UI.Link', () => {
it('should render correctly', () => {
const tree = renderer.create(<Link>Link text</Link>).toJSON()
expect(tree).toMatchSnapshot()
})
})
20 changes: 20 additions & 0 deletions test/unit/components/UI/__snapshots__/Link.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`component.UI.Link should render correctly 1`] = `
.c0 {
font-size: m;
color: primaryText;
cursor: pointer;
-webkit-text-decoration: underline;
text-decoration: underline;
line-height: 1.4;
}
<a
className="c0"
color="primaryText"
fontSize="m"
>
Link text
</a>
`;

0 comments on commit c3b4434

Please sign in to comment.