Skip to content

Commit d93b627

Browse files
committed
Added min/max toasts
1 parent 47658e3 commit d93b627

File tree

8 files changed

+97
-14
lines changed

8 files changed

+97
-14
lines changed

src/common/Icon/Icon.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AngleRightIcon } from './components/AngleRightIcon';
66
import { AnglesLeftIcon } from './components/AnglesLeftIcon';
77
import { AnglesRightIcon } from './components/AnglesRightIcon';
88
import { AngleUpIcon } from './components/AngleUpIcon';
9+
import { ArrowRightIcon } from './components/ArrowRightIcon';
910
import { ArrowsRotateIcon } from './components/ArrowsRotateIcon';
1011
import { ArrowUpRightFromSquareIcon } from './components/ArrowUpRightFromSquare';
1112
import { ArrowUpRightIcon } from './components/ArrowUpRightIcon';
@@ -22,11 +23,12 @@ import { CopyIcon } from './components/CopyIcon';
2223
import { HourglassIcon } from './components/HourglassIcon';
2324
import { LayersIcon } from './components/LayersIcon';
2425
import { LockIcon } from './components/LockIcon';
26+
import { MaximizeIcon } from './components/MaximizeIcon';
27+
import { MinimizeIcon } from './components/MinimizeIcon';
2528
import { PencilIcon } from './components/PencilIcon';
26-
import { TriangularWarningIcon } from './components/TriangularWarningIcon';
2729
import { SpinnerIcon } from './components/SpinnerIcon';
30+
import { TriangularWarningIcon } from './components/TriangularWarningIcon';
2831
import type { IconPropsType } from './icon.types';
29-
import { ArrowRightIcon } from './components/ArrowRightIcon';
3032

