@thecb/components 11.2.6 → 11.2.7-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "11.2.6",
3
+ "version": "11.2.7-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -100,12 +100,12 @@
100
100
  "@types/styled-components": "^5.1.34",
101
101
  "core-js": "^3.22.5",
102
102
  "formatted-input": "^1.0.0",
103
- "framer-motion": "^1.11.0",
103
+ "framer-motion": "12.4.7",
104
104
  "numeral": "^2.0.6",
105
105
  "polished": "^4.0.3",
106
106
  "ramda": "^0.27.0",
107
107
  "react-aria-modal": "^4.0.0",
108
- "react-pose": "^4.0.10",
109
108
  "redux-freeform": "6.2.1"
110
- }
109
+ },
110
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
111
111
  }
package/src/.DS_Store ADDED
Binary file
Binary file
Binary file
@@ -1,32 +1,14 @@
1
1
  import React, { useContext, forwardRef } from "react";
2
2
  import styled, { ThemeContext } from "styled-components";
3
- import posed from "react-pose";
4
- import { linear } from "@popmotion/easing";
5
3
  import Text from "../text";
6
- import { Box, Center } from "../layouts";
4
+ import { Box, Center, Motion } from "../layouts";
7
5
  import { fallbackValues } from "./ButtonWithAction.theme";
8
6
 
9
7
  import SpinnerIcon from "../../../deprecated/spinner";
10
8
  import { noop } from "../../../util/general";
11
9
  import { createThemeValues } from "../../../util/themeUtils";
12
10
 
13
- const rotate = posed.div({
14
- fixed: {
15
- rotate: "0deg"
16
- },
17
- rotate: {
18
- rotate: "360deg",
19
- transition: {
20
- rotate: {
21
- ease: linear,
22
- duration: 1000,
23
- loop: Infinity
24
- }
25
- }
26
- }
27
- });
28
-
29
- const SpinnerContainer = styled.div`
11
+ const SpinnerContainer = styled(Motion)`
30
12
  width: 100%;
31
13
  display: flex;
32
14
  flex-direction: row;
@@ -34,13 +16,9 @@ const SpinnerContainer = styled.div`
34
16
  justify-content: center;
35
17
  `;
36
18
 
37
- const SpinnerIconWrapper = styled(rotate)``;
38
-
39
19
  const Spinner = ({ color, isMobile }) => (
40
20
  <SpinnerContainer>
41
- <SpinnerIconWrapper initialPose="fixed" pose="rotate">
42
- <SpinnerIcon color={color} isMobile={isMobile} />
43
- </SpinnerIconWrapper>
21
+ <SpinnerIcon color={color} isMobile={isMobile} />
44
22
  </SpinnerContainer>
45
23
  );
46
24
 
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment, forwardRef } from "react";
2
- import { MotionWrapper } from "./Motion.styled";
2
+ import { MotionWrapper, MotionSpanWrapper } from "./Motion.styled";
3
3
  import { safeChildren } from "../../../util/general";
4
4
 
5
5
  /*
@@ -38,11 +38,30 @@ import { safeChildren } from "../../../util/general";
38
38
  */
39
39
 
40
40
  export const Motion = forwardRef(
41
- ({ position = "relative", padding = "0", children, ...rest }, ref) => (
42
- <MotionWrapper position={position} padding={padding} ref={ref} {...rest}>
43
- {safeChildren(children, <Fragment />)}
44
- </MotionWrapper>
45
- )
41
+ (
42
+ {
43
+ position = "relative",
44
+ padding = "0",
45
+ children,
46
+ useSpan = false,
47
+ ...rest
48
+ },
49
+ ref
50
+ ) =>
51
+ useSpan ? (
52
+ <MotionSpanWrapper
53
+ position={position}
54
+ padding={padding}
55
+ ref={ref}
56
+ {...rest}
57
+ >
58
+ {safeChildren(children, <Fragment />)}
59
+ </MotionSpanWrapper>
60
+ ) : (
61
+ <MotionWrapper position={position} padding={padding} ref={ref} {...rest}>
62
+ {safeChildren(children, <Fragment />)}
63
+ </MotionWrapper>
64
+ )
46
65
  );
47
66
 
48
67
  export default Motion;
@@ -36,3 +36,39 @@ export const MotionWrapper = styled(motion.div)`
36
36
 
37
37
  ${({ extraStyles }) => extraStyles};
38
38
  `;
