@thecb/components 9.1.7-beta.0 → 9.1.7-beta.2

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.1.7-beta.0",
3
+ "version": "9.1.7-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -4,7 +4,7 @@ import { Box, Center, Cluster, Stack, Cover, Sidebar } from "../layouts";
4
4
  import Text from "../text";
5
5
  import { fallbackValues } from "./Alert.theme";
6
6
  import { themeComponent } from "../../../util/themeUtils";
7
- import { generateShadows } from "../../../util/generateShadows";
7
+ import { generateShadows } from "../../../util/colorUtils";
8
8
 
9
9
  const Alert = ({
10
10
  heading,
@@ -16,10 +16,12 @@ import {
16
16
  GREY_CHATEAU,
17
17
  MINESHAFT_GREY,
18
18
  STORM_GREY,
19
+ TRANSPARENT,
19
20
  WHITE
20
21
  } from "../../../constants/colors";
21
22
  import { fallbackValues } from "./Dropdown.theme";
22
23
  import { themeComponent } from "../../../util/themeUtils";
24
+ import { addOpacity } from "../../../util/colorUtils";
23
25
 
24
26
  const IconWrapper = styled.div`
25
27
  position: absolute;
@@ -57,50 +59,66 @@ const DropdownContentWrapper = styled.div`
57
59
  const DropdownItemWrapper = styled.li`
58
60
  text-align: start;
59
61
  border-width: 2px;
60
- border-color: transparent;
62
+ border-style: solid;
63
+ border-color: ${({ selected, themeValues }) =>
64
+ selected
65
+ ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0)
66
+ : TRANSPARENT};
61
67
  box-shadow: none;
62
- padding: 1rem;
63
68
  box-sizing: border-box;
64
69
  width: 100%;
65
70
  list-style: none;
66
71
  cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
67
72
 
68
73
  &:hover {
69
- border-color: themeValues.selectedColor;
70
- }
71
- &:focus {
72
- outline: none;
73
- border-color: themeValues.selectedColor;
74
- }
75
- `;
76
- // ${({ selected, themeValues }) =>
77
- // selected ? themeValues.selectedColor : TRANSPARENT};
78
- const DropdownItemBorder = styled.div`
79
- background-color: ${({ selected, themeValues }) =>
80
- selected ? themeValues.selectedColor : WHITE};
81
- border-width: 2px;
82
- border-color: white;
83
- width: 100%;
84
-
85
- &:hover {
86
- background-color: ${({ selected, disabled, themeValues }) =>
74
+ background: ${({ selected, disabled, themeValues }) =>
87
75
  selected
88
- ? themeValues.selectedColor
76
+ ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0)
89
77
  : disabled
90
78
  ? WHITE
91
79
  : themeValues.hoverColor};
80
+ > * {
81
+ background: ${({ selected, disabled, themeValues }) =>
82
+ selected
83
+ ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0)
84
+ : disabled
85
+ ? WHITE
86
+ : themeValues.hoverColor};
87
+ border-color: ${({ selected, themeValues }) =>
88
+ selected
89
+ ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0)
90
+ : themeValues.hoverColor};
91
+ }
92
92
  }
93
93
  &:focus {
94
- background-color: ${({ selected, disabled, themeValues }) =>
95
- selected
96
- ? themeValues.selectedColor
97
- : disabled
98
- ? WHITE
99
- : themeValues.hoverColor};
100
94
  outline: none;
95
+ background: ${({ selected, themeValues }) =>
96
+ selected ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0) : ""};
97
+ border-color: ${({ selected, themeValues }) =>
98
+ selected ? TRANSPARENT : themeValues.selectedColor};
99
+ > * {
100
+ background: ${({ selected, disabled, themeValues }) =>
101
+ selected
102
+ ? addOpacity(themeValues.selectedColor, 0.2, 0, 0, 0)
103
+ : disabled
104
+ ? WHITE
105
+ : themeValues.hoverColor};
106
+ border-color: white;
107
+ outline: none;
108
+ }
101
109
  }
102
110
  `;
103
111
 
112
+ const DropdownItemBorder = styled.div`
113
+ background: ${({ selected, themeValues }) =>
114
+ selected ? themeValues.selectedColor : WHITE};
115
+ border-color: ${({ selected, themeValues }) =>
116
+ selected ? themeValues.selectedColor : WHITE};
117
+ border-width: 2px;
118
+ border-style: solid;
119
+ padding: 12px;
120
+ `;
121
+
104
122
  const Dropdown = ({
105
123
  placeholder,
106
124
  options,
@@ -400,7 +418,11 @@ const Dropdown = ({
400
418
  role="option"
401
419
  onFocus={() => setFocusedRef(optionRefs.current[i])}
402
420
  >
403
- <DropdownItemBorder selected={choice.value === value}>
421
+ <DropdownItemBorder
422
+ disabled={disabledValues.includes(choice.value)}
423
+ selected={choice.value === value}
424
+ themeValues={themeValues}
425
+ >
404
426
  <Text
405
427
  variant="p"
406
428
  color={
@@ -8,7 +8,7 @@ import {
8
8
  CHARADE_GREY,
9
9
  ERROR_COLOR
10
10
  } from "../../../constants/colors";
11
- import { generateShadows } from "../../../util/generateShadows";
11
+ import { generateShadows } from "../../../util/colorUtils";
12
12
  import useScrollTo from "../../../util/useScrollTo";
13
13
 
14
14
  const TermsAndConditionsControlV2 = ({
@@ -58,3 +58,9 @@ export const generateShadows = (baseColorRGB = "rgb(41, 42, 51)") => {
58
58
  overlay
59
59
  };
60
60
  };
61
+
62
+ export const addOpacity = (color, opacity, r, g, b) => {
63
+ const rgba = `rgba(${r}, ${g}, ${b}, ${opacity})`;
64
+
65
+ return `linear-gradient(0deg, ${rgba}, ${rgba}), linear-gradient(0deg, ${color}, ${color});`;
66
+ };