@datlv-trustshop/shopify-inapp-components 0.1.22 → 0.1.24
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.
|
@@ -36,6 +36,9 @@ interface FloatingCardProps {
|
|
|
36
36
|
onDismiss?: () => void;
|
|
37
37
|
onPrimaryAction?: (data: FloatingCardData) => void;
|
|
38
38
|
onSecondaryAction?: (data: FloatingCardData) => void;
|
|
39
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
40
|
+
animationType?: 'slide' | 'fade';
|
|
41
|
+
showCloseButton?: boolean;
|
|
39
42
|
}
|
|
40
43
|
export declare const FloatingCard: React.FC<FloatingCardProps>;
|
|
41
44
|
export default FloatingCard;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { Card, BlockStack, InlineStack, Text, Badge, Button, Box, } from "@shopify/polaris";
|
|
3
4
|
import { XIcon } from "@shopify/polaris-icons";
|
|
4
|
-
export const FloatingCard = ({ data, onDismiss, onPrimaryAction, onSecondaryAction, }) => {
|
|
5
|
+
export const FloatingCard = ({ data, onDismiss, onPrimaryAction, onSecondaryAction, position = 'bottom-right', showCloseButton = true, }) => {
|
|
5
6
|
const handlePrimaryAction = () => {
|
|
6
7
|
if (data.primary_action) {
|
|
7
8
|
const url = data.primary_action.url;
|
|
@@ -40,7 +41,81 @@ export const FloatingCard = ({ data, onDismiss, onPrimaryAction, onSecondaryActi
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
// CSS-in-JS styles - no external CSS file needed
|
|
45
|
+
const floatingCardStyles = {
|
|
46
|
+
position: 'fixed',
|
|
47
|
+
zIndex: 9999,
|
|
48
|
+
width: '300px',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
alignItems: 'flex-start',
|
|
52
|
+
borderRadius: '8px',
|
|
53
|
+
boxShadow: '0 4px 26px 0 rgba(0, 0, 0, 0.10)',
|
|
54
|
+
overflow: 'hidden',
|
|
55
|
+
animation: 'slideInUp 0.3s ease-out',
|
|
56
|
+
...(position === 'bottom-right' && { bottom: '20px', right: '20px' }),
|
|
57
|
+
...(position === 'bottom-left' && { bottom: '20px', left: '20px' }),
|
|
58
|
+
...(position === 'top-right' && { top: '20px', right: '20px' }),
|
|
59
|
+
...(position === 'top-left' && { top: '20px', left: '20px' }),
|
|
60
|
+
};
|
|
61
|
+
const closeButtonStyles = {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
padding: '4px 2px',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
gap: '2px',
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
right: '7px',
|
|
69
|
+
top: '7px',
|
|
70
|
+
borderRadius: '8px',
|
|
71
|
+
background: 'rgba(255, 255, 255, 0.20)',
|
|
72
|
+
border: 'none',
|
|
73
|
+
cursor: 'pointer',
|
|
74
|
+
transition: 'background 0.2s ease',
|
|
75
|
+
zIndex: 10,
|
|
76
|
+
backdropFilter: 'blur(10px)',
|
|
77
|
+
WebkitBackdropFilter: 'blur(10px)',
|
|
78
|
+
};
|
|
79
|
+
const imageContainerStyles = {
|
|
80
|
+
position: 'relative',
|
|
81
|
+
height: '168.75px',
|
|
82
|
+
aspectRatio: '16/9',
|
|
83
|
+
width: '100%',
|
|
84
|
+
overflow: 'hidden',
|
|
85
|
+
borderRadius: '8px 8px 0 0',
|
|
86
|
+
backgroundColor: '#f5f5f5',
|
|
87
|
+
};
|
|
88
|
+
// Add keyframe animation dynamically
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
// Check if animation already exists
|
|
91
|
+
const styleId = 'floating-card-animations';
|
|
92
|
+
if (!document.getElementById(styleId)) {
|
|
93
|
+
const style = document.createElement('style');
|
|
94
|
+
style.id = styleId;
|
|
95
|
+
style.innerHTML = `
|
|
96
|
+
@keyframes slideInUp {
|
|
97
|
+
from {
|
|
98
|
+
transform: translateY(100%);
|
|
99
|
+
opacity: 0;
|
|
100
|
+
}
|
|
101
|
+
to {
|
|
102
|
+
transform: translateY(0);
|
|
103
|
+
opacity: 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
@keyframes fadeIn {
|
|
107
|
+
from { opacity: 0; }
|
|
108
|
+
to { opacity: 1; }
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
document.head.appendChild(style);
|
|
112
|
+
}
|
|
113
|
+
}, []);
|
|
114
|
+
return (_jsx("div", { style: floatingCardStyles, children: _jsxs(Card, { padding: "0", roundedAbove: "sm", children: [(showCloseButton && data.dismissible !== false) && (_jsx("button", { style: closeButtonStyles, onMouseEnter: (e) => {
|
|
115
|
+
e.currentTarget.style.background = 'rgba(255, 255, 255, 0.30)';
|
|
116
|
+
}, onMouseLeave: (e) => {
|
|
117
|
+
e.currentTarget.style.background = 'rgba(255, 255, 255, 0.20)';
|
|
118
|
+
}, onClick: onDismiss, "aria-label": "Close", children: _jsx(XIcon, { style: { width: '20px', height: '20px', color: 'rgba(255, 255, 255, 0.9)' } }) })), _jsxs(BlockStack, { gap: "0", children: [data.img_url && (_jsx("div", { style: imageContainerStyles, children: _jsx("img", { src: data.img_url, alt: data.image_alt || data.title, style: {
|
|
44
119
|
width: "100%",
|
|
45
120
|
height: "100%",
|
|
46
121
|
objectFit: "cover",
|