@thecb/components 11.2.7-beta.0 → 11.2.8-beta.0

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.7-beta.0",
3
+ "version": "11.2.8-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -105,7 +105,7 @@
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",
108
109
  "redux-freeform": "6.2.1"
109
- },
110
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
110
+ }
111
111
  }
@@ -1,15 +1,16 @@
1
1
  import React, { useContext, forwardRef } from "react";
2
2
  import styled, { ThemeContext } from "styled-components";
3
+ import posed from "react-pose";
3
4
  import { linear } from "@popmotion/easing";
4
5
  import Text from "../text";
5
- import { Box, Center, Motion } from "../layouts";
6
+ import { Box, Center } from "../layouts";
6
7
  import { fallbackValues } from "./ButtonWithAction.theme";
7
8
 
8
9
  import SpinnerIcon from "../../../deprecated/spinner";
9
10
  import { noop } from "../../../util/general";
10
11
  import { createThemeValues } from "../../../util/themeUtils";
11
12
 
12
- const variants = {
13
+ const rotate = posed.div({
13
14
  fixed: {
14
15
  rotate: "0deg"
15
16
  },
@@ -23,7 +24,7 @@ const variants = {
23
24
  }
24
25
  }
25
26
  }
26
- };
27
+ });
27
28
 
28
29
  const SpinnerContainer = styled.div`
29
30
  width: 100%;
@@ -33,16 +34,11 @@ const SpinnerContainer = styled.div`
33
34
  justify-content: center;
34
35
  `;
35
36
 
36
- const SpinnerIconWrapper = styled(Motion)``;
37
+ const SpinnerIconWrapper = styled(rotate)``;
37
38
 
38
39
  const Spinner = ({ color, isMobile }) => (
39
40
  <SpinnerContainer>
40
- <SpinnerIconWrapper
41
- padding="0"
42
- variants={variants}
43
- initial="fixed"
44
- animate="rotate"
45
- >
41
+ <SpinnerIconWrapper initialPose="fixed" pose="rotate">
46
42
  <SpinnerIcon color={color} isMobile={isMobile} />
47
43
  </SpinnerIconWrapper>
48
44
  </SpinnerContainer>
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment, forwardRef } from "react";
2
- import { MotionWrapper, MotionSpanWrapper } from "./Motion.styled";
2
+ import { MotionWrapper } from "./Motion.styled";
3
3
  import { safeChildren } from "../../../util/general";
4
4
 
5
5
  /*
@@ -38,30 +38,11 @@ import { safeChildren } from "../../../util/general";
38
38
  */
39
39
 
40
40
  export const Motion = forwardRef(
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
- )
41
+ ({ position = "relative", padding = "0", children, ...rest }, ref) => (
42
+ <MotionWrapper position={position} padding={padding} ref={ref} {...rest}>
43
+ {safeChildren(children, <Fragment />)}
44
+ </MotionWrapper>
45
+ )
65
46
  );
66
47
 
67
48
  export default Motion;
@@ -36,39 +36,3 @@ 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,8 +1,9 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
+ import posed from "react-pose";
3
4
  import { fallbackValues } from "./ToggleSwitch.theme";
4
5
  import { themeComponent } from "../../../util/themeUtils";
5
- import { Box, Center, Cover, Cluster, Motion } from "../layouts";
6
+ import { Box, Center, Cover, Cluster } from "../layouts";
6
7
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
7
8
  import { CHARADE_GREY } from "../../../constants/colors";
8
9
  import { ENTER } from "../../../constants/keyboard";
@@ -17,7 +18,7 @@ const HiddenToggleSwitchBox = styled.input`
17
18
  width: ${({ isMobile }) => (isMobile ? `40px` : `44px`)};
18
19
  `;
19
20
 
20
- const VisibleSwitchComponent = styled(Motion)`
21
+ const VisibleSwitchComponent = styled.span`
21
22
  width: ${({ isMobile }) => (isMobile ? `40px` : `44px`)};
22
23
  height: ${({ isMobile }) => (isMobile ? `22px` : `24px`)};
23
24
  border-radius: 12px;
@@ -37,7 +38,7 @@ const VisibleSwitchComponent = styled(Motion)`
37
38
  }
