@esitorsunil/new-folder 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["@babel/preset-env", "@babel/preset-react"]
3
+ }
package/README.md ADDED
File without changes
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@esitorsunil/new-folder",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "build": "babel src --out-dir dist --copy-files"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "@reduxjs/toolkit": "^1.9.0",
15
+ "react": ">=17.0.0",
16
+ "react-dom": ">=17.0.0",
17
+ "react-redux": "^8.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@babel/cli": "^7.27.2",
21
+ "@babel/core": "^7.27.1",
22
+ "@babel/plugin-transform-runtime": "^7.27.1",
23
+ "@babel/preset-env": "^7.27.2",
24
+ "@babel/preset-react": "^7.27.1",
25
+ "babel-plugin-transform-react-remove-prop-types": "^0.4.24"
26
+ },
27
+ "peerDependencies": {
28
+ "@reduxjs/toolkit": "^1.9.0",
29
+ "react": ">=17.0.0",
30
+ "react-dom": ">=17.0.0",
31
+ "react-redux": "^8.0.0"
32
+ }
33
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './notification/NotificationsPanel';
2
+ export * from './notification/notificationsSlice';
@@ -0,0 +1,47 @@
1
+ // NotificationsPanel.jsx
2
+ import React from 'react';
3
+ import { useSelector, useDispatch } from 'react-redux';
4
+ import { removeNotification } from './notificationsSlice';
5
+
6
+ export const NotificationsPanel = () => {
7
+ const notifications = useSelector((state) => state.notifications.items);
8
+ const dispatch = useDispatch();
9
+
10
+ return (
11
+ <div style={{ position: 'fixed', top: 10, right: 10, zIndex: 1000 }}>
12
+ {notifications.map(n => (
13
+ <div
14
+ key={n.id}
15
+ style={{
16
+ background:
17
+ n.type === 'error'
18
+ ? '#f44336'
19
+ : n.type === 'success'
20
+ ? '#4caf50'
21
+ : '#2196f3',
22
+ color: '#fff',
23
+ padding: '10px 15px',
24
+ marginBottom: 8,
25
+ borderRadius: 4,
26
+ minWidth: 200,
27
+ boxShadow: '0 2px 4px rgba(0,0,0,0.3)',
28
+ }}
29
+ >
30
+ {n.message}
31
+ <button
32
+ onClick={() => dispatch(removeNotification(n.id))}
33
+ style={{
34
+ marginLeft: 10,
35
+ background: 'transparent',
36
+ border: 'none',
37
+ color: '#fff',
38
+ cursor: 'pointer',
39
+ }}
40
+ >
41
+ ×
42
+ </button>
43
+ </div>
44
+ ))}
45
+ </div>
46
+ );
47
+ };
@@ -0,0 +1,24 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+
3
+ const initialState = {
4
+ items: [],
5
+ };
6
+
7
+ const notificationsSlice = createSlice({
8
+ name: 'notifications',
9
+ initialState,
10
+ reducers: {
11
+ pushNotification: (state, action) => {
12
+ state.items.push(action.payload);
13
+ },
14
+ removeNotification: (state, action) => {
15
+ state.items = state.items.filter(n => n.id !== action.payload);
16
+ },
17
+ clearNotifications: (state) => {
18
+ state.items = [];
19
+ },
20
+ },
21
+ });
22
+
23
+ export const { pushNotification, removeNotification, clearNotifications } = notificationsSlice.actions;
24
+ export const notificationsReducer = notificationsSlice.reducer;