main
Last change
on this file since fe03f69 was 87614a5, checked in by anastasovv <simon@…>, 2 years ago |
Blackjack prototype
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[87614a5] | 1 | import React from 'react'
|
---|
| 2 |
|
---|
| 3 | import { AiOutlineClose } from 'react-icons/ai';
|
---|
| 4 |
|
---|
| 5 | import { useDispatch, useSelector } from 'react-redux';
|
---|
| 6 | import { setStyle } from '../redux/reducers/styleSlice';
|
---|
| 7 |
|
---|
| 8 | const Notification = () => {
|
---|
| 9 | const styleState = useSelector(state => state.style);
|
---|
| 10 |
|
---|
| 11 | const dispatch = useDispatch();
|
---|
| 12 |
|
---|
| 13 | const display = styleState.style.notification.show === true ? 'flex' : 'none';
|
---|
| 14 | const bg = styleState.style.notification.status === 'success' ? 'rgba(0, 200, 255, 0.8)' : 'rgba(255, 0, 0, 0.8)';
|
---|
| 15 |
|
---|
| 16 | function close() {
|
---|
| 17 | dispatch(setStyle({
|
---|
| 18 | ...styleState.style,
|
---|
| 19 | notification: {
|
---|
| 20 | ...styleState.style.notification,
|
---|
| 21 | show: false,
|
---|
| 22 | }
|
---|
| 23 | }))
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | return (
|
---|
| 27 | <div className="notification" style={{display: display, backgroundColor: bg}}>
|
---|
| 28 | <AiOutlineClose onClick={() => close()}/>
|
---|
| 29 | <div>
|
---|
| 30 | {styleState.style.notification.text}
|
---|
| 31 | </div>
|
---|
| 32 | </div>
|
---|
| 33 | )
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | export default Notification |
---|
Note:
See
TracBrowser
for help on using the repository browser.