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

EuiGlobalToastListItem convert to TS #1880

Merged
merged 4 commits into from
Apr 29, 2019
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,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Converted `EuiGlobalToastListItem` to TS ([#1880](https://github.com/elastic/eui/pull/1880))
- Converted `token_map` to TS ([#1870](https://github.com/elastic/eui/pull/1870))
- Converted `EuiOverlayMask` to TS ([#1858](https://github.com/elastic/eui/pull/1858))
- Converted `EuiStat` to TS ([#1848](https://github.com/elastic/eui/pull/1848))
Expand Down
20 changes: 0 additions & 20 deletions src/components/toast/global_toast_list_item.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('EuiGlobalToastListItem', () => {
</EuiGlobalToastListItem>
);

expect(component)
.toMatchSnapshot();
expect(component).toMatchSnapshot();
});
});
28 changes: 28 additions & 0 deletions src/components/toast/global_toast_list_item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { cloneElement, FunctionComponent, ReactElement } from 'react';
import classNames from 'classnames';
import { CommonProps } from '../common';

export interface EuiGlobalToastListItemProps {
isDismissed?: boolean;
children?: ReactElement;
}

export const EuiGlobalToastListItem: FunctionComponent<
CommonProps & EuiGlobalToastListItemProps
> = ({ children, isDismissed }) => {
if (!children) {
return null;
}
const classes = classNames(
'euiGlobalToastListItem',
children.props.className,
{
'euiGlobalToastListItem-isDismissed': isDismissed,
}
);

return cloneElement(children, {
...children.props,
...{ className: classes },
});
};
31 changes: 15 additions & 16 deletions src/components/toast/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import {
EuiGlobalToastListItemProps as ToastListItemProps,
EuiGlobalToastListItem as ToastListItem,
} from './global_toast_list_item';
import { CommonProps } from '../common';
import { IconType } from '../icon';

import { Component, FunctionComponent, HTMLAttributes, ReactChild } from 'react';
import {
Component,
FunctionComponent,
HTMLAttributes,
ReactChild,
} from 'react';

declare module '@elastic/eui' {
/**
* EuiToast type def
*
* @see './toast.js'
*/
export interface EuiToastProps extends CommonProps, HTMLAttributes<HTMLDivElement> {
export interface EuiToastProps
extends CommonProps,
HTMLAttributes<HTMLDivElement> {
title?: string,
color?: 'primary' | 'success' | 'warning' | 'danger',
iconType?: IconType,
onClose?: () => void,
}

export const EuiToast: FunctionComponent<EuiToastProps>;


/**
* EuiGlobalToastListItem type def
*
* @see './global_toast_list_item.js'
*/
export interface EuiGlobalToastListItemProps {
isDismissed?: boolean;
}

export const EuiGlobalToastListItem: FunctionComponent<
EuiGlobalToastListItemProps
>
export interface EuiGlobalToastListItemProps extends ToastListItemProps {}
export const EuiGlobalToastListItem: typeof ToastListItem;

/**
* EuiGlobalToastList type def
Expand Down