Skip to content

Commit

Permalink
Add types for EuiEmptyPrompt, EuiCode(Block), EuiCallOut (#1010)
Browse files Browse the repository at this point in the history
This PR adds type definitions for the `<EuiEmptyPrompt>`, `<EuiCode>`, `<EuiCodeBlock>`, and `<EuiCallOut>`. All components are pretty straight forward.
  • Loading branch information
Spencer authored Jul 13, 2018
1 parent 7aa94ce commit cde4c1b
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `3.0.0`.
- Added typings for `EuiEmptyPrompt`, `EuiCode`, `EuiCodeBlock`, and `EuiCallOut` ([#1010](https://github.com/elastic/eui/pull/1010))

## [`3.0.0`](https://github.com/elastic/eui/tree/v3.0.0)

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

import { SFC, ReactNode, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
/**
* EuiCallOut type defs
*
* @see './code.js'
*/

type Color = 'primary' | 'success' | 'warning' | 'danger';
type Size = 's' | 'm';

export interface EuiCallOutProps {
title?: ReactNode,
iconType?: IconType,
color?: Color,
size?: Size,
}

export const EuiCallOut: SFC<
CommonProps & EuiCallOutProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'>
>;
}
57 changes: 57 additions & 0 deletions src/components/code/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/// <reference path="../common.d.ts" />

import { SFC, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
type FontSize = 's' | 'm' | 'l';
type PaddingSize = 'none' | 's' | 'm' | 'l';

// there isn't a specific type for the <code> element, and MDN
// says that it only supports the HTMLElement interface
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code
type HTMLCodeElement = HTMLElement

interface EuiCodeSharedProps {
paddingSize?: PaddingSize;

/**
* Sets the syntax highlighting for a specific language
* See http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases
* for options
*/
language?: string;

overflowHeight?: number;
fontSize?: FontSize;
transparentBackground?: boolean;
}


/**
* EuiCode type defs
*
* @see './code.js'
*/

export interface EuiCodeProps extends EuiCodeSharedProps {
inline?: true
}

export const EuiCode: SFC<
CommonProps & EuiCodeProps & HTMLAttributes<HTMLCodeElement>
>;

/**
* EuiCodeBlock type defs
*
* @see './code_block.js'
*/

export interface EuiCodeBlockProps extends EuiCodeSharedProps {
inline?: false
}

export const EuiCodeBlock: SFC<
CommonProps & EuiCodeBlockProps & HTMLAttributes<HTMLCodeElement>
>;
}
28 changes: 28 additions & 0 deletions src/components/empty_prompt/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// <reference path="../common.d.ts" />
/// <reference path="../icon/index.d.ts" />
/// <reference path="../title/index.d.ts" />

import { SFC, ReactNode, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
/**
* EuiEmptyPrompt type defs
*
* @see './empty_prompt.js'
*/

export interface EuiEmptyPromptProps {
iconType?: IconType;
iconColor?: IconColor;
title?: ReactNode;
titleSize?: EuiTitleSize;
body?: ReactNode;
actions?: ReactNode;
}

export const EuiEmptyPrompt: SFC<
CommonProps & EuiEmptyPromptProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'>
>;


}
3 changes: 3 additions & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
/// <reference path="./horizontal_rule/index.d.ts" />
/// <reference path="./page/index.d.ts" />
/// <reference path="./flyout/index.d.ts" />
/// <reference path="./empty_prompt/index.d.ts" />
/// <reference path="./code/index.d.ts" />
/// <reference path="./call_out/index.d.ts" />

0 comments on commit cde4c1b

Please sign in to comment.