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

Added side property to 'EuiGlobalToastList' #3600

Merged
merged 8 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`EuiGlobalToastList is rendered 1`] = `
<div
aria-label="aria-label"
aria-live="polite"
class="euiGlobalToastList testClass1 testClass2"
class="euiGlobalToastList testClass1 testClass2 euiGlobalToastList-right"
data-test-subj="test subject string"
role="region"
/>
Expand All @@ -13,7 +13,7 @@ exports[`EuiGlobalToastList is rendered 1`] = `
exports[`EuiGlobalToastList props toasts is rendered 1`] = `
<div
aria-live="polite"
class="euiGlobalToastList"
class="euiGlobalToastList euiGlobalToastList-left"
role="region"
>
<div
Expand Down
9 changes: 8 additions & 1 deletion src/components/toast/_global_toast_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
position: fixed;
z-index: $euiZToastList;
bottom: 0;
right: 0;
width: $euiToastWidth + $euiSize + $euiSizeXL; /* 3 */
padding-right: $euiSize;
padding-left: $euiSizeXL;
Expand All @@ -23,6 +22,14 @@
}
}

.euiGlobalToastList-right {
right: 0;
}

.euiGlobalToastList-left {
left: 0;
}

.euiGlobalToastListItem {
margin-bottom: $euiSize;
margin-right: $euiSize;
Expand Down
1 change: 1 addition & 0 deletions src/components/toast/global_toast_list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('EuiGlobalToastList', () => {
toasts={toasts}
dismissToast={() => {}}
toastLifeTimeMs={5}
side="left"
cchaos marked this conversation as resolved.
Show resolved Hide resolved
/>
);

Expand Down
12 changes: 10 additions & 2 deletions src/components/toast/global_toast_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface EuiGlobalToastListProps extends CommonProps {
toasts: Toast[];
dismissToast: (this: EuiGlobalToastList, toast: Toast) => void;
toastLifeTimeMs: number;
side?: 'right' | 'left';
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}

interface State {
Expand Down Expand Up @@ -69,6 +70,7 @@ export class EuiGlobalToastList extends Component<

static defaultProps = {
toasts: [],
side: 'right',
};

startScrollingToBottom() {
Expand Down Expand Up @@ -247,6 +249,7 @@ export class EuiGlobalToastList extends Component<
toasts,
dismissToast,
toastLifeTimeMs,
side,
...rest
} = this.props;

Expand All @@ -267,8 +270,13 @@ export class EuiGlobalToastList extends Component<
</EuiGlobalToastListItem>
);
});

const classes = classNames('euiGlobalToastList', className);
const additionalClass =
side === 'left' ? 'euiGlobalToastList-left' : 'euiGlobalToastList-right';
cchaos marked this conversation as resolved.
Show resolved Hide resolved
const classes = classNames(
'euiGlobalToastList',
className,
additionalClass
);

return (
<div
Expand Down