38
39
  `;
39
40
 
40
- const ToggleSwitchRingComponent = styled(Motion)`
41
+ const ToggleSwitchRingComponent = styled.span`
41
42
  position: absolute;
42
43
  width: ${({ isMobile }) => (isMobile ? `14px` : `16px`)};
43
44
  height: ${({ isMobile }) => (isMobile ? `14px` : `16px`)};
@@ -63,7 +64,7 @@ const ToggleSwitch = ({
63
64
  extraStyles = ""
64
65
  }) => {
65
66
  const nameId = name.replace(/ /g, "-");
66
- const toggleSwitchRingVariants = {
67
+ const ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
67
68
  off: {
68
69
  backgroundColor: disabled
69
70
  ? themeValues.disabledBackground
@@ -86,9 +87,12 @@ const ToggleSwitch = ({
86
87
  ease: "backIn"
87
88
  }
88
89
  }
89
- };
90
+ });
90
91
 
91
- const visibleSwitchVariants = {
92
+ const VisibleSwitch = posed(VisibleSwitchComponent)({
93
+ focusable: true,
94
+ hoverable: true,
95
+ pressable: true,
92
96
  focus: {
93
97
  outline: "0px ridge rgba(170, 50, 220, 0)",
94
98
  boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
@@ -120,7 +124,7 @@ const ToggleSwitch = ({
120
124
  ease: "easeIn"
121
125
  }
122
126
  }
123
- };
127
+ });
124
128
 
125
129
  const handleKeyDown = e => {
126
130
  if (e.keyCode === ENTER) {
@@ -164,25 +168,17 @@ const ToggleSwitch = ({
164
168
  id={`#${nameId}`}
165
169
  isMobile={isMobile}
166
170
  />
167
- <VisibleSwitchComponent
171
+ <VisibleSwitch
168
172
  onClick={disabled ? noop : onToggle}
169
173
  onKeyDown={disabled ? noop : handleKeyDown}
170
- initial={isOn ? "on" : "off"}
171
- animate={isOn ? "on" : "off"}
172
- variants={visibleSwitchVariants}
173
- whileFocus="focus"
174
- whileHover="hover"
174
+ pose={isOn ? "on" : "off"}
175
175
  tabIndex={disabled ? -1 : 0}
176
176
  disabled={disabled}
177
177
  isMobile={isMobile}
178
- useSpan
179
178
  tabindex="0"
180
179
  >
181
- <ToggleSwitchRingComponent
182
- variants={toggleSwitchRingVariants}
183
- isMobile={isMobile}
184
- />
185
- </VisibleSwitchComponent>
180
+ <ToggleSwitchRing isMobile={isMobile} />
181
+ </VisibleSwitch>
186
182
  </Box>
187
183
  </Cover>
