Skip to content

Commit

Permalink
Add typedefs for EuiAvatar component and color service (#1120)
Browse files Browse the repository at this point in the history
This PR adds typedefs for the following:
- `EuiAvatar` component
- `color` service
  • Loading branch information
legrego authored Aug 17, 2018
1 parent 387c736 commit c508b75
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/avatar/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference path="../common.d.ts" />

import { HTMLAttributes, SFC } from 'react';

declare module '@elastic/eui' {

export type AvatarSize = 's' | 'm' | 'l' | 'xl';

export type AvatarType = 'user' | 'space';

export interface EuiAvatarProps {
name: string;
color?: string;
initials?: string;
initialsLength?: number;
className?: string;
imageUrl?: string;
size?: AvatarSize;
type?: AvatarType;
}

export const EuiAvatar: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiAvatarProps
>;
}
1 change: 1 addition & 0 deletions src/components/form/field_search/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare module '@elastic/eui' {
isInvalid?: boolean;
fullWidth?: boolean;
isLoading?: boolean;
incremental?: boolean;
}

export const EuiFieldSearch: SFC<
Expand Down
1 change: 1 addition & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="./common.d.ts" />
/// <reference path="./avatar/index.d.ts" />
/// <reference path="./button/index.d.ts" />
/// <reference path="./context_menu/index.d.ts" />
/// <reference path="./flex/index.d.ts" />
Expand Down
16 changes: 16 additions & 0 deletions src/services/color/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

declare module '@elastic/eui' {
export const VISUALIZATION_COLORS: string[];

export const DEFAULT_VISUALIZATION_COLOR: string;

type rgbDef = [number, number, number];

export const hexToRbg: (hex: string) => rgbDef;
export const rgbToHex: (rgb: string) => string;

export const isColorDark: (red: number, green: number, blue: number) => boolean;

export const calculateLuminance: (red: number, green: number, blue: number) => number;
export const calculateContrast: (rgb1: rgbDef, rgb2: rgbDef) => number;
}
1 change: 1 addition & 0 deletions src/services/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference path="./alignment.d.ts" />
/// <reference path="./key_codes.d.ts" />
/// <reference path="./color/index.d.ts" />
/// <reference path="./popover/index.d.ts" />

0 comments on commit c508b75

Please sign in to comment.