@thecb/components 5.7.0-beta.5 → 5.8.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.
Files changed (33) hide show
  1. package/dist/index.cjs.js +9200 -10431
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +9198 -10430
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +6 -2
  6. package/src/components/atoms/amount-callout/AmountCallout.js +6 -12
  7. package/src/components/atoms/amount-callout/AmountCallout.stories.js +0 -10
  8. package/src/components/atoms/amount-callout/AmountCallout.theme.js +1 -15
  9. package/src/components/atoms/detail/Detail.theme.js +10 -8
  10. package/src/components/atoms/dropdown/Dropdown.js +8 -4
  11. package/src/components/atoms/form-layouts/FormInput.js +8 -8
  12. package/src/components/atoms/form-select/FormSelect.js +3 -1
  13. package/src/components/atoms/heading/Heading.js +2 -2
  14. package/src/components/atoms/layouts/Box.js +8 -2
  15. package/src/components/atoms/layouts/Cluster.js +4 -4
  16. package/src/components/atoms/layouts/Cluster.styled.js +4 -4
  17. package/src/components/atoms/nav-footer/NavFooter.stories.js +1 -1
  18. package/src/components/atoms/paragraph/Paragraph.js +2 -2
  19. package/src/components/atoms/paragraph/Paragraph.theme.js +8 -6
  20. package/src/components/atoms/text/Text.theme.js +8 -6
  21. package/src/components/atoms/title/Title.theme.js +6 -4
  22. package/src/components/molecules/index.js +1 -0
  23. package/src/components/molecules/obligation/Obligation.js +88 -5
  24. package/src/components/molecules/obligation/modules/InactiveControlsModule.js +61 -0
  25. package/src/components/molecules/obligation/modules/InactiveTitleModule.js +41 -0
  26. package/src/components/molecules/obligation/modules/TitleModule.js +14 -8
  27. package/src/components/molecules/obligation/modules/index.js +10 -1
  28. package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashBoardIframe.stories.js +22 -0
  29. package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashboardIframe.js +124 -0
  30. package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashboardIframe.styled.js +9 -0
  31. package/src/components/molecules/periscope-dashboard-iframe/index.js +3 -0
  32. package/src/components/molecules/tabs/Tabs.js +3 -3
  33. package/src/util/general.js +17 -0
@@ -1,23 +1,29 @@
1
1
  import React from "react";
2
2
  import { Box, Stack } from "../../../atoms/layouts";
3
- import Heading from "../../../atoms/heading";
4
- import Text from "../../../atoms/text";
3
+ import Title from "../../../atoms/title";
4
+ import Detail from "../../../atoms/detail";
5
5
  import { FONT_WEIGHT_SEMIBOLD } from "../../../../constants/style_constants";
6
6
 
7
7
  const TitleModule = ({ title, subtitle, titleColor, subtitleColor }) => (
8
8
  <Box padding="0">
9
9
  <Stack childGap="0">
10
- <Heading
11
- variant="h6"
10
+ <Title
11
+ variant="small"
12
12
  weight={FONT_WEIGHT_SEMIBOLD}
13
13
  color={titleColor}
14
- as="h2"
14
+ as="h4"
15
+ id="obligation-title"
15
16
  >
16
17
  {title}
17
- </Heading>
18
- <Text variant="pS" color={subtitleColor}>
18
+ </Title>
19
+ <Detail
20
+ variant="small"
21
+ color={subtitleColor}
22
+ as="h5"
23
+ id="obligation-subtitle"
24
+ >
19
25
  {subtitle}
20
- </Text>
26
+ </Detail>
21
27
  </Stack>
22
28
  </Box>
23
29
  );
@@ -2,5 +2,14 @@ import IconModule from "./IconModule";
2
2
  import TitleModule from "./TitleModule";
3
3
  import AmountModule from "./AmountModule";
4
4
  import PaymentDetailsActions from "./PaymentDetailsActions";
5
+ import InactiveControlsModule from "./InactiveControlsModule";
6
+ import InactiveTitleModule from "./InactiveTitleModule";
5
7
 
