react-notify-sdk 1.0.11 → 1.0.13

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,23 @@ 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 py-1 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
- padding: '1rem', // p-4 = 1rem
58
+ zIndex: 20,
59
+ width: device === 'Mobile' ? '100%' : device === 'Tablet' ? '80%' : `${message?.width}%`,
60
+ paddingTop: '4px', // p-4 = 1rem
61
+ paddingBottom: '4px',
62
+ paddingLeft: '12px',
63
+ paddingRight: '12px',
59
64
  backgroundColor: message?.backgroundColor,
60
65
  border: `1px solid ${message?.textColor}`, // Completed border style
66
+ borderRadius: "8px"
61
67
  }
62
68
  :
63
69
  {}, children: [_jsx("strong", { className: `block mb-2 text-lg font-semibold text-[${message?.textColor}]`, style: {
@@ -65,7 +71,7 @@ disableDefaultStyles = false, }) => {
65
71
  marginBottom: '0.5rem', // mb-2 = 0.5rem
66
72
  fontSize: '1.125rem', // text-lg = 18px = 1.125rem
67
73
  fontWeight: 600, // font-semibold = 600
68
- color: `${message?.backgroundColor}`,
74
+ color: `${message?.textColor}`,
69
75
  }, children: message.title }), _jsx("p", { className: `text-sm text-[${message?.textColor}]`, style: {
70
76
  fontSize: '0.875rem', // text-sm = 14px = 0.875rem
71
77
  color: `${message?.textColor}`,
@@ -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.11",
3
+ "version": "1.0.13",
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",