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

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.6",
3
+ "version": "7.7.4-beta.7",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -201,7 +201,6 @@ const Pagination = ({
201
201
  variant="pXL"
202
202
  weight={fontWeight}
203
203
  color={numberColor ?? themeValues.numberColor}
204
- extraStyles={`font-size: ${fontSize}`}
205
204
  >
206
205
  {"..."}
207
206
  </Text>
@@ -9,13 +9,11 @@ const arrowColor = WHITE;
9
9
  const numberColor = MATISSE_BLUE;
10
10
  const hoverBackgroundColor = ALABASTER_WHITE;
11
11
  const activeBackgroundColor = WHITE;
12
- const activeBorderColor = MATISSE_BLUE;
13
12
  const activeColor = MATISSE_BLUE;
14
13
 
15
14
  export const fallbackValues = {
16
15
  activeColor,
17
16
  activeBackgroundColor,
18
- activeBorderColor,
19
17
  arrowColor,
20
18
  hoverBackgroundColor,
21
19
  numberColor
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface PaginationProps {
5
+ extraStyles?: string;
6
+ activeBorderWidth?: string;
7
+ arrowColor?: string;
8
+ borderRadius?: string;
9
+ buttonHeight?: string;
10
+ buttonWidth?: string;
11
+ childGap?: string;
12
+ currentPage: number;
13
+ fontSize?: string;
14
+ fontWeight?: string;
15
+ numberColor?: string;
16
+ pageCount: number;
17
+ pageNext: () => void;
18
+ pagePrevious: () => void;
19
+ setCurrentPage: ({ currentPage: number }) => void;
20
+ }
21
+
22
+ export const Pagination: React.FC<Expand<PaginationProps> &
23
+ React.HTMLAttributes<HTMLElement>>;
@@ -1,187 +0,0 @@
1
- import React from "react";
2
- import { Cluster, Box } from "../../atoms/layouts";
3
- import Text from "../../atoms/text";
4
- import ButtonWithAction from "../../atoms/button-with-action";
5
- import { ChevronIcon } from "../../atoms/icons";
6
- import { noop } from "../../../util/general";
7
- import { themeComponent } from "../../../util/themeUtils";
8
- import { fallbackValues } from "./Pagination.theme";
9
-
10
- const PAGING_SPACE = 2; // how many pages we want to have before/after delimiter
11
- const PAGING_INIT_SPACE = 3; // first delimiter should appear after 3 pages
12
-
13
- const PrevNextButton = ({
14
- action,
15
- arrowColor,
16
- borderRadius,
17
- numberColor,
18
- buttonHeight,
19
- buttonWidth,
20
- type
21
- }) => (
22
- <Box
23
- padding="0 10px 0"
24
- minHeight={buttonHeight}
25
- extraStyles={`max-height: ${buttonHeight};`}
26
- >
27
- <ButtonWithAction
28
- action={action}
29
- contentOverride
30
- dataQa={type}
31
- extraStyles={`
32
- min-width: ${buttonWidth};
33
- min-height: 100%;
34
- max-height: ${buttonHeight};
35
- padding: 6px;
36
- border-radius: ${borderRadius};
37
- background-color: ${numberColor};
38
- border-color: ${numberColor};
39
- margin: 0;
40
- `}
41
- >
42
- <Box padding="0" extraStyles={type === "prev" && "transform: scaleX(-1)"}>
43
- <ChevronIcon variant="darkMode" iconFill={arrowColor} />
44
- </Box>
45
- </ButtonWithAction>
46
- </Box>
47
- );
48
-
49
- export const getPagesPanel = (page, pagesCount) => {
50
- if (!pagesCount || pagesCount <= 1) {
51
- return [];
52
- }
53
- const lastPageNumber = pagesCount;
54
- const space = page === 1 ? PAGING_INIT_SPACE : PAGING_SPACE;
55
- const pages = [{ index: 1, isButton: true }];
56
- if (page > space + 1) {
57
- pages.push({ isDelimiter: true });
58
- }
59
- for (
60
- let j = Math.max(1, page - space) + 1;
61
- j < Math.min(lastPageNumber, page + space);
62
- j++
63
- ) {
64
- pages.push({ index: j, isButton: true });
65
- }
66
- if (page < lastPageNumber - space) {
67
- pages.push({ isDelimiter: true });
68
- }
69
- pages.push({ index: lastPageNumber, isButton: true });
70
- const activePage = pages.find(p => p.index === page);
71
- if (activePage) {
72
- activePage.active = true;
73
- }
74
- return pages;
75
- };
76
-
77
- const Pagination = ({
78
- activeBorderWidth = "1px",
79
- applyActivePageDisabledStyles = true,
80
- arrowColor,
81
- borderRadius = "3px",
82
- buttonHeight = "40px",
83
- buttonWidth = "40px",
84
- childGap = "10px",
85
- currentPage,
86
- fontSize = "17px",
87
- fontWeight = "900",
88
- numberColor,
89
- pageCount,
90
- pageNext,
91
- pagePrevious,
92
- setCurrentPage,
93
- themeValues
94
- }) => (
95
- <Cluster justify="center" childGap={childGap}>
96
- {currentPage > 1 && (
97
- <PrevNextButton
98
- action={pagePrevious}
99
- arrowColor={arrowColor ?? themeValues.arrowColor}
100
- borderRadius={borderRadius}
101
- buttonHeight={buttonHeight}
102
- buttonWidth={buttonWidth}
103
- numberColor={numberColor ?? themeValues.numberColor}
104
- type="prev"
105
- />
106
- )}
107
- {getPagesPanel(currentPage, pageCount).map((item, index) =>
108
- item.isButton ? (
109
- <Box padding="0" extraStyles={`max-height: ${buttonHeight};`}>
110
- <ButtonWithAction
111
- variant="ghost"
112
- key={item.index}
113
- text={item.index}
114
- disabled={item.active}
115
- applyDisabledStyles={applyActivePageDisabledStyles}
116
- action={
117
- !item.active
118
- ? () => setCurrentPage({ pageNumber: item.index })
119
- : noop
120
- }
121
- textExtraStyles={`font-size: ${fontSize}; font-weight: ${fontWeight};`}
122
- extraStyles={`
123
- ${
124
- item.active
125
- ? `border: ${activeBorderWidth} solid ${numberColor ??
126
- themeValues.numberColor};`
127
- : ""
128
- }
129
- min-width: ${buttonWidth}; min-height: 100%; padding: 0;
130
- border-radius: ${borderRadius};
131
- &:hover, &:focus {
132
- text-decoration: none;
133
- > * > span {
134
- text-decoration: none;
135
- }
136
- }
137
- > * > span {
138
- color: ${numberColor ?? themeValues.numberColor}
139
- }
140
- margin: 0;
141
- }
142
- &:hover { ${
143
- item.active
144
- ? `cursor: default;
145
- border: ${activeBorderWidth} solid ${numberColor ??
146
- themeValues.numberColor};
147
- > * > span {
148
- cursor: default;
149
- }`
150
- : `background-color: ${themeValues.hoverBackgroundColor}`
151
- } }
152
- `}
153
- dataQa={index}
154
- >
155
- {item.index}
156
- </ButtonWithAction>
157
- </Box>
158
- ) : (
159
- <Box padding="0 10px">
160
- <Cluster justify="flex-end">
161
- <Text
162
- key={index}
163
- variant="pXL"
164
- weight={fontWeight}
165
- color={numberColor ?? themeValues.numberColor}
166
- >
167
- {"..."}
168
- </Text>
169
- </Cluster>
170
- </Box>
171
- )
172
- )}
173
- {currentPage < pageCount && (
174
- <PrevNextButton
175
- action={pageNext}
176
- arrowColor={arrowColor ?? themeValues.arrowColor}
177
- borderRadius={borderRadius}
178
- buttonHeight={buttonHeight}
179
- buttonWidth={buttonWidth}
180
- numberColor={numberColor ?? themeValues.numberColor}
181
- type="next"
182
- />
183
- )}
184
- </Cluster>
185
- );
186
-
187
- export default themeComponent(Pagination, "Pagination", fallbackValues);