Skip to content

Commit 8126304

Browse files
committed
feat: add types of alerts
- hassome bugs - but it's a start
1 parent 9ec7e4b commit 8126304

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

GUI/ETVR/src/components/Notifications/CustomToast/index.tsx

+23-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Transition, Toast, Alert } from 'solid-headless'
33
import { AiOutlineCheckCircle } from 'solid-icons/ai'
44
import { FiAlertTriangle, FiAlertOctagon } from 'solid-icons/fi'
55
import { IoAlertCircleSharp } from 'solid-icons/io'
6-
import { createSignal, Component } from 'solid-js'
6+
import { createSignal, Component, Show } from 'solid-js'
77
import CloseIcon from '@components/CloseIcon'
88
import { ENotificationType } from '@static/types/enums'
99
import { notifications, notificationsType } from '@store/ui/selectors'
@@ -14,16 +14,27 @@ interface ToastProps {
1414
}
1515

1616
const NotificationIcon = () => {
17-
switch (notificationsType()) {
18-
case ENotificationType.SUCCESS:
19-
return <AiOutlineCheckCircle size={25} color="#68D391" />
20-
case ENotificationType.ERROR:
21-
return <FiAlertOctagon size={25} color="#F56565" />
22-
case ENotificationType.WARNING:
23-
return <FiAlertTriangle size={25} color="#F6E05E" />
24-
case ENotificationType.INFO:
25-
return <IoAlertCircleSharp size={25} color="#90CDF4" />
26-
}
17+
return (
18+
<div>
19+
<Show when={notificationsType() === ENotificationType.SUCCESS}>
20+
<AiOutlineCheckCircle size={25} color="#68D391" />
21+
</Show>
22+
<Show when={notificationsType() === ENotificationType.ERROR}>
23+
<FiAlertOctagon size={25} color="#F56565" />
24+
</Show>
25+
<Show when={notificationsType() === ENotificationType.WARNING}>
26+
<FiAlertTriangle size={25} color="#F6E05E" />
27+
</Show>
28+
<Show when={notificationsType() === ENotificationType.INFO}>
29+
<IoAlertCircleSharp size={25} color="#90CDF4" />
30+
</Show>
31+
</div>
32+
)
33+
34+
/*
35+
36+
37+
*/
2738
}
2839

2940
const CustomToast: Component<ToastProps> = (props) => {
@@ -48,7 +59,7 @@ const CustomToast: Component<ToastProps> = (props) => {
4859
}}>
4960
<Toast class="flex justify-between items-center">
5061
<Alert class="bg-slate-600 flex grow flex-row items-center justify-center text-xl text-bold text-gray-50 p-4">
51-
{NotificationIcon()}
62+
<NotificationIcon />
5263
<span class="flex-1 text-sm font-semibold pl-1 pr-1 text-gray-50">
5364
{props.message}
5465
</span>

GUI/ETVR/src/pages/Settings/index.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { DropdownMenu } from '@kobalte/core'
22
import { createSignal } from 'solid-js'
33
import Button from '@components/Button'
4-
import { ENotificationAction } from '@static/types/enums'
54
import { addNotification } from '@src/store/ui/components/actions'
5+
import { ENotificationAction, ENotificationType } from '@static/types/enums'
66
import './styles.css'
77

88
const SettingsPage = () => {
99
const [open, setOpen] = createSignal(false)
1010
const [type, setType] = createSignal<ENotificationAction>(ENotificationAction.APP)
11+
const [alertType, setAlertType] = createSignal<ENotificationType>(ENotificationType.INFO)
1112
return (
1213
<div class="pb-[5rem] h-[95%] xl:h-[100%] xl:pb-[1rem] grow flex-col pt-6 py-6 px-8">
1314
<DropdownMenu.Root isOpen={open()} onOpenChange={setOpen}>
@@ -25,13 +26,28 @@ const SettingsPage = () => {
2526
onClick={() => setType(ENotificationAction.APP)}>
2627
App Level Notification
2728
</DropdownMenu.Item>
28-
<DropdownMenu.Separator class="dropdown-menu__separator" />
2929
<DropdownMenu.Item
3030
class="dropdown-menu__item"
3131
onClick={() => setType(ENotificationAction.OS)}>
3232
OS Level Notification
3333
</DropdownMenu.Item>
3434
</DropdownMenu.Group>
35+
<DropdownMenu.Separator class="dropdown-menu__separator" />
36+
<DropdownMenu.Group>
37+
<DropdownMenu.GroupLabel class="dropdown-menu__group-label">
38+
Alert Type
39+
</DropdownMenu.GroupLabel>
40+
<DropdownMenu.Item
41+
class="dropdown-menu__item"
42+
onClick={() => setAlertType(ENotificationType.SUCCESS)}>
43+
SUCCESS
44+
</DropdownMenu.Item>
45+
<DropdownMenu.Item
46+
class="dropdown-menu__item"
47+
onClick={() => setAlertType(ENotificationType.ERROR)}>
48+
ERROR
49+
</DropdownMenu.Item>
50+
</DropdownMenu.Group>
3551
<DropdownMenu.Arrow />
3652
</DropdownMenu.Content>
3753
</DropdownMenu.Portal>
@@ -43,6 +59,7 @@ const SettingsPage = () => {
4359
{
4460
title: 'Test',
4561
message: `This toast is created on ${new Date().toTimeString()}`,
62+
type: alertType(),
4663
},
4764
type(),
4865
)

GUI/ETVR/src/store/ui/ui.ts

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const defaultState = {
4040
connectedUser: '',
4141
showCameraView: false,
4242
notifications: new ToasterStore<string>(),
43+
notificationsType: ENotificationType.INFO,
4344
displayMode: POPOVER_ID.GRIP,
4445
}
4546

0 commit comments

Comments
 (0)