@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/dist/index.cjs.js +91 -62
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +91 -62
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/button-with-action/ButtonWithAction.js +13 -14
- package/src/components/molecules/pagination/Pagination.js +144 -99
- package/src/components/molecules/pagination/Pagination.theme.js +8 -1
package/package.json
CHANGED
|
@@ -62,19 +62,17 @@ const Spinner = ({ isMobile }) => (
|
|
|
62
62
|
|
|
63
63
|
const ButtonWithAction = ({
|
|
64
64
|
action = noop,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
variant = "primary",
|
|
66
|
+
text,
|
|
67
|
+
textWrap = false,
|
|
68
|
+
isLoading = false,
|
|
67
69
|
dataQa = null,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
disabledColor = "#FFFFFF",
|
|
70
|
+
textExtraStyles,
|
|
71
|
+
contentOverride = false,
|
|
71
72
|
extraStyles = "",
|
|
72
|
-
isLoading = false,
|
|
73
73
|
tabIndex,
|
|
74
|
-
|
|
75
|
-
|
|
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:
|
|
110
|
-
border-color:
|
|
111
|
-
color:
|
|
107
|
+
background-color: #6D717E;
|
|
108
|
+
border-color: #6D717E;
|
|
109
|
+
color: #FFFFFF;
|
|
112
110
|
cursor: default;
|
|
113
111
|
&:focus {
|
|
114
|
-
box-shadow: 0 0 10px
|
|
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 {
|
|
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
|
|
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 = "
|
|
82
|
-
activeBackgroundColor,
|
|
92
|
+
activeBorderWidth = "3px",
|
|
83
93
|
arrowColor,
|
|
84
94
|
borderRadius = "3px",
|
|
85
|
-
buttonHeight = "
|
|
86
|
-
buttonWidth = "
|
|
87
|
-
childGap = "
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|