@thecb/components 7.7.4-beta.3 → 7.7.4-beta.5

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": "7.7.4-beta.3",
3
+ "version": "7.7.4-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -62,19 +62,17 @@ const Spinner = ({ isMobile }) => (
62
62
 
63
63
  const ButtonWithAction = ({
64
64
  action = noop,
65
- children,
66
- contentOverride = false,
65
+ variant = "primary",
66
+ text,
67
+ textWrap = false,
68
+ isLoading = false,
67
69
  dataQa = null,
68
- disabledBackgroundColor = "#6D717E",
69
- disabledBorderColor = "#6D717E",
70
- disabledColor = "#FFFFFF",
70
+ textExtraStyles,
71
+ contentOverride = false,
71
72
  extraStyles = "",
72
- isLoading = false,
73
73
  tabIndex,
74
- text,
75
- textExtraStyles,
76
- textWrap = false,
77
- variant = "primary",
74
+ children,
75
+ extraDisabledStyles,
78
76
  ...rest
79
77
  }) => {
80
78
  const themeContext = useContext(ThemeContext);
@@ -106,14 +104,15 @@ const ButtonWithAction = ({
106
104
  };
107
105
  `;
108
106
  const disabledStyles = `
109
- background-color: ${disabledBackgroundColor};
110
- border-color: ${disabledBorderColor};
111
- color: ${disabledColor};
107
+ background-color: #6D717E;
108
+ border-color: #6D717E;
109
+ color: #FFFFFF;
112
110
  cursor: default;
113
111
  &:focus {
114
- box-shadow: 0 0 10px ${disabledBackgroundColor};
112
+ box-shadow: 0 0 10px #6D717E;
115
113
  outline: none;
116
114
  }
115
+ ${extraDisabledStyles}
117
116
  `;
118
117
 
119
118
  return (
@@ -1,4 +1,6 @@
1
- import React from "react";
1
+ import React, { useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
3
+
2
4
  import { Cluster, Box } from "../../atoms/layouts";
3
5
  import Text from "../../atoms/text";
4
6
  import ButtonWithAction from "../../atoms/button-with-action";
@@ -10,6 +12,15 @@ import { fallbackValues } from "./Pagination.theme";
10
12
  const PAGING_SPACE = 2; // how many pages we want to have before/after delimiter
11
13
  const PAGING_INIT_SPACE = 3; // first delimiter should appear after 3 pages
12
14
 
15
+ const PrevNextPlaceholder = ({ buttonHeight, buttonWidth }) => (
16
+ <Box
17
+ padding="0"
18
+ minHeight={buttonHeight}
19
+ minWidth={buttonWidth}
20
+ extraStyles={`max-height: ${buttonHeight};`}
21
+ ></Box>
22
+ );
23
+
13
24
  const PrevNextButton = ({
14
25
  action,
15
26
  arrowColor,
@@ -20,7 +31,7 @@ const PrevNextButton = ({
20
31
  type
21
32
  }) => (
22
33
  <Box
23
- padding="0 10px 0"
34
+ padding="0"
24
35
  minHeight={buttonHeight}
25
36
  extraStyles={`max-height: ${buttonHeight};`}
26
37
  >
@@ -30,12 +41,13 @@ const PrevNextButton = ({
30
41
  dataQa={type}
31
42
  extraStyles={`
32
43
  background-color: ${numberColor};
33
- border-color: ${numberColor}
44
+ border-color: ${numberColor};
34
45
  border-radius: ${borderRadius};
35
46
  margin: 0;
36
47
  max-height: ${buttonHeight};
37
48
  min-height: 100%;
38
49
  min-width: ${buttonWidth};
50
+ padding: 0;
39
51
  &:focus {
40
52
  outline: none
41
53
  }
@@ -77,8 +89,7 @@ export const getPagesPanel = (page, pagesCount) => {
77
89
  };
78
90
 
79
91
  const Pagination = ({
80
- activeBorderWidth = "1px",
81
- activeBackgroundColor,
92
+ activeBorderWidth = "3px",
82
93
  arrowColor,
83
94
  borderRadius = "3px",
84
95
  buttonHeight = "40px",
@@ -93,40 +104,70 @@ const Pagination = ({
93
104
  pagePrevious,
94
105
  setCurrentPage,
95
106
  themeValues
96
- }) => (
97
- <Cluster justify="center" childGap={childGap}>
98
- {currentPage > 1 && (
99
- <PrevNextButton
100
- action={pagePrevious}
101
- arrowColor={arrowColor ?? themeValues.arrowColor}
102
- borderRadius={borderRadius}
103
- buttonHeight={buttonHeight}
104
- buttonWidth={buttonWidth}
105
- numberColor={numberColor ?? themeValues.numberColor}
106
- type="prev"
107
- />
108
- )}
109
- {getPagesPanel(currentPage, pageCount).map((item, index) =>
110
- item.isButton ? (
111
- <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
112
- <ButtonWithAction
113
- variant="ghost"
114
- key={item.index}
115
- text={item.index}
116
- disabled={item.active}
117
- action={
118
- !item.active
119
- ? () => setCurrentPage({ pageNumber: item.index })
120
- : noop
121
- }
122
- textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
123
- extraStyles={`
124
- ${
125
- item.active
126
- ? `border: ${activeBorderWidth} solid ${numberColor ??
127
- themeValues.numberColor};`
128
- : ""
107
+ }) => {
108
+ const { isMobile } = useContext(ThemeContext);
109
+
110
+ return (
111
+ <Cluster justify="center" childGap={childGap}>
112
+ {currentPage > 1 ? (
113
+ <PrevNextButton
114
+ action={pagePrevious}
115
+ arrowColor={arrowColor ?? themeValues.arrowColor}
116
+ borderRadius={borderRadius}
117
+ buttonHeight={buttonHeight}
118
+ buttonWidth={buttonWidth}
119
+ numberColor={numberColor ?? themeValues.numberColor}
120
+ type="prev"
121
+ />
122
+ ) : (
123
+ isMobile && (
124
+ <PrevNextPlaceholder
125
+ buttonHeight={buttonHeight}
126
+ buttonWidth={buttonWidth}
127
+ />
128
+ )
129
+ )}
130
+ {isMobile ? (
131
+ <Box padding="0">
132
+ <Cluster justify="flex-end">
133
+ <Text
134
+ variant="pXL"
135
+ weight={fontWeight}
136
+ color={numberColor ?? themeValues.numberColor}
137
+ extraStyles={`font-size: ${fontSize}`}
138
+ >
139
+ {`${currentPage} of ${pageCount}`}
140
+ </Text>
141
+ </Cluster>
142
+ </Box>
143
+ ) : (
144
+ getPagesPanel(currentPage, pageCount).map((item, index) =>
145
+ item.isButton ? (
146
+ <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
147
+ <ButtonWithAction
148
+ variant="ghost"
149
+ key={item.index}
150
+ text={item.index}
151
+ disabled={item.active}
152
+ extraDisabledStyles={`
153
+ border: ${activeBorderWidth} solid ${numberColor ??
154
+ themeValues.numberColor};
155
+ color: ${numberColor ?? themeValues.activeColor};
156
+ background-color: ${themeValues.activeBackgroundColor};
157
+ &:focus {
158
+ box-shadow: none;
159
+ }
160
+ &:hover {
161
+ background-color: initial;
129
162
  }
163
+ `}
164
+ action={
165
+ !item.active
166
+ ? () => setCurrentPage({ pageNumber: item.index })
167
+ : noop
168
+ }
169
+ textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
170
+ extraStyles={`
130
171
  min-width: ${buttonWidth}; min-height: 100%; padding: 0;
131
172
  border-radius: ${borderRadius};
132
173
  &:hover, &:focus {
@@ -139,50 +180,55 @@ const Pagination = ({
139
180
  color: ${numberColor ?? themeValues.numberColor}
140
181
  }
141
182
  margin: 0;
142
- &:hover { ${
143
- item.active
144
- ? "cursor: default;"
145
- : `background-color: ${themeValues.hoverBackgroundColor}`
146
- } }
183
+ &:hover {
184
+ background-color: ${themeValues.hoverBackgroundColor}
185
+ }
147
186
  &:focus {
148
187
  outline: none
149
188
  }
150
189
  `}
151
- dataQa={index}
152
- disabledBackgroundColor={activeBackgroundColor}
153
- disabledBorderColor={numberColor ?? themeValues.numberColor}
154
- disabledColor={numberColor ?? themeValues.numberColor}
155
- >
156
- {item.index}
157
- </ButtonWithAction>
158
- </Box>
190
+ dataQa={index}
191
+ >
192
+ {item.index}
193
+ </ButtonWithAction>
194
+ </Box>
195
+ ) : (
196
+ <Box padding="0 10px">
197
+ <Cluster justify="flex-end">
198
+ <Text
199
+ key={index}
200
+ variant="pXL"
201
+ weight={fontWeight}
202
+ color={numberColor ?? themeValues.numberColor}
203
+ extraStyles={`font-size: ${fontSize}`}
204
+ >
205
+ {"..."}
206
+ </Text>
207
+ </Cluster>
208
+ </Box>
209
+ )
210
+ )
211
+ )}
212
+ {currentPage < pageCount ? (
213
+ <PrevNextButton
214
+ action={pageNext}
215
+ arrowColor={arrowColor ?? themeValues.arrowColor}
216
+ borderRadius={borderRadius}
217
+ buttonHeight={buttonHeight}
218
+ buttonWidth={buttonWidth}
219
+ numberColor={numberColor ?? themeValues.numberColor}
220
+ type="next"
221
+ />
159
222
  ) : (
160
- <Box padding="0 10px">
161
- <Cluster justify="flex-end">
162
- <Text
163
- key={index}
164
- variant="pXL"
165
- weight={fontWeight}
166
- color={numberColor ?? themeValues.numberColor}
167
- >
168
- {"..."}
169
- </Text>
170
- </Cluster>
171
- </Box>
172
- )
173
- )}
174
- {currentPage < pageCount && (
175
- <PrevNextButton
176
- action={pageNext}
177
- arrowColor={arrowColor ?? themeValues.arrowColor}
178
- borderRadius={borderRadius}
179
- buttonHeight={buttonHeight}
180
- buttonWidth={buttonWidth}
181
- numberColor={numberColor ?? themeValues.numberColor}
182
- type="next"
183
- />
184
- )}
185
- </Cluster>
186
- );
223
+ isMobile && (
224
+ <PrevNextPlaceholder
225
+ buttonHeight={buttonHeight}
226
+ buttonWidth={buttonWidth}
227
+ />
228
+ )
229
+ )}
230
+ </Cluster>
231
+ );
232
+ };
187
233
 
188
234
  export default themeComponent(Pagination, "Pagination", fallbackValues);
@@ -1,14 +1,21 @@
1
1
  import {
2
2
  WHITE,
3
3
  MATISSE_BLUE,
4
- ALABASTER_WHITE
4
+ ALABASTER_WHITE,
5
+ STORM_GREY
5
6
  } from "../../../constants/colors";
6
7
 
7
8
  const arrowColor = WHITE;
8
9
  const numberColor = MATISSE_BLUE;
9
10
  const hoverBackgroundColor = ALABASTER_WHITE;
11
+ const activeBackgroundColor = WHITE;
12
+ const activeBorderColor = MATISSE_BLUE;
13
+ const activeColor = MATISSE_BLUE;
10
14
 
11
15
  export const fallbackValues = {
16
+ activeColor,
17
+ activeBackgroundColor,
18
+ activeBorderColor,
12
19
  arrowColor,
13
20
  hoverBackgroundColor,
14
21
  numberColor