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 typedefs for EuiAvatar component and color service #1120

Merged
merged 4 commits into from
Aug 17, 2018
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
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" />