Skip to content

Commit

Permalink
Add TS types for EuiTab/EuiTabs/EuiTabbedContent (#1288)
Browse files Browse the repository at this point in the history
* Add TS types for EuiTab/EuiTabs/EuiTabbedContent

* Fixes

* Add CHANGELOG entry

* Update CHANGELOG.md
  • Loading branch information
joshdover authored Nov 6, 2018
1 parent 6366145 commit 06de080
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `4.8.0`.
**Bug fixes**
- Added TypeScript definitions for tab components ([#1288](https://github.com/elastic/eui/pull/1288))

## [`4.8.0`](https://github.com/elastic/eui/tree/v4.8.0)

Expand Down
37 changes: 37 additions & 0 deletions src/components/tabs/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference path="../common.d.ts" />

declare module '@elastic/eui' {
import { MouseEventHandler, ReactNode, SFC, HTMLAttributes } from 'react';

type TAB_SIZES = 's' | 'm';

type EuiTabProps = {
onClick: MouseEventHandler<HTMLButtonElement>;
isSelected?: boolean;
disabled?: boolean;
};

type EuiTabsProps = {
size?: TAB_SIZES;
expand?: boolean;
};

export interface EuiTabbedContentTab {
id: string;
name: string;
content: ReactNode;
}

type EuiTabbedContentProps = {
tabs: EuiTabbedContentTab[];
onTabClick?: (tab: EuiTabbedContentTab) => void;
selectedTab?: EuiTabbedContentTab;
initialSelectedTab?: EuiTabbedContentTab;
size?: TAB_SIZES;
expand?: boolean;
}

export const EuiTab: SFC<EuiTabProps & CommonProps & HTMLAttributes<HTMLDivElement>>;
export const EuiTabs: SFC<EuiTabsProps & CommonProps & HTMLAttributes<HTMLDivElement>>;
export const EuiTabbedContent: SFC<EuiTabbedContentProps & CommonProps & HTMLAttributes<HTMLDivElement>>;
}
4 changes: 2 additions & 2 deletions src/components/text/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare module '@elastic/eui' {
* @see './text.js'
* @see './text_color.js'
*/
type SIZES = 's' | 'xs';
type TEXT_SIZES = 's' | 'xs';

type COLORS =
| 'default'
Expand All @@ -22,7 +22,7 @@ declare module '@elastic/eui' {

type EuiTextProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
size?: SIZES;
size?: TEXT_SIZES;
color?: COLORS;
grow?: boolean;
};
Expand Down

0 comments on commit 06de080

Please sign in to comment.