@thecb/components 9.2.0-beta.9 → 9.2.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": "9.2.0-beta.9",
3
+ "version": "9.2.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -12,11 +12,11 @@ import styled from "styled-components";
12
12
  import "core-js/proposals/relative-indexing-method";
13
13
 
14
14
  import {
15
- WHITE,
15
+ ERROR_COLOR,
16
16
  GREY_CHATEAU,
17
- STORM_GREY,
18
17
  MINESHAFT_GREY,
19
- ERROR_COLOR
18
+ STORM_GREY,
19
+ WHITE
20
20
  } from "../../../constants/colors";
21
21
  import { fallbackValues } from "./Dropdown.theme";
22
22
  import { themeComponent } from "../../../util/themeUtils";
@@ -55,37 +55,65 @@ const DropdownContentWrapper = styled.div`
55
55
  `;
56
56
 
57
57
  const DropdownItemWrapper = styled.li`
58
- background-color: ${({ selected, themeValues }) =>
59
- selected ? themeValues.selectedColor : WHITE};
60
58
  text-align: start;
61
- border-width: 0px;
62
- border-color: transparent;
59
+ border-width: 2px;
60
+ border-style: solid;
61
+ border-color: ${({ selected, themeValues }) =>
62
+ selected ? themeValues.selectedColor : WHITE};
63
63
  box-shadow: none;
64
- padding: 1rem;
65
64
  box-sizing: border-box;
66
65
  width: 100%;
67
66
  list-style: none;
68
67
  cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
69
68
 
70
69
  &:hover {
71
- background-color: ${({ selected, disabled, themeValues }) =>
70
+ border-color: ${({ disabled, selected, themeValues }) =>
72
71
  selected
73
- ? themeValues.selectedColor
72
+ ? themeValues.focusColor
74
73
  : disabled
75
74
  ? WHITE
76
75
  : themeValues.hoverColor};
76
+ > * {
77
+ background: ${({ selected, disabled, themeValues }) =>
78
+ selected
79
+ ? themeValues.focusColor
80
+ : disabled
81
+ ? WHITE
82
+ : themeValues.hoverColor};
83
+ border-color: ${({ selected, disabled, themeValues }) =>
84
+ selected
85
+ ? themeValues.focusColor
86
+ : disabled
87
+ ? WHITE
88
+ : themeValues.hoverColor};
89
+ }
77
90
  }
78
91
  &:focus {
79
- background-color: ${({ selected, disabled, themeValues }) =>
80
- selected
81
- ? themeValues.selectedColor
82
- : disabled
83
- ? WHITE
84
- : themeValues.hoverColor};
85
92
  outline: none;
93
+ border-color: ${({ themeValues }) => themeValues.selectedColor};
94
+ > * {
95
+ background: ${({ selected, disabled, themeValues }) =>
96
+ selected
97
+ ? themeValues.focusColor
98
+ : disabled
99
+ ? WHITE
100
+ : themeValues.hoverColor};
101
+ border-color: white;
102
+ outline: none;
103
+ }
86
104
  }
87
105
  `;
88
106
 