6
- export { IconModule, TitleModule, AmountModule, PaymentDetailsActions };
8
+ export {
9
+ IconModule,
10
+ TitleModule,
11
+ AmountModule,
12
+ PaymentDetailsActions,
13
+ InactiveControlsModule,
14
+ InactiveTitleModule
15
+ };
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import PeriscopeDashboardIframe from "./PeriscopeDashboardIframe";
3
+ import page from "../../../../.storybook/page";
4
+ import { boolean } from "@storybook/addon-knobs";
5
+
6
+ export const periscopeDashboardIframe = () => (
7
+ <PeriscopeDashboardIframe
8
+ url={"www.example.com"}
9
+ requestDashboardUrl={() => {}}
10
+ periscopeDataPending={boolean("dataPending", true)}
11
+ periscopeDataSuccess={boolean("dataSuccess", false)}
12
+ periscopeDataFailure={boolean("dataFailure", false)}
13
+ periscopeDataRequestSuccess={boolean("requestSuccess", false)}
14
+ periscopeDataRequestFailure={boolean("requestFailure", false)}
15
+ />
16
+ );
17
+
18
+ const story = page({
19
+ title: "Components|Molecules/PeriscopeDashboardIframe",
20
+ Component: PeriscopeDashboardIframe
21
+ });
22
+ export default story;
@@ -0,0 +1,124 @@
1
+ import React, { useLayoutEffect, useState, useEffect, Fragment } from "react";
2
+ import {
3
+ BoxWithShadow,
4
+ Center,
5
+ Box,
6
+ PeriscopeFailedIcon,
7
+ Heading,
8
+ Paragraph,
9
+ Cover,
10
+ Spinner
11
+ } from "../../atoms";
12
+ import { DashboardIframe } from "./PeriscopeDashboardIframe.styled";
13
+
14
+ /**
15
+ * Component: PeriscopeDashboardIframe
16
+ *
17
+ * Used for rendering Citybase's periscope reporting dashboards in iframes.
18
+ * Receives action props to trigger a request on mount for the iframe's url.
19
+ * Receives a string prop if/when we receive the url result.
20
+ * And receives action props to emit errors from failed iframe loading.
21
+ *
22
+ * The logic and api client methods to handle requests/response,
23
+ * store the url, etc. should be provided from the app consuming this library.
24
+ *
25
+ * If the url request is pending, render a spinner.
26
+ * If the url request failed, render a UI error state.
27
+ **/
28
+
29
+ const DASHBOARD_SIZE_MESSAGE_TYPE = "dashboard_resize";
30
+ const PERISCOPE_ORIGIN = "https://app.periscopedata.com";
31
+ const isValidMessage = message =>
32
+ message.isTrusted &&
33
+ message.origin === PERISCOPE_ORIGIN &&
34
+ message.data &&
35
+ message.data.event_type === DASHBOARD_SIZE_MESSAGE_TYPE;
36
+
37
+ const PeriscopeDashboardIframe = ({
38
+ url,
39
+ requestDashboardUrl,
40
+ periscopeDataPending,
41
+ periscopeDataSuccess,
42
+ periscopeDataFailure,
43
+ periscopeDataRequestSuccess,
44
+ periscopeDataRequestFailure
45
+ }) => {
46
+ const [height, setHeight] = useState(0);
47
+ let time = { timer: null };
48
+
49
+ useEffect(() => {
50
+ time.timer = setTimeout(() => {
51
+ periscopeDataRequestFailure();
52
+ }, 10000);
53
+ }, []);
54
+
55
+ const Dashboard = height => url => (
56
+ <DashboardIframe
57
+ src={url}
58
+ width="100%"
59
+ height={height}
60
+ data-qa="DashboardIframe"
61
+ onLoad={() => {
62
+ let iframe = document.querySelector("iframe");
63
+ iframe.style.display = "initial";
64
+ }}
65
+ />
66
+ );
67
+
68
+ const validatePeriscope = message => {
69
+ if (isValidMessage(message)) {
70
+ setHeight(message.data.dashboard_height + 100);
71
+ clearTimeout(time.timer);
72
+ periscopeDataRequestSuccess();
73
+ }
74
+ };
75
+
76
+ useLayoutEffect(() => {
77
+ window.addEventListener("message", validatePeriscope);
78
+ requestDashboardUrl();
79
+ return () => window.removeEventListener("message", validatePeriscope);
80
+ }, [requestDashboardUrl]);
81
+
82
+ return (
83
+ <Fragment>
84
+ <BoxWithShadow
85
+ padding="0"
86
+ minWidth="100%"
87
+ minHeight="592px"
88
+ variant="baseStandard"
89
+ background="#fff"
90
+ borderRadius="4px"
91
+ extraStyles={`display: flex; justify-content: center; align-items: center; flex-direction: column;`}
92
+ >
93
+ {periscopeDataPending && !periscopeDataSuccess && (
94
+ <Cover minHeight="100%" singleChild>
95
+ <Center intrinsic>
96
+ <Spinner size="100" />
97
+ </Center>
98
+ </Cover>
99
+ )}
100
+ {periscopeDataFailure && !periscopeDataSuccess && (
101
+ <Box padding="64px">
102
+ <Center intrinsic>
103
+ <Box padding="0 0 2rem">
104
+ <PeriscopeFailedIcon />
105
+ </Box>
106
+ <Heading variant="h3" weight="700">
107
+ Something Went Wrong
108
+ </Heading>
109
+ <Paragraph variant="p" extraStyles={`text-align: center;`}>
110
+ There was an issue trying to load the dashboard.
111
+ </Paragraph>
112
+ <Paragraph variant="p" extraStyles={`text-align: center;`}>
113
+ Your organization may not have a dashboard configured.
114
+ </Paragraph>
115
+ </Center>
116
+ </Box>
117
+ )}
118
+ {!periscopeDataFailure && url && Dashboard(height)(url)}
119
+ </BoxWithShadow>
120
+ </Fragment>
121
+ );
122
+ };
123
+
124
+ export default PeriscopeDashboardIframe;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { ALTO_GREY } from "../../../constants/colors";
4
+
5
+ export const DashboardIframe = styled.iframe`
6
+ border: none;
7
+ box-shadow: 0 0 5px 0 ${ALTO_GREY};
8
+ display: none;
9
+ `;
@@ -0,0 +1,3 @@
1
+ import PeriscopeDashboardIframe from "./PeriscopeDashboardIframe";
2
+
3
+ export default PeriscopeDashboardIframe;
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, Fragment } from "react";
2
2
  import { Stack, Box, Cluster } from "../../atoms/layouts";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./Tabs.theme";
@@ -46,9 +46,9 @@ const Tabs = ({
46
46
  </Box>
47
47
  <Box className="tab-content">
48
48
  <Box>
49
- {tabsConfig.tabs.map(tab => {
49
+ {tabsConfig.tabs.map((tab, idx) => {
50
50
  if (tab.label !== activeTab) return undefined;
51
- return tab.content;
51
+ return <Fragment key={idx}>{tab.content}</Fragment>;
52
52
  })}
53
53
  </Box>
54
54
  </Box>
@@ -79,3 +79,20 @@ export const checkDeniedCards = name => {
79
79
  return "";
80
80
  }
81
81
  };
82
+
83
+ /*
84
+ An optional style for layout atoms that positions the atom completely off screen
85
+ This will *not* be visible or accessible to sighted users
86
+ Use to contain text content or a11y interactive content (skip links when not visible)
87
+ that is only for users of assistive technologies (screen readers)
88
+
89
+ Currently implemented on the Box atom via the srOnly prop
90
+ */
91
+ export const screenReaderOnlyStyle = `
92
+ position: absolute;
93
+ left: -10000px;
94
+ top: auto;
95
+ width: 1px;
96
+ height: 1px;
97
+ overflow: hidden;
98
+ `;