Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizontal rule conversion to ts #7

Merged
merged 4 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {
EuiHorizontalRule,
} from '../../../../src/components';
} from '../../../../src/components/horizontal_rule';

export default () => (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {
EuiHorizontalRule,
} from '../../../../src/components';
} from '../../../../src/components/horizontal_rule';

export default () => (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import React, { SFC, HTMLAttributes } from 'react';
import classNames from 'classnames';

import { CommonProps } from '../common';

export type EuiHorizontalRuleSize = keyof typeof sizeToClassNameMap;
export type EuiHorizontalRuleMargin = keyof typeof marginToClassNameMap;

export interface EuiHorizontalRuleProps {
/**
* Defines the width of the HR.
*/
size?: EuiHorizontalRuleSize;
margin?: EuiHorizontalRuleMargin;
}

const sizeToClassNameMap = {
full: 'euiHorizontalRule--full',
half: 'euiHorizontalRule--half',
Expand All @@ -22,16 +34,18 @@ const marginToClassNameMap = {

export const MARGINS = Object.keys(marginToClassNameMap);

export const EuiHorizontalRule = ({
export const EuiHorizontalRule: SFC<
CommonProps & HTMLAttributes<HTMLHRElement> & EuiHorizontalRuleProps
> = ({
className,
size,
margin,
...rest
}) => {
const classes = classNames(
'euiHorizontalRule',
sizeToClassNameMap[size],
marginToClassNameMap[margin],
size ? sizeToClassNameMap[size] : undefined,
margin ? marginToClassNameMap[margin] : undefined,
className
);

Expand All @@ -43,13 +57,6 @@ export const EuiHorizontalRule = ({
);
};

EuiHorizontalRule.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
size: PropTypes.oneOf(SIZES),
margin: PropTypes.oneOf(MARGINS),
};

EuiHorizontalRule.defaultProps = {
size: 'full',
margin: 'l',
Expand Down
26 changes: 0 additions & 26 deletions src/components/horizontal_rule/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
/// <reference path="./flyout/index.d.ts" />
/// <reference path="./form/index.d.ts" />
/// <reference path="./health/index.d.ts" />
/// <reference path="./horizontal_rule/index.d.ts" />
/// <reference path="./icon/index.d.ts" />
/// <reference path="./key_pad_menu/index.d.ts" />
/// <reference path="./link/index.d.ts" />
Expand Down