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

Add TypeScript types for portal, text, title components, popover service #638

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
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;
};
}