@dtdot/lego 0.16.0 → 0.16.4
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { motion, useMotionValue, useTransform } from 'framer-motion';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import useMeasure from 'react-use-measure';
|
|
4
5
|
import { responsive } from '../..';
|
|
5
6
|
import getThemeStatusColour from '../../theme/helpers/getThemeStatusColour';
|
|
6
7
|
import InlineCardContent from './_InlineCardContent.component';
|
|
@@ -77,18 +78,21 @@ const CardActionBackground = styled(motion.div) `
|
|
|
77
78
|
const InlineCard = ({ children, size, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }) => {
|
|
78
79
|
const theme = useTheme();
|
|
79
80
|
const x = useMotionValue(0);
|
|
80
|
-
const
|
|
81
|
+
const [ref, bounds] = useMeasure();
|
|
82
|
+
const xInput = [-50, 0];
|
|
81
83
|
const gestureLeftTheme = getThemeStatusColour(gestureLeftVariant || 'info', theme);
|
|
84
|
+
const [gestureLeftActivated, setGestureLeftActivated] = useState(false);
|
|
82
85
|
const opacity = useTransform(x, xInput, ['1', '0']);
|
|
83
86
|
const handleDragEnd = (e, panInfo) => {
|
|
84
87
|
// approx xInputMin * 3
|
|
85
88
|
if (panInfo.offset.x < -180 && onGestureLeft) {
|
|
89
|
+
setGestureLeftActivated(true);
|
|
86
90
|
onGestureLeft();
|
|
87
91
|
}
|
|
88
92
|
};
|
|
89
93
|
return (React.createElement(CardWrapper, { size: size },
|
|
90
94
|
React.createElement(CardActionBackground, { style: { opacity, backgroundColor: gestureLeftTheme.main } }, gestureLeftIcon && (React.createElement(FontAwesomeIcon, { style: { fontSize: '20px', color: gestureLeftTheme.contrast }, icon: gestureLeftIcon }))),
|
|
91
|
-
React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, style: { x }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick, onClick: onClick }, children)));
|
|
95
|
+
React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, ref: ref, style: { x }, animate: { x: gestureLeftActivated ? -bounds.width : undefined, opacity: gestureLeftActivated ? 0 : undefined }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick, onClick: onClick }, children)));
|
|
92
96
|
};
|
|
93
97
|
InlineCard.Media = InlineCardMedia;
|
|
94
98
|
InlineCard.Content = InlineCardContent;
|
|
@@ -51,7 +51,7 @@ const ModalWrapper = styled.div `
|
|
|
51
51
|
`)}
|
|
52
52
|
`;
|
|
53
53
|
const ModalOuter = styled(motion.div) `
|
|
54
|
-
background-color: ${(props) => props.theme.colours.
|
|
54
|
+
background-color: ${(props) => props.theme.colours.background};
|
|
55
55
|
border-radius: 4px;
|
|
56
56
|
margin: 16px 0 128px 0;
|
|
57
57
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { animated, useTransition } from 'react-spring';
|
|
5
4
|
import { Notification, Spacer } from '../..';
|
|
6
5
|
import responsive from '../../responsive/responsive';
|
|
7
6
|
import zIndexConstants from '../../constants/zIndex.constants';
|
|
7
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
8
8
|
const NotificationContainer = styled.div `
|
|
9
9
|
position: fixed;
|
|
10
10
|
bottom: 20px;
|
|
@@ -20,18 +20,9 @@ const NotificationContainer = styled.div `
|
|
|
20
20
|
`)}
|
|
21
21
|
`;
|
|
22
22
|
const Notifications = ({ notifications }) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
config: {
|
|
28
|
-
tension: 280,
|
|
29
|
-
mass: 0.2,
|
|
30
|
-
friction: 10,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
return (React.createElement(NotificationContainer, null, transitions.map(({ item, props, key }) => (React.createElement(animated.div, { key: key, style: props },
|
|
34
|
-
React.createElement(Spacer, { size: '1x' }),
|
|
35
|
-
React.createElement(Notification, { variant: item.variant, message: item.message, action: item.action, onAction: item.onAction, count: item.count }))))));
|
|
23
|
+
return (React.createElement(NotificationContainer, null,
|
|
24
|
+
React.createElement(AnimatePresence, null, notifications.map((notification) => (React.createElement(motion.div, { transition: { type: 'spring', duration: 0.4, bounce: 0 }, initial: { x: -300, opacity: 0 }, animate: { x: 0, opacity: 1 }, exit: { x: 300, opacity: 0 }, key: notification.id },
|
|
25
|
+
React.createElement(Spacer, { size: '1x' }),
|
|
26
|
+
React.createElement(Notification, { variant: notification.variant, message: notification.message, action: notification.action, onAction: notification.onAction, count: notification.count })))))));
|
|
36
27
|
};
|
|
37
28
|
export default Notifications;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dtdot/lego",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Some reusable components for building my applications",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"framer-motion": "^4.1.17",
|
|
60
60
|
"identicon.js": "^2.3.3",
|
|
61
61
|
"qrcode": "^1.4.4",
|
|
62
|
-
"react-
|
|
62
|
+
"react-use-measure": "^2.1.1",
|
|
63
63
|
"spark-md5": "^3.0.1"
|
|
64
64
|
}
|
|
65
65
|
}
|