Skip to content

Commit

Permalink
Add TypeScript types for portal, text, title components, popover serv…
Browse files Browse the repository at this point in the history
…ice (#638)
  • Loading branch information
weltenwort authored Apr 9, 2018
1 parent 8a675fc commit 69f7c07
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- Tweaked sizing, weights, color, line-heights, and added more levels to `EuiTitle` and `EuiText` ([#627](https://github.com/elastic/eui/pull/627))
- Add TypeScript type defitions for `EuiPortal`, `EuiText` and `EuiTitle` as well as the `calculatePopoverPosition` service ([#638](https://github.com/elastic/eui/pull/638))

**Bug fixes**

Expand Down
3 changes: 3 additions & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
/// <reference path="./link/index.d.ts" />
/// <reference path="./loading/index.d.ts" />
/// <reference path="./progress/index.d.ts" />
/// <reference path="./portal/index.d.ts" />
/// <reference path="./title/index.d.ts" />
/// <reference path="./text/index.d.ts" />
14 changes: 14 additions & 0 deletions src/components/portal/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module '@elastic/eui' {
import { SFC } from 'react';

/**
* portal type defs
*
* @see './portal.js'
*/
type EuiPortalProps = {
children: React.ReactNode;
};

export const EuiPortal: SFC<EuiPortalProps>;
}
30 changes: 30 additions & 0 deletions src/components/text/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference path="../common.d.ts" />

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

/**
* text type defs
*
* @see './text.js'
* @see './text_color.js'
*/
type EuiTextSize = 's' | 'xs';

type EuiTextColor =
| 'default'
| 'subdued'
| 'secondary'
| 'accent'
| 'danger'
| 'warning'
| 'ghost';

type EuiTextProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
size?: EuiTextSize;
color?: EuiTextColor;
};

export const EuiText: SFC<EuiTextProps>;
}
22 changes: 22 additions & 0 deletions src/components/title/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference path="../common.d.ts" />

declare module '@elastic/eui' {
import { SFC } from 'react';

/**
* title type defs
*
* @see './title.js'
*/

type EuiTitleSize = 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l';

type EuiTitleTextTransform = 'uppercase';

type EuiTitleProps = CommonProps & {
size?: EuiTitleSize;
textTransform?: EuiTitleTextTransform;
};

export const EuiTitle: SFC<EuiTitleProps>;
}
1 change: 1 addition & 0 deletions src/services/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="./alignment.d.ts" />
/// <reference path="./popover/index.d.ts" />
29 changes: 29 additions & 0 deletions src/services/popover/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
declare module '@elastic/eui' {
type EuiToolTipPosition = 'top' | 'right' | 'bottom' | 'left';

type EuiPopoverAnchorRect = {
top: number;
left: number;
width: number;
height: number;
};

type EuiPopoverDimensions = {
width: number;
height: number;
};

export const calculatePopoverPosition: (
anchorBounds: EuiPopoverAnchorRect,
popoverBounds: EuiPopoverDimensions,
requestedPosition: EuiToolTipPosition,
buffer?: number,
positions?: EuiToolTipPosition[]
) => {
top: number;
left: number;
width: number;
height: number;
position: EuiToolTipPosition;
};
}

0 comments on commit 69f7c07

Please sign in to comment.