@thecb/components 7.7.4-beta.4 → 7.7.4-beta.6

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.6",
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,5 +1,7 @@
1
- import React from "react";
2
- import { Cluster, Box } from "../../atoms/layouts";
1
+ import React, { useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
3
+
4
+ import { Cluster, Cover, Box } from "../../atoms/layouts";
3
5
  import Text from "../../atoms/text";
4
6
  import ButtonWithAction from "../../atoms/button-with-action";
5
7
  import { ChevronIcon } from "../../atoms/icons";
@@ -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,13 +89,12 @@ 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
- buttonHeight = "40px",
86
- buttonWidth = "40px",
87
- childGap = "10px",
95
+ buttonHeight = "44px",
96
+ buttonWidth = "44px",
97
+ childGap = "24px",
88
98
  currentPage,
89
99
  fontSize = "17px",
90
100
  fontWeight = "900",
@@ -94,96 +104,131 @@ 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
- : ""
130
- }
131
- min-width: ${buttonWidth}; min-height: 100%; padding: 0;
132
- border-radius: ${borderRadius};
133
- &:hover, &:focus {
134
- text-decoration: none;
135
- > * > span {
136
- text-decoration: none;
137
- }
138
- }
139
- > * > span {
140
- color: ${numberColor ?? themeValues.numberColor}
141
- }
142
- margin: 0;
143
- &:hover { ${
144
- item.active
145
- ? "cursor: default;"
146
- : `background-color: ${themeValues.hoverBackgroundColor}`
147
- } }
148
- &:focus {
149
- outline: none
150
- }
151
- `}
152
- dataQa={index}
153
- disabledBackgroundColor={activeBackgroundColor}
154
- disabledBorderColor={numberColor ?? themeValues.numberColor}
155
- disabledColor={numberColor ?? themeValues.numberColor}
156
- >
157
- {item.index}
158
- </ButtonWithAction>
159
- </Box>
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
+ />
160
122
  ) : (
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
- );
123
+ isMobile && (
124
+ <PrevNextPlaceholder
125
+ buttonHeight={buttonHeight}
126
+ buttonWidth={buttonWidth}
127
+ />
128
+ )
129
+ )}
130
+ {isMobile
131
+ ? pageCount > 0 && (
132
+ <Box padding="0">
133
+ <Cover singleChild>
134
+ <Text
135
+ variant="pXL"
136
+ weight={fontWeight}
137
+ color={numberColor ?? themeValues.numberColor}
138
+ extraStyles={`font-size: ${fontSize}`}
139
+ >
140
+ {`${currentPage} of ${pageCount}`}
141
+ </Text>
142
+ </Cover>
143
+ </Box>
144
+ )
145
+ : getPagesPanel(currentPage, pageCount).map((item, index) =>
146
+ item.isButton ? (
147
+ <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
148
+ <ButtonWithAction
149
+ variant="ghost"
150
+ key={item.index}
151
+ text={item.index}
152
+ disabled={item.active}
153
+ extraDisabledStyles={`
154
+ border: ${activeBorderWidth} solid ${numberColor ??
155
+ themeValues.numberColor};
156
+ color: ${numberColor ?? themeValues.activeColor};
157
+ background-color: ${themeValues.activeBackgroundColor};
158
+ &:focus {
159
+ box-shadow: none;
160
+ }
161
+ &:hover {
162
+ background-color: initial;
163
+ }
164
+ `}
165
+ action={
166
+ !item.active
167
+ ? () => setCurrentPage({ pageNumber: item.index })
168
+ : noop
169
+ }
170
+ textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
171
+ extraStyles={`
172
+ min-width: ${buttonWidth}; min-height: 100%; padding: 0;
173
+ border-radius: ${borderRadius};
174
+ &:hover, &:focus {
175
+ text-decoration: none;
176
+ > * > span {
177
+ text-decoration: none;
178
+ }
179
+ }
180
+ > * > span {
181
+ color: ${numberColor ?? themeValues.numberColor}
182
+ }
183
+ margin: 0;
184
+ &:hover {
185
+ background-color: ${themeValues.hoverBackgroundColor}
186
+ }
187
+ &:focus {
188
+ outline: none
189
+ }
190
+ `}
191
+ dataQa={index}
192
+ >
193
+ {item.index}
194
+ </ButtonWithAction>
195
+ </Box>
196
+ ) : (
197
+ <Box padding="0 10px">
198
+ <Cluster justify="flex-end">
199
+ <Text
200
+ key={index}
201
+ variant="pXL"
202
+ weight={fontWeight}
203
+ color={numberColor ?? themeValues.numberColor}
204
+ extraStyles={`font-size: ${fontSize}`}
205
+ >
206
+ {"..."}
207
+ </Text>
208
+ </Cluster>
209
+ </Box>
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
+ />
222
+ ) : (
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