forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update eslint config to lint the new UI Framework directory structure. (
- Loading branch information
Showing
4 changed files
with
96 additions
and
3 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,43 @@ | ||
import { | ||
cloneElement, | ||
PropTypes, | ||
} from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
const sizeToClassNameMap = { | ||
small: 'kuiTitle--small', | ||
large: 'kuiTitle--large', | ||
}; | ||
|
||
export const SIZES = Object.keys(sizeToClassNameMap); | ||
|
||
export const KuiTitle = ({ size, children, className, ...rest }) => { | ||
const classes = classNames('kuiTitle', sizeToClassNameMap[size], className); | ||
|
||
const props = { | ||
className: classes, | ||
...rest, | ||
}; | ||
|
||
return cloneElement(children, props); | ||
}; | ||
|
||
KuiTitle.PropTypes = { | ||
children: PropTypes.node.isRequired, | ||
size: PropTypes.oneOf(SIZES), | ||
}; | ||
|
||
export const KuiText = ({ children, className, ...rest }) => { | ||
const classes = classNames('kuiText', className); | ||
|
||
const props = { | ||
className: classes, | ||
...rest, | ||
}; | ||
|
||
return cloneElement(children, props); | ||
}; | ||
|
||
KuiText.PropTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; |
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,50 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test/required_props'; | ||
|
||
import { | ||
KuiTitle, | ||
KuiText, | ||
SIZES, | ||
} from './typography'; | ||
|
||
describe('KuiTitle', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<KuiTitle { ...requiredProps }> | ||
<h1>Hello</h1> | ||
</KuiTitle> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
|
||
describe('renders size', () => { | ||
SIZES.forEach(size => { | ||
test(size, () => { | ||
const component = render( | ||
<KuiTitle size={size}> | ||
<h1>Hello</h1> | ||
</KuiTitle> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('KuiText', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<KuiText { ...requiredProps }> | ||
<h1>Hello</h1> | ||
</KuiText> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
}); |
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,4 +1,3 @@ | ||
import _ from 'lodash'; | ||
import { | ||
SortableProperties, | ||
} from './sortable_properties'; | ||
|