react-notify-sdk 1.0.10 → 1.0.12

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.
@@ -4,12 +4,14 @@ import { useEffect, useState } from 'react';
4
4
  import { useLocation } from 'react-router-dom';
5
5
  import clsx from 'clsx';
6
6
  import { supabase } from './supabase/supabaseClient';
7
+ import useDeviceDetection from './UseDeviceDetection';
7
8
  export const NotifyProvider = ({ projectId,
8
9
  //className,
9
10
  //style,
10
11
  disableDefaultStyles = false, }) => {
11
12
  const [message, setMessage] = useState(null);
12
13
  const location = useLocation();
14
+ const device = useDeviceDetection();
13
15
  useEffect(() => {
14
16
  if (typeof window === 'undefined')
15
17
  return; // Skip on server
@@ -45,19 +47,20 @@ disableDefaultStyles = false, }) => {
45
47
  }, [location.pathname, projectId]);
46
48
  if (!message)
47
49
  return null;
48
- const defaultClasses = `absolute ${message?.position}-4 left-1/2 transform -translate-x-1/2 z-50 w-[${message?.width}%] px-3 bg-[${message?.backgroundColor}] border border-[${message?.borderColor}] text-[${message?.textColor}] rounded-lg shadow`;
49
- return (_jsxs("div", { className: clsx(!disableDefaultStyles && defaultClasses), style: disableDefaultStyles ?
50
+ const defaultClasses = `absolute ${message?.position}-6 left-1/2 transform -translate-x-1/2 z-20 w-full md:w-[${message?.width}%] px-3 bg-[${message?.backgroundColor}] border border-[${message?.borderColor}] text-[${message?.textColor}] rounded-lg shadow`;
51
+ return (_jsxs("div", { className: clsx(!disableDefaultStyles && defaultClasses), style: !disableDefaultStyles ?
50
52
  {
51
53
  position: 'absolute',
52
- top: message?.position === 'top' ? '16px' : undefined,
53
- bottom: message?.position === 'top' ? undefined : '16px',
54
+ top: message?.position === 'top' ? '24px' : undefined,
55
+ bottom: message?.position === 'bottom' ? '24px' : undefined,
54
56
  left: '50%',
55
57
  transform: 'translateX(-50%)',
56
- zIndex: 50,
57
- width: `${message?.width}%`,
58
+ zIndex: 20,
59
+ width: device === 'Mobile' ? '100%' : device === 'Tablet' ? '80%' : `${message?.width}%`,
58
60
  padding: '1rem', // p-4 = 1rem
59
61
  backgroundColor: message?.backgroundColor,
60
- border: '1px solid', // Completed border style
62
+ border: `1px solid ${message?.textColor}`, // Completed border style
63
+ borderRadius: "8px"
61
64
  }
62
65
  :
63
66
  {}, children: [_jsx("strong", { className: `block mb-2 text-lg font-semibold text-[${message?.textColor}]`, style: {
@@ -68,6 +71,6 @@ disableDefaultStyles = false, }) => {
68
71
  color: `${message?.backgroundColor}`,
69
72
  }, children: message.title }), _jsx("p", { className: `text-sm text-[${message?.textColor}]`, style: {
70
73
  fontSize: '0.875rem', // text-sm = 14px = 0.875rem
71
- color: `${message?.backgroundColor}`,
74
+ color: `${message?.textColor}`,
72
75
  }, children: message.content })] }));
73
76
  };
@@ -0,0 +1,2 @@
1
+ declare const useDeviceDetection: () => string;
2
+ export default useDeviceDetection;
@@ -0,0 +1,28 @@
1
+ import { useState, useEffect } from 'react';
2
+ const useDeviceDetection = () => {
3
+ const [device, setDevice] = useState('');
4
+ useEffect(() => {
5
+ const handleDeviceDetection = () => {
6
+ const userAgent = navigator.userAgent.toLowerCase();
7
+ const isMobile = /iphone|ipad|ipod|android|blackberry|windows phone/g.test(userAgent);
8
+ const isTablet = /(ipad|tablet|playbook|silk)|(android(?!.*mobile))/g.test(userAgent);
9
+ if (isMobile) {
10
+ setDevice('Mobile');
11
+ }
12
+ else if (isTablet) {
13
+ setDevice('Tablet');
14
+ }
15
+ else {
16
+ console.log("Device is a desktop");
17
+ setDevice('Desktop');
18
+ }
19
+ };
20
+ handleDeviceDetection();
21
+ window.addEventListener('resize', handleDeviceDetection);
22
+ return () => {
23
+ window.removeEventListener('resize', handleDeviceDetection);
24
+ };
25
+ }, []);
26
+ return device;
27
+ };
28
+ export default useDeviceDetection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-notify-sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "SDK for displaying real-time route-specific messages in React apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",