Skip to content

Commit

Permalink
Update eslint config to lint the new UI Framework directory structure. (
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Aug 11, 2017
1 parent 1abbced commit e170437
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tasks/config/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export default grunt => ({
'scripts',
'tasks',
'test',
'ui_framework/components',
'ui_framework/doc_site',
'ui_framework/src',
'ui_framework/doc_site/src',
'ui_framework/generator_kui',
'utilities',
'webpackShims',
],
Expand Down
43 changes: 43 additions & 0 deletions ui_framework/src/components/typography/typography.js
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,
};
50 changes: 50 additions & 0 deletions ui_framework/src/components/typography/typography.test.js
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();
});
});
1 change: 0 additions & 1 deletion ui_framework/src/services/sort/sortable_properties.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import {
SortableProperties,
} from './sortable_properties';
Expand Down

0 comments on commit e170437

Please sign in to comment.