Skip to content

Commit

Permalink
Convert EuiFacetGroup to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
pugnascotia committed Sep 27, 2019
1 parent d70977a commit 683088c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 53 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import React from 'react';
import PropTypes from 'prop-types';
import React, { FunctionComponent, HTMLAttributes } from 'react';
import classNames from 'classnames';

import { CommonProps, keysOf } from '../common';
import { EuiFlexGroup } from '../flex';

const layoutToClassNameMap = {
type FacetGroupLayout = 'vertical' | 'horizontal';

const layoutToClassNameMap: { [layout in FacetGroupLayout]: string } = {
vertical: 'euiFacetGroup--vertical',
horizontal: 'euiFacetGroup--horizontal',
};

export const LAYOUTS = Object.keys(layoutToClassNameMap);
export const LAYOUTS = keysOf(layoutToClassNameMap);

export interface EuiFacetGroupProps {
layout?: FacetGroupLayout;
}

type Props = CommonProps & HTMLAttributes<HTMLDivElement> & EuiFacetGroupProps;

export const EuiFacetGroup = ({ children, className, layout, ...rest }) => {
export const EuiFacetGroup: FunctionComponent<Props> = ({
children,
className,
layout = 'vertical',
...rest
}) => {
const classes = classNames(
'euiFacetGroup',
layoutToClassNameMap[layout],
Expand All @@ -30,13 +44,3 @@ export const EuiFacetGroup = ({ children, className, layout, ...rest }) => {
</EuiFlexGroup>
);
};

EuiFacetGroup.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
layout: PropTypes.oneOf(LAYOUTS),
};

EuiFacetGroup.defaultProps = {
layout: 'vertical',
};
34 changes: 0 additions & 34 deletions src/components/facet/index.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/facet/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/components/facet/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { EuiFacetButton, EuiFacetButtonProps } from './facet_button';

export { EuiFacetGroup, EuiFacetGroupProps } from './facet_group';
1 change: 0 additions & 1 deletion src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/// <reference path="./date_picker/index.d.ts" />
/// <reference path="./empty_prompt/index.d.ts" />
/// <reference path="./error_boundary/index.d.ts" />
/// <reference path="./facet/index.d.ts" />
/// <reference path="./filter_group/index.d.ts" />
/// <reference path="./flyout/index.d.ts" />
/// <reference path="./form/index.d.ts" />
Expand Down

0 comments on commit 683088c

Please sign in to comment.