39
+
40
+ export const MotionSpanWrapper = styled(motion.span)`
41
+ position: ${({ position }) => position};
42
+ display: ${({ display }) => display};
43
+ box-sizing: border-box;
44
+ padding: ${({ padding }) => padding};
45
+ border: ${({ borderShorthand }) => borderShorthand};
46
+ border-color: ${({ borderColor }) => borderColor};
47
+ border-size: ${({ borderSize }) => borderSize};
48
+ border-style: ${({ borderStyle }) => borderStyle};
49
+ border-width: ${({ borderWidth }) => borderWidth};
50
+ border-radius: ${({ borderRadius }) => borderRadius};
51
+ background-color: ${({ backgroundColor }) => backgroundColor};
52
+ box-shadow: ${({ boxShadow }) => boxShadow};
53
+ min-height: ${({ minHeight }) => minHeight};
54
+ min-width: ${({ minWidth }) => minWidth};
55
+ height: ${({ height }) => height};
56
+ width: ${({ width }) => width};
57
+ text-align: ${({ textAlign }) => textAlign};
58
+ margin: ${({ margin }) => margin};
59
+
60
+ &:hover,
61
+ &:focus {
62
+ ${({ hoverStyles }) => hoverStyles};
63
+ }
64
+
65
+ &:active {
66
+ ${({ activeStyles }) => activeStyles};
67
+ }
68
+
69
+ &:disabled {
70
+ ${({ disabledStyles }) => disabledStyles};
71
+ }
72
+
73
+ ${({ extraStyles }) => extraStyles};
74
+ `;
@@ -1,9 +1,8 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
- import posed from "react-pose";
4
3
  import { fallbackValues } from "./ToggleSwitch.theme";
5
4
  import { themeComponent } from "../../../util/themeUtils";
6
- import { Box, Center, Cover, Cluster } from "../layouts";
5
+ import { Box, Center, Cover, Cluster, Motion } from "../layouts";
7
6
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
8
7
  import { CHARADE_GREY } from "../../../constants/colors";
9
8
  import { ENTER } from "../../../constants/keyboard";
@@ -18,7 +17,7 @@ const HiddenToggleSwitchBox = styled.input`
18
17
  width: ${({ isMobile }) => (isMobile ? `40px` : `44px`)};
19
18
  `;
20
19
 
21
- const VisibleSwitchComponent = styled.span`
20
+ const VisibleSwitchComponent = styled(Motion)`
22
21
  width: ${({ isMobile }) => (isMobile ? `40px` : `44px`)};
23
22
  height: ${({ isMobile }) => (isMobile ? `22px` : `24px`)};
24
23
  border-radius: 12px;
@@ -38,7 +37,7 @@ const VisibleSwitchComponent = styled.span`
38
37
  }
39
38
  `;
40
39
 
41
- const ToggleSwitchRingComponent = styled.span`
40
+ const ToggleSwitchRingComponent = styled(Motion)`
42
41
  position: absolute;
43
42
  width: ${({ isMobile }) => (isMobile ? `14px` : `16px`)};
44
43
  height: ${({ isMobile }) => (isMobile ? `14px` : `16px`)};
@@ -64,7 +63,7 @@ const ToggleSwitch = ({
64
63
  extraStyles = ""
65
64
  }) => {
66
65
  const nameId = name.replace(/ /g, "-");
67
- const ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
66
+ const toggleSwitchRingVariants = {
68
67
  off: {
69
68
  backgroundColor: disabled
70
69
  ? themeValues.disabledBackground
@@ -87,12 +86,9 @@ const ToggleSwitch = ({
87
86
  ease: "backIn"
88
87
  }
89
88
  }
90
- });
89
+ };
91
90
 