188
184
  {label && (
@@ -2,7 +2,6 @@ import React, { useContext } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import { Box, Center, Stack } from "../../atoms/layouts";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
- import Paragraph from "../../atoms/paragraph";
6
5
  import Title from "../../atoms/title";
7
6
  import { fallbackValues } from "./HeroImage.theme";
8
7
  import withWindowSize from "../../withWindowSize";
@@ -28,35 +27,42 @@ const HeroImage = ({
28
27
  extraStyles
29
28
  }) => {
30
29
  const { isMobile } = useContext(ThemeContext);
31
- const heroImageVariantStyles = Styled.getHeroImageVariantStyles({
30
+ const gradientStyles = Styled.getHeroGradientStyles({
32
31
  variant,
33
- imageUrl,
34
32
  isMobile,
35
- heroPrimaryColor: themeValues.heroPrimaryColor
33
+ heroPrimaryColor: themeValues.heroPrimaryColor,
34
+ heroSecondaryColor: themeValues.heroSecondaryColor
36
35
  });
37
36
 
38
37
  return (
39
- <>
40
- <Styled.HeroImageContainer
41
- minWidth={minWidth}
42
- minHeight={minHeight}
43
- padding={isMobile ? "2rem" : "3rem 2rem"}
44
- extraStyles={`${heroImageVariantStyles} ${extraStyles}`}
38
+ <Box
39
+ minWidth={minWidth}
40
+ minHeight={minHeight}
41
+ padding={isMobile ? "2rem" : "3rem 2rem"}
42
+ extraStyles={`
43
+ display: flex;
44
+ background: ${gradientStyles},
45
+ url(${imageUrl}) center / cover no-repeat, ${themeValues.heroPrimaryColor};
46
+ ${extraStyles}
47
+ `}
48
+ >
49
+ <Center
50
+ maxWidth={contentMaxWidth}
51
+ width={"100%"}
52
+ intrinsic
53
+ extraStyles={`
54
+ flex-flow: unset;
55
+ justify-content: ${variant === "v2" ? "center" : "flex-start"};
56
+ flex-wrap: nowrap;
57
+ `}
45
58
  >
46
- <Center
47
- maxWidth={contentMaxWidth}
48
- width={"100%"}
49
- intrinsic
50
- extraStyles={`
51
- flex-flow: unset;
52
- justify-content: flex-start;
53
- flex-wrap: nowrap;
54
- `}
59
+ <Stack
60
+ childGap={contentSpacing}
61
+ extraStyles={`max-width: ${
62
+ isMobile || variant === "v2" ? "100%" : "50%"
63
+ };`}
55
64
  >
56
- <Stack
57
- childGap={contentSpacing}
58
- extraStyles={`max-width: ${isMobile ? "100%" : "50%"};`}
59
- >
65
+ {variant === "v1" ? (
60
66
  <Stack childGap="0">
61
67
  {heading && (
62
68
  <Title
@@ -82,22 +88,37 @@ const HeroImage = ({
82
88
  </Title>
83
89
  )}
84
90
  </Stack>
85
- {description && (
86
- <Box padding="0">
87
- <Paragraph
91
+ ) : (
92
+ <>
93
+ {heading && (
94
+ <Title
95
+ variant="hero"
96
+ as={headingVariant}
97
+ weight={FONT_WEIGHT_BOLD}
88
98
  color={themeValues.heroTextColor}
89
- extraStyles={`line-height: 150%; ${
90
- !isMobile ? "font-size: 1.25rem;" : ""
91
- }`}
99
+ extraStyles={`text-align: center; line-height: ${
100
+ isMobile ? "125%" : "115%"
101
+ };`}
92
102
  >
93
- {description}
94
- </Paragraph>
95
- </Box>
96
- )}
97
- </Stack>
98
- </Center>
99
- </Styled.HeroImageContainer>
100
- </>
103
+ {heading}
104
+ </Title>
105
+ )}
106
+ </>
107
+ )}
108
+ {description && (
109
+ <Box padding="0">
110
+ <Styled.HeroDescription
111
+ color={themeValues.heroTextColor}
112
+ isMobile={isMobile}
113
+ variant={variant}
114
+ >
115
+ {description}
116
+ </Styled.HeroDescription>
117
+ </Box>
118
+ )}
119
+ </Stack>
120
+ </Center>
121
+ </Box>
101
122
  );
102
123
  };
103
124
 
@@ -118,7 +118,7 @@ export const DesktopV1 = {
118
118
  }
119
119
  };
120
120
 
121
- export const NoImage = {
121
+ export const NoImageV1 = {
122
122
  args: {
123
123
  variant: "v1",
124
124
  minWidth: "1000px",
@@ -126,3 +126,24 @@ export const NoImage = {
126
126
  imageUrl: undefined
127
127
  }
128
128
  };
129
+
130
+ export const DesktopV2 = {
131
+ args: {
132
+ heading: "Cityville Payment Center",
133
+ variant: "v2",
134
+ minWidth: "1000px",
135
+ minHeight: "274px",
136
+ imageUrl:
137
+ "https://cb-public-assets.s3-us-west-2.amazonaws.com/cityville/hero.jpg"
138
+ }
139
+ };
140
+
141
+ export const NoImageV2 = {
142
+ args: {
143
+ heading: "Cityville Payment Center",
144
+ variant: "v2",
145
+ minWidth: "1000px",
146
+ minHeight: "274px",
147
+ imageUrl: undefined
148
+ }
149
+ };
@@ -1,30 +1,41 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
- import { Box } from "../../atoms";
3
+ import { Paragraph } from "../../atoms";
3
4
  import { rgba } from "polished";
4
5
 
5
- export const getHeroImageVariantStyles = ({
6
+ export const getHeroGradientStyles = ({
6
7
  variant,
7
- imageUrl,
8
8
  isMobile,
9
- heroPrimaryColor
9
+ heroPrimaryColor,
10
+ heroSecondaryColor
10
11
  }) => {
11
- return `
12
- background: ${
13
- !isMobile
14
- ? `linear-gradient(
15
- 90deg,
16
- ${heroPrimaryColor} 33%,
17
- transparent 100%
18
- )`
19
- : `linear-gradient(
20
- ${rgba(heroPrimaryColor, 0.8)},
21
- ${rgba(heroPrimaryColor, 0.8)}
22
- )`
23
- },
24
- url(${imageUrl}) center / cover no-repeat, ${heroPrimaryColor};
25
- `;
12
+ const v1Gradient = `linear-gradient(
13
+ 90deg,
14
+ ${heroPrimaryColor} 33%,
15
+ transparent 100%
16
+ )`;
17
+ const v1GradientMobile = `linear-gradient(
18
+ ${rgba(heroPrimaryColor, 0.8)},
19
+ ${rgba(heroPrimaryColor, 0.8)}
20
+ )`;
21
+ const v2Gradient = `linear-gradient(
22
+ 90deg,
23
+ ${rgba(heroPrimaryColor, 0.8)} 0%,
24
+ ${rgba(heroSecondaryColor, 0.8)} 100%
25
+ )`;
26
+
27
+ return {
28
+ v1: isMobile ? v1GradientMobile : v1Gradient,
29
+ v2: v2Gradient
30
+ }[variant];
26
31
  };
27
32
 
28
- export const HeroImageContainer = styled(Box)`
29
- display: flex;
33
+ export const HeroDescription = styled(({ variant, isMobile, ...props }) => (
34
+ <Paragraph {...props} />
35
+ ))`
36
+ line-height: 150%;
37
+ font-size: ${({ isMobile }) => (!isMobile ? "1.25rem" : "inherit")};
38
+ text-align: ${({ variant }) => (variant === "v2" ? "center" : "inherit")};
39
+ font-size: ${({ variant, isMobile }) =>
40
+ variant === "v2" ? (isMobile ? "1.125rem" : "1.25rem") : "inherit"};
30
41
  `;
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
+ import posed from "react-pose";
3
4
  import { easeIn, easeOut } from "@popmotion/easing";
4
- import { Box, Motion } from "../../atoms/layouts";
5
+ import { Box } from "../../atoms/layouts";
5
6
  import { fallbackValues } from "./NavMenu.theme.js";
6
7
  import { themeComponent } from "../../../util/themeUtils";
7
8
 
8
- const menuVariants = {
9
+ const menu = posed.div({
9
10
  invisible: {
10
11
  left: "-100vw",
11
12
  right: "100vw",
@@ -34,9 +35,9 @@ const menuVariants = {
34
35
  }
35
36
  }
36
37
  }
37
- };
38
+ });
38
39
 
39
- const ImposterMenu = styled(Motion)`
40
+ const ImposterMenu = styled(menu)`
40
41
  position: fixed;
41
42
  top: ${({ headerSize }) => headerSize};
42
43
  `;
@@ -51,9 +52,8 @@ const NavMenuMobile = ({
51
52
  return (
52
53
  <ImposterMenu
53
54
  id={id}
54
- variants={menuVariants}
55
- initial="invisible"
56
- animate={visible ? "visible" : "invisible"}
55
+ initialPose="invisible"
56
+ pose={visible ? "visible" : "invisible"}
57
57
  headerSize={headerSize}
58
58
  >
59
59
  <Box
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import styled from "styled-components";
3
- import { Motion } from "../../components/atoms/layouts";
3
+ import posed from "react-pose";
4
4
  import { linear } from "@popmotion/easing";
5
5
 
6
- const rotateVariants = {
6
+ const rotate = posed.div({
7
7
  fixed: {
8
8
  rotate: "0deg"
9
9
  },
@@ -17,7 +17,7 @@ const rotateVariants = {
17
17
  }
18
18
  }
19
19
  }
20
- };
20
+ });
21
21
 
22
22
  export const SpinnerContainer = styled.div`
23
23
  width: 100%;
@@ -27,19 +27,14 @@ export const SpinnerContainer = styled.div`
27
27
  justify-content: center;
28
28
  `;
29
29
 
30
- export const SpinnerIconWrapper = styled(Motion)`
30
+ export const SpinnerIconWrapper = styled(rotate)`
31
31
  width: ${({ isMobile }) => (isMobile ? "18" : "21")}px;
32
32
  height: ${({ isMobile }) => (isMobile ? "18" : "21")}px;
33
33
  `;
34
34
 
35
35
  const SpinnerIcon = ({ color, isMobile }) => (
36
36
  <SpinnerContainer>
37
- <SpinnerIconWrapper
38
- initial="fixed"
39
- animate="rotate"
40
- isMobile={isMobile}
41
- variants={rotateVariants}
42
- >
37
+ <SpinnerIconWrapper initialPose="fixed" pose="rotate" isMobile={isMobile}>
43
38
  <svg
44
39
  viewBox={`0 0 24 24`}
45
40
  height="100%"
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file