forked from elastic/kibana
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI Framework] [K7] Add KuiLink React component. (elastic#13264)
* Add KuiLink React component.
- Loading branch information
Showing
10 changed files
with
86 additions
and
6 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 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
KuiLink, | ||
KuiText, | ||
} from '../../../../components'; | ||
|
||
export default () => ( | ||
<KuiText> | ||
<p> | ||
Open the {( | ||
<KuiLink | ||
href="http://www.elastic.co" | ||
target="_blank" | ||
> | ||
Elastic website | ||
</KuiLink> | ||
)} in a new tab. | ||
</p> | ||
</KuiText> | ||
); |
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,26 +1,33 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideDemo, | ||
GuidePage, | ||
GuideSection, | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
const linkHtml = require('./link.html'); | ||
import Link from './link'; | ||
const linkSource = require('!!raw!./link'); | ||
const linkHtml = renderToHtml(Link); | ||
|
||
export default props => ( | ||
<GuidePage title={props.route.name}> | ||
<GuideSection | ||
title="Link" | ||
source={[{ | ||
type: GuideSectionTypes.JS, | ||
code: linkSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: linkHtml, | ||
}]} | ||
> | ||
<GuideDemo | ||
html={linkHtml} | ||
/> | ||
<GuideDemo> | ||
<Link /> | ||
</GuideDemo> | ||
</GuideSection> | ||
</GuidePage> | ||
); |
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
11 changes: 11 additions & 0 deletions
11
ui_framework/src/components/link/__snapshots__/link.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`KuiLink is rendered 1`] = ` | ||
<a | ||
aria-label="aria-label" | ||
class="kuiLink testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
href="#" | ||
target="_blank" | ||
/> | ||
`; |
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,3 @@ | ||
export { | ||
KuiLink, | ||
} from './link'; |
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,15 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export const KuiLink = ({ children, className, ...rest }) => { | ||
const classes = classNames('kuiLink', className); | ||
|
||
return ( | ||
<a | ||
className={classes} | ||
{...rest} | ||
> | ||
{children} | ||
</a> | ||
); | ||
}; |
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,20 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test/required_props'; | ||
|
||
import { KuiLink } from './link'; | ||
|
||
describe('KuiLink', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<KuiLink | ||
href="#" | ||
target="_blank" | ||
{...requiredProps} | ||
/> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
}); |