92
- const VisibleSwitch = posed(VisibleSwitchComponent)({
93
- focusable: true,
94
- hoverable: true,
95
- pressable: true,
91
+ const visibleSwitchVariants = {
96
92
  focus: {
97
93
  outline: "0px ridge rgba(170, 50, 220, 0)",
98
94
  boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
@@ -124,7 +120,7 @@ const ToggleSwitch = ({
124
120
  ease: "easeIn"
125
121
  }
126
122
  }
127
- });
123
+ };
128
124
 
129
125
  const handleKeyDown = e => {
130
126
  if (e.keyCode === ENTER) {
@@ -168,17 +164,25 @@ const ToggleSwitch = ({
168
164
  id={`#${nameId}`}
169
165
  isMobile={isMobile}
170
166
  />
171
- <VisibleSwitch
167
+ <VisibleSwitchComponent
172
168
  onClick={disabled ? noop : onToggle}
173
169
  onKeyDown={disabled ? noop : handleKeyDown}
174
- pose={isOn ? "on" : "off"}
170
+ initial={isOn ? "on" : "off"}
171
+ animate={isOn ? "on" : "off"}
172
+ variants={visibleSwitchVariants}
173
+ whileFocus="focus"
174
+ whileHover="hover"
175
175
  tabIndex={disabled ? -1 : 0}
176
176
  disabled={disabled}
177
177
  isMobile={isMobile}
178
+ useSpan
178
179
  tabindex="0"
179
180
  >
180
- <ToggleSwitchRing isMobile={isMobile} />
181
- </VisibleSwitch>
181
+ <ToggleSwitchRingComponent
182
+ variants={toggleSwitchRingVariants}
183
+ isMobile={isMobile}
184
+ />
185
+ </VisibleSwitchComponent>
182
186
  </Box>
183
187
  </Cover>
184
188
  {label && (
@@ -1,22 +1,20 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
- import posed from "react-pose";
4
- import { easeIn, easeOut } from "@popmotion/easing";
5
- import { Box } from "../../atoms/layouts";
3
+ import { Box, Motion } from "../../atoms/layouts";
6
4
  import { fallbackValues } from "./NavMenu.theme.js";
7
5
  import { themeComponent } from "../../../util/themeUtils";
8
6
 
9
- const menu = posed.div({
7
+ const menuVariants = {
10
8
  invisible: {
11
9
  left: "-100vw",
12
10
  right: "100vw",
13
11
  transition: {
14
12
  right: {
15
- ease: easeOut,
13
+ ease: "easeOut",
16
14
  duration: 500
17
15
  },
18
16
  left: {
19
- ease: easeOut,
17
+ ease: "easeOut",
20
18
  duration: 500
21
19
  }
22
20
  }
@@ -26,18 +24,18 @@ const menu = posed.div({
26
24
  right: "0",
27
25
  transition: {
28
26
  left: {
29
- ease: easeIn,
27
+ ease: "easeIn",
30
28
  duration: 500
31
29
  },
32
30
  right: {
33
- ease: easeIn,
31
+ ease: "easeIn",
34
32
  duration: 500
35
33
  }
36
34
  }
37
35
  }
38
- });
36
+ };
39
37
 
40
- const ImposterMenu = styled(menu)`
38
+ const ImposterMenu = styled(Motion)`
41
39
  position: fixed;
42
40
  top: ${({ headerSize }) => headerSize};
43
41
  `;
@@ -52,8 +50,9 @@ const NavMenuMobile = ({
52
50
  return (
53
51
  <ImposterMenu
54
52
  id={id}
55
- initialPose="invisible"
56
- pose={visible ? "visible" : "invisible"}
53
+ variants={menuVariants}
54
+ initial="invisible"
55
+ animate={visible ? "visible" : "invisible"}
57
56
  headerSize={headerSize}
58
57
  >
59
58
  <Box
@@ -1,23 +1,6 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
- import posed from "react-pose";
4
- import { linear } from "@popmotion/easing";
5
-
6
- const rotate = posed.div({
7
- fixed: {
8
- rotate: "0deg"
9
- },
10
- rotate: {
11
- rotate: "360deg",
12
- transition: {
13
- rotate: {
14
- ease: linear,
15
- duration: 1000,
16
- loop: Infinity
17
- }
18
- }
19
- }
20
- });
3
+ import { Motion } from "../../components/atoms/layouts";
21
4
 
22
5
  export const SpinnerContainer = styled.div`
23
6
  width: 100%;
@@ -27,14 +10,19 @@ export const SpinnerContainer = styled.div`
27
10
  justify-content: center;
28
11
  `;
29
12
 
30
- export const SpinnerIconWrapper = styled(rotate)`
13
+ export const SpinnerIconWrapper = styled(Motion)`
31
14
  width: ${({ isMobile }) => (isMobile ? "18" : "21")}px;
32
15
  height: ${({ isMobile }) => (isMobile ? "18" : "21")}px;
33
16
  `;
34
17
 
35
18
  const SpinnerIcon = ({ color, isMobile }) => (
36
19
  <SpinnerContainer>
37
- <SpinnerIconWrapper initialPose="fixed" pose="rotate" isMobile={isMobile}>
20
+ <SpinnerIconWrapper
21
+ initial={{ rotate: 0 }}
22
+ animate={{ rotate: 360 }}
23
+ transition={{ duration: 1, ease: "linear", repeat: Infinity }}
24
+ isMobile={isMobile}
25
+ >
38
26
  <svg
39
27
  viewBox={`0 0 24 24`}
40
28
  height="100%"