@thecb/components 7.7.4-beta.4 → 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.4",
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,7 +41,7 @@ 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};
@@ -78,8 +89,7 @@ export const getPagesPanel = (page, pagesCount) => {
78
89
  };
79
90
 
80
91
  const Pagination = ({
81
- activeBorderWidth = "1px",
82
- activeBackgroundColor,
92
+ activeBorderWidth = "3px",
83
93
  arrowColor,
84
94
  borderRadius = "3px",
85
95
  buttonHeight = "40px",
@@ -94,40 +104,70 @@ const Pagination = ({
94
104
  pagePrevious,
95
105
  setCurrentPage,
96
106
  themeValues
97
- }) => (
98
- <Cluster justify="center" childGap={childGap}>
99
- {currentPage > 1 && (
100
- <PrevNextButton
101
- action={pagePrevious}
102
- arrowColor={arrowColor ?? themeValues.arrowColor}
103
- borderRadius={borderRadius}
104
- buttonHeight={buttonHeight}
105
- buttonWidth={buttonWidth}
106
- numberColor={numberColor ?? themeValues.numberColor}
107
- type="prev"
108
- />
109
- )}
110
- {getPagesPanel(currentPage, pageCount).map((item, index) =>
111
- item.isButton ? (
112
- <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
113
- <ButtonWithAction
114
- variant="ghost"
115
- key={item.index}
116
- text={item.index}
117
- disabled={item.active}
118
- action={
119
- !item.active
120
- ? () => setCurrentPage({ pageNumber: item.index })
121
- : noop
122
- }
123
- textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
124
- extraStyles={`
125
- ${
126
- item.active
127
- ? `border: ${activeBorderWidth} solid ${numberColor ??
128
- themeValues.numberColor};`
129
- : ""
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;
130
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={`
131
171
  min-width: ${buttonWidth}; min-height: 100%; padding: 0;
132
172
  border-radius: ${borderRadius};
133
173
  &:hover, &:focus {
@@ -140,50 +180,55 @@ const Pagination = ({
140
180
  color: ${numberColor ?? themeValues.numberColor}
141
181
  }
142
182
  margin: 0;
143
- &:hover { ${
144
- item.active
145
- ? "cursor: default;"
146
- : `background-color: ${themeValues.hoverBackgroundColor}`
147
- } }
183
+ &:hover {
184
+ background-color: ${themeValues.hoverBackgroundColor}
185
+ }
148
186
  &:focus {
149
187
  outline: none
150
188
  }
151
189
  `}
152
- dataQa={index}
153
- disabledBackgroundColor={activeBackgroundColor}
154
- disabledBorderColor={numberColor ?? themeValues.numberColor}
155
- disabledColor={numberColor ?? themeValues.numberColor}
156
- >
157
- {item.index}
158
- </ButtonWithAction>
159
- </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
+ />
160
222
  ) : (
161
- <Box padding="0 10px">
162
- <Cluster justify="flex-end">
163
- <Text
164
- key={index}
165
- variant="pXL"
166
- weight={fontWeight}
167
- color={numberColor ?? themeValues.numberColor}
168
- >
169
- {"..."}
170
- </Text>
171
- </Cluster>
172
- </Box>
173
- )
174
- )}
175
- {currentPage < pageCount && (
176
- <PrevNextButton
177
- action={pageNext}
178
- arrowColor={arrowColor ?? themeValues.arrowColor}
179
- borderRadius={borderRadius}
180
- buttonHeight={buttonHeight}
181
- buttonWidth={buttonWidth}
182
- numberColor={numberColor ?? themeValues.numberColor}
183
- type="next"
184
- />
185
- )}
186
- </Cluster>
187
- );
223
+ isMobile && (
224
+ <PrevNextPlaceholder
225
+ buttonHeight={buttonHeight}
226
+ buttonWidth={buttonWidth}
227
+ />
228
+ )
229
+ )}
230
+ </Cluster>
231
+ );
232
+ };
188
233
 
189
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