3133
export const Icon = ({ name, ...properties }: IconPropsType) => {
3234
if (!name) {
@@ -107,10 +109,16 @@ export const Icon = ({ name, ...properties }: IconPropsType) => {
107109
return <ArrowsRotateIcon {...properties} />;
108110

109111
case 'spinner':
110-
return <SpinnerIcon />
112+
return <SpinnerIcon />;
111113

112114
case 'arrow-right':
113-
return <ArrowRightIcon />
115+
return <ArrowRightIcon />;
116+
117+
case 'minimize':
118+
return <MinimizeIcon />;
119+
120+
case 'maximize':
121+
return <MaximizeIcon />;
114122

115123
default:
116124
console.error(`No data for the ${name} icon.`);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { h } from '@stencil/core';
2+
3+
const styles = {
4+
maximizeIcon: 'mvx:text-inherit',
5+
} satisfies Record<string, string>;
6+
7+
export const MaximizeIcon = ({ class: className }: { class?: string }) => (
8+
<svg
9+
width="16"
10+
height="16"
11+
viewBox="0 0 16 16"
12+
fill="none"
13+
xmlns="http://www.w3.org/2000/svg"
14+
class={{ [styles.maximizeIcon]: true, [className]: Boolean(className) }}
15+
>
16+
<path
17+
d="M10 5.28125L14.2812 1H11C10.7188 1 10.5 0.78125 10.5 0.5C10.5 0.25 10.7188 0 11 0H15.5C15.75 0 16 0.25 16 0.5V5C16 5.28125 15.75 5.5 15.5 5.5C15.2188 5.5 15 5.28125 15 5V1.71875L10.7188 6C10.5312 6.1875 10.1875 6.1875 10 6C9.8125 5.8125 9.8125 5.46875 10 5.28125ZM6 10.7188L1.6875 15H5C5.25 15 5.5 15.25 5.5 15.5C5.5 15.7812 5.25 16 5 16H0.5C0.21875 16 0 15.7812 0 15.5V11C0 10.75 0.21875 10.5 0.5 10.5C0.75 10.5 1 10.75 1 11V14.3125L5.28125 10C5.46875 9.8125 5.8125 9.8125 6 10C6.1875 10.1875 6.1875 10.5312 6 10.7188Z"
18+
fill="white"
19+
/>
20+
</svg>
21+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './MaximizeIcon';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { h } from '@stencil/core';
2+
3+
const styles = {
4+
minimizeIcon: 'mvx:text-inherit',
5+
} satisfies Record<string, string>;
6+
7+
export const MinimizeIcon = ({ class: className }: { class?: string }) => (
8+
<svg
9+
width="20"
10+
height="20"
11+
viewBox="0 0 20 20"
12+
fill="none"
13+
xmlns="http://www.w3.org/2000/svg"
14+
class={{ [styles.minimizeIcon]: true, [className]: Boolean(className) }}
15+
>
16+
<path
17+
d="M2.57031 16.7111L6.88281 12.4298L3.57031 12.4298C3.32031 12.4298 3.07031 12.1798 3.07031 11.9298C3.07031 11.6486 3.32031 11.4298 3.57031 11.4298L8.07031 11.4298C8.35156 11.4298 8.57031 11.6486 8.57031 11.9298L8.57031 16.4298C8.57031 16.6798 8.35156 16.9298 8.07031 16.9298C7.82031 16.9298 7.57031 16.6798 7.57031 16.4298L7.57031 13.1173L3.28906 17.4298C3.10156 17.6173 2.75781 17.6173 2.57031 17.4298C2.38281 17.2423 2.38281 16.8986 2.57031 16.7111Z"
18+
fill="white"
19+
/>
20+
<path
21+
d="M17.4297 3.28894L13.1484 7.57019L16.4297 7.57019C16.7109 7.57019 16.9297 7.78894 16.9297 8.07019C16.9297 8.32019 16.7109 8.57019 16.4297 8.57019L11.9297 8.57019C11.6797 8.57019 11.4297 8.32019 11.4297 8.07019V3.57019C11.4297 3.28894 11.6797 3.07019 11.9297 3.07019C12.2109 3.07019 12.4297 3.28894 12.4297 3.57019V6.85144L16.7109 2.57019C16.8984 2.38269 17.2422 2.38269 17.4297 2.57019C17.6172 2.75769 17.6172 3.10144 17.4297 3.28894Z"
22+
fill="white"
23+
/>
24+
</svg>
25+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './MinimizeIcon';

src/common/Icon/icon.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export enum IconNamesEnum {
2626
coins = 'coins',
2727
arrowsRotate = 'arrows-rotate',
2828
spinner = 'spinner',
29-
arrowRight = 'arrow-right'
29+
arrowRight = 'arrow-right',
30+
minimize = 'minimize',
31+
maximize = 'maximize',
3032
}
3133

3234
export type IconPropsType = JSXBase.IntrinsicElements['svg'] & {

src/components/functional/toasts-list/toast-list.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@
1818
}
1919

2020
.view-all-button-container {
21-
@apply mvx:absolute mvx:-bottom-12 mvx:right-0 mvx:z-1;
21+
@apply mvx:absolute mvx:-bottom-12 mvx:right-0 mvx:z-1 mvx:flex;
2222
}
2323

24+
.minimize-button,
25+
.maximize-button,
2426
.view-all-button {
2527
@apply mvx:backdrop-blur-2xl mvx:py-2 mvx:px-4 mvx:text-base mvx:font-normal mvx:leading-6 mvx:cursor-pointer;
2628
@apply mvx:ease-in-out mvx:transition-opacity mvx:duration-200;
2729
border-radius: 100px;
2830
border: 2px solid var(--mvx-border-color-secondary);
2931
background: var(--mvx-bg-color-primary);
3032
color: var(--mvx-text-color-primary);
33+
min-height: 44px;
3134

3235
&:hover {
3336
@apply mvx:opacity-80;

src/components/functional/toasts-list/toast-list.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Component, h, Method, State } from '@stencil/core';
2+
import { Icon } from 'common/Icon';
3+
import { IconNamesEnum } from 'common/Icon/icon.types';
24
import { ConnectionMonitor } from 'utils/ConnectionMonitor';
35
import type { IEventBus } from 'utils/EventBus';
46
import { EventBus } from 'utils/EventBus';
@@ -18,6 +20,7 @@ export class ToastList {
1820
@State() transactionToasts: ITransactionToast[] = [];
1921
@State() customToasts: CustomToastType[] = [];
2022
@State() isVisible: boolean = true;
23+
@State() isMinimized: boolean = false;
2124

2225
@Method()
2326
async getEventBus() {
@@ -80,24 +83,40 @@ export class ToastList {
8083
this.customToasts = [...payload];
8184
};
8285

86+
private readonly toggleMinimize = () => {
87+
this.isMinimized = !this.isMinimized;
88+
};
89+
8390
private resetState() {
8491
this.transactionToasts = [];
8592
this.customToasts = [];
8693
this.isVisible = true;
94+
this.isMinimized = false;
8795
}
8896

8997
render() {
9098
const hasTransactionToasts = this.transactionToasts?.length > 0;
9199

100+
const toastListClasses = {
101+
'toast-list': true,
102+
'toast-list-bottom': hasTransactionToasts,
103+
'hidden': !this.isVisible,
104+
};
105+
106+
if (this.isMinimized && hasTransactionToasts) {
107+
return (
108+
<div class={toastListClasses} id="toast-list">
109+
<div class="view-all-button-container">
110+
<button class="maximize-button" onClick={this.toggleMinimize} aria-label="Maximize Toasts">
111+
<Icon name={IconNamesEnum.maximize} />
112+
</button>
113+
</div>
114+
</div>
115+
);
116+
}
117+
92118
return (
93-
<div
94-
class={{
95-
'toast-list': true,
96-
'toast-list-bottom': hasTransactionToasts,
97-
'hidden': !this.isVisible,
98-
}}
99-
id="toast-list"
100-
>
119+
<div class={toastListClasses} id="toast-list">
101120
{this.customToasts?.map(toast => (
102121
<mvx-generic-toast toast={toast} onDeleteToast={() => this.handleCustomToastDelete(toast.toastId)} />
103122
))}
@@ -108,6 +127,9 @@ export class ToastList {
108127

109128
{hasTransactionToasts && (
110129
<div class="view-all-button-container">
130+
<button class="minimize-button" onClick={this.toggleMinimize} aria-label="Minimize Toasts">
131+
<Icon name={IconNamesEnum.minimize} />
132+
</button>
111133
<button class="view-all-button" onClick={this.handleViewAllClick}>
112134
View All
113135
</button>

0 commit comments

Comments
 (0)