107
+ const DropdownItemBorder = styled.div`
108
+ background: ${({ selected, themeValues }) =>
109
+ selected ? themeValues.selectedColor : WHITE};
110
+ border-color: ${({ selected, themeValues }) =>
111
+ selected ? themeValues.selectedColor : WHITE};
112
+ border-width: 2px;
113
+ border-style: solid;
114
+ padding: 12px;
115
+ `;
116
+
89
117
  const Dropdown = ({
90
118
  placeholder,
91
119
  options,
@@ -385,27 +413,33 @@ const Dropdown = ({
385
413
  role="option"
386
414
  onFocus={() => setFocusedRef(optionRefs.current[i])}
387
415
  >
388
- <Text
389
- variant="p"
390
- color={
391
- choice.value === value
392
- ? WHITE
393
- : disabledValues.includes(choice.value)
394
- ? STORM_GREY
395
- : MINESHAFT_GREY
396
- }
397
- extraStyles={`padding-left: 16px;
398
- cursor: ${
399
- disabledValues.includes(choice.value)
400
- ? "default"
401
- : "pointer"
402
- };
403
- white-space: nowrap;
404
- overflow: hidden;
405
- text-overflow: ellipsis;`}
416
+ <DropdownItemBorder
417
+ disabled={disabledValues.includes(choice.value)}
418
+ selected={choice.value === value}
419
+ themeValues={themeValues}
406
420
  >
407
- {choice.text}
408
- </Text>
421
+ <Text
422
+ variant="p"
423
+ color={
424
+ choice.value === value
425
+ ? WHITE
426
+ : disabledValues.includes(choice.value)
427
+ ? STORM_GREY
428
+ : MINESHAFT_GREY
429
+ }
430
+ extraStyles={`padding-left: 16px;
431
+ cursor: ${
432
+ disabledValues.includes(choice.value)
433
+ ? "default"
434
+ : "pointer"
435
+ };
436
+ white-space: nowrap;
437
+ overflow: hidden;
438
+ text-overflow: ellipsis;`}
439
+ >
440
+ {choice.text}
441
+ </Text>
442
+ </DropdownItemBorder>
409
443
  </DropdownItemWrapper>
410
444
  );
411
445
  })}
@@ -1,9 +1,15 @@
1
- import { HOVER_LIGHT_BLUE, MATISSE_BLUE } from "../../../constants/colors";
1
+ import {
2
+ HOVER_LIGHT_BLUE,
3
+ MATISSE_BLUE,
4
+ MATISSE_BLUE_DARK
5
+ } from "../../../constants/colors";
2
6
 
3
7
  const selectedColor = `${MATISSE_BLUE}`;
4
8
  const hoverColor = `${HOVER_LIGHT_BLUE}`;
9
+ const focusColor = `${MATISSE_BLUE_DARK}`;
5
10
 
6
11
  export const fallbackValues = {
7
12
  selectedColor,
8
- hoverColor
13
+ hoverColor,
14
+ focusColor
9
15
  };
@@ -4,7 +4,7 @@ import Text from "../../atoms/text";
4
4
  import Paragraph from "../../atoms/paragraph";
5
5
  import { Box } from "../../atoms/layouts";
6
6
  import ButtonWithAction from "../../atoms/button-with-action";
7
- import { useOutsideClick } from "../../../util";
7
+ import { useOutsideClick } from "../../../hooks";
8
8
  import { noop } from "../../../util/general";
9
9
  import { fallbackValues } from "./Popover.theme";
10
10
 
@@ -24,19 +24,21 @@ const RadioButton = ({
24
24
  const buttonBorder = {
25
25
  onFocused: {
26
26
  borderColor: themeValues.activeColor,
27
- boxShadow: `0px 0px 4px 0px ${themeValues.activeColor}`
27
+ outline: `3px solid ${themeValues.activeColor}`,
28
+ outlineOffset: "2px"
28
29
  },
29
30
  offFocused: {
30
31
  borderColor: themeValues.activeColor,
31
- boxShadow: `0px 0px 4px 0px ${themeValues.activeColor}`
32
+ outline: `3px solid ${themeValues.activeColor}`,
33
+ outlineOffset: "2px"
32
34
  },
33
35
  on: {
34
36
  borderColor: themeValues.activeColor,
35
- boxShadow: "0px 0px 0px 0px #FFFFFF"
37
+ outline: "0"
36
38
  },
37
39
  off: {
38
40
  borderColor: themeValues.inactiveColor,
39
- boxShadow: "0px 0px 0px 0px #FFFFFF"
41
+ outline: "0"
40
42
  }
41
43
  };
42
44
 
@@ -97,7 +99,7 @@ const RadioButton = ({
97
99
  borderWidth="1px"
98
100
  borderStyle="solid"
99
101
  borderRadius="12px"
100
- margin="4px 14px 4px 4px"
102
+ margin="6px 14px 6px 6px"
101
103
  height="24px"
102
104
  width="24px"
103
105
  variants={buttonBorder}
@@ -1,7 +1,7 @@
1
- import { MATISSE_BLUE, GREY_CHATEAU } from "../../../../constants/colors";
1
+ import { MATISSE_BLUE, STORM_GREY } from "../../../../constants/colors";
2
2
 
3
3
  const activeColor = `${MATISSE_BLUE}`;
4
- const inactiveColor = `${GREY_CHATEAU}`;
4
+ const inactiveColor = `${STORM_GREY}`;
5
5
 
6
6
  export const fallbackValues = {
7
7
  activeColor,
@@ -9,7 +9,7 @@ import {
9
9
  ERROR_COLOR
10
10
  } from "../../../constants/colors";
11
11
  import { generateShadows } from "../../../util/generateShadows";
12
- import useScrollTo from "../../../util/useScrollTo";
12
+ import { useScrollTo } from "../../../hooks";
13
13
 
14
14
  const TermsAndConditionsControlV2 = ({
15
15
  showCheckbox = true,
@@ -12,6 +12,7 @@ import {
12
12
  WHITE
13
13
  } from "../../../constants/colors";
14
14
  import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
15
+ import { generateShadows } from "../../../util/generateShadows";
15
16
 
16
17
  const VARIANTS = {
17
18
  SUCCESS: "success",
@@ -37,7 +38,7 @@ const ToastNotification = ({
37
38
  ? backgroundColor
38
39
  : variant === VARIANTS.SUCCESS
39
40
  ? HINT_GREEN
40
- : variant === "error"
41
+ : variant === VARIANTS.ERROR
41
42
  ? ERROR_BACKGROUND_COLOR
42
43
  : WHITE
43
44
  }
@@ -47,9 +48,7 @@ const ToastNotification = ({
47
48
  tabIndex={toastOpen ? "-1" : "0"}
48
49
  padding="0rem 1rem"
49
50
  borderRadius="4px"
50
- boxShadow="0px 4px 4px rgba(41, 42, 51, 0.15),
51
- 0px 1px 7px rgba(41, 42, 51, 0.2),
52
- 0px 7px 12px rgba(41, 42, 51, 0.15)"
51
+ boxShadow={generateShadows().standard.base}
53
52
  extraStyles={`
54
53
  display: ${toastOpen ? "block" : "none"};
55
54
  position: fixed; bottom: 4rem; left: 4rem;
@@ -58,8 +57,8 @@ const ToastNotification = ({
58
57
  `}
59
58
  >
60
59
  <Cluster align="center" childGap={childGap}>
61
- {variant === "success" && <SuccessfulIconMedium />}
62
- {variant === "error" && <ErroredIcon />}
60
+ {variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
61
+ {variant === VARIANTS.ERROR && <ErroredIcon />}
63
62
  <Box padding="1rem 0" maxWidth={maxWidth}>
64
63
  <Paragraph
65
64
  weight={FONT_WEIGHT_SEMIBOLD}
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from "react";
2
2
  import ToastNotification from "./ToastNotification";
3
3
  import page from "../../../../.storybook/page";
4
- import { useToastNotification } from "../../../util";
4
+ import { useToastNotification } from "../../../hooks";
5
5
  import { ToastVariants } from "../../../types/common";
6
6
 
7
7
  export const toastNotificationSuccess = () => {
@@ -38,13 +38,13 @@ export const toastNotificationError = () => {
38
38
  toastVariant,
39
39
  toastMessage,
40
40
  showToast,
41
- hideToast,
41
+ hideToast
42
42
  } = useToastNotification();
43
43
 
44
44
  useEffect(() => {
45
45
  showToast({
46
46
  message: "An error occurred",
47
- variant: ToastVariants.ERROR,
47
+ variant: ToastVariants.ERROR
48
48
  });
49
49
  }, []);
50
50
 
@@ -61,7 +61,7 @@ toastNotificationError.storyName = "Error Toast";
61
61
 
62
62
  const story = page({
63
63
  title: "Components|Molecules/ToastNotification",
64
- Component: ToastNotification,
64
+ Component: ToastNotification
65
65
  });
66
66
 
67
67
  export default story;
@@ -56,6 +56,7 @@ const INFO_BLUE = "#E4F4FD";
56
56
  const CORNFLOWER_BLUE = "#EBEFFB";
57
57
  const HOVER_LIGHT_BLUE = "#EFFAFF";
58
58
  const MATISSE_BLUE = "#15749D";
59
+ const MATISSE_BLUE_DARK = "#105C7D";
59
60
  const ROYAL_BLUE = "#3181E3";
60
61
  const ROYAL_BLUE_VIVID = "#3B5BDB";
61
62
  const ASTRAL_BLUE = "#3176AA";
@@ -193,6 +194,7 @@ export {
193
194
  BOSTON_BLUE,
194
195
  HOVER_LIGHT_BLUE,
195
196
  MATISSE_BLUE,
197
+ MATISSE_BLUE_DARK,
196
198
  ROYAL_BLUE,
197
199
  ROYAL_BLUE_VIVID,
198
200
  ASTRAL_BLUE,
@@ -0,0 +1,3 @@
1
+ export { default as useOutsideClick } from "./use-outside-click";
2
+ export { default as useScrollTo } from "./use-scroll-to";
3
+ export { default as useToastNotification } from "./use-toast-notification";
@@ -1,23 +1,23 @@
1
- import { ToastVariants } from "../../../types/common";
1
+ import { ToastVariants } from "../../types/common";
2
2
 
3
- export interface UseToastProps {
3
+ export interface UseToastOptions {
4
4
  timeout?: number;
5
5
  }
6
6
 
7
7
  export interface UseToastResult {
8
8
  isToastOpen: boolean;
9
- toastVariant: "" | ToastVariants;
9
+ toastVariant: string | ToastVariants;
10
10
  toastMessage: string;
11
11
  showToast: ({
12
12
  message,
13
- variant,
13
+ variant
14
14
  }: {
15
15
  message: string;
16
- variant: ToastVariants;
16
+ variant: string | ToastVariants;
17
17
  }) => void;
18
18
  hideToast: () => void;
19
19
  }
20
20
 
21
21
  export default function useToastNotification(
22
- props: UseToastProps
22
+ options?: UseToastOptions
23
23
  ): UseToastResult;
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as constants from "./constants";
2
- import * as hooks from "./util/hooks";
2
+ import * as hooks from "./hooks";
3
3
  export * from "./components";
4
4
  export * from "./types/common";
5
5
  export { constants, hooks };
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./components";
2
2
  import * as constants from "./constants";
3
3
  import * as util from "./util";
4
- export { constants, util };
4
+ import * as hooks from "./hooks";
5
+ export { constants, util, hooks };
@@ -1,6 +1,6 @@
1
1
  enum ToastVariants {
2
2
  ERROR = "error",
3
- SUCCESS = "success",
3
+ SUCCESS = "success"
4
4
  }
5
5
 
6
6
  export default ToastVariants;
package/src/util/index.js CHANGED
@@ -2,8 +2,8 @@ import * as formats from "./formats";
2
2
  import * as general from "./general";
3
3
  import * as theme from "./themeUtils";
4
4
  import useFocusInvalidInput from "./focusFirstInvalidInputHook";
5
- import useOutsideClick from "./useOutsideClick";
6
- import useToastNotification from "./hooks/use-toast-notification";
5
+ import useOutsideClick from "../hooks/use-outside-click";
6
+ import useToastNotification from "../hooks/use-toast-notification";
7
7
 
8
8
  export {
9
9
  formats,
@@ -1 +0,0 @@
1
- export { default as useToastNotification } from "./use-toast-notification";