@iabbb/bds-react 0.38.0-alpha.0
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/README.md +17 -0
- package/dist/Button/Button.js +53 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/index.js +4 -0
- package/dist/Button/index.js.map +1 -0
- package/dist/CallToAction/CallToAction.js +20 -0
- package/dist/CallToAction/CallToAction.js.map +1 -0
- package/dist/CallToAction/index.js +4 -0
- package/dist/CallToAction/index.js.map +1 -0
- package/dist/ErrorSummary/ErrorSummary.js +242 -0
- package/dist/ErrorSummary/ErrorSummary.js.map +1 -0
- package/dist/ErrorSummary/index.js +4 -0
- package/dist/ErrorSummary/index.js.map +1 -0
- package/dist/FieldTextInput/FieldTextInput.js +48 -0
- package/dist/FieldTextInput/FieldTextInput.js.map +1 -0
- package/dist/FieldTextInput/index.js +4 -0
- package/dist/FieldTextInput/index.js.map +1 -0
- package/dist/Pagination/Pagination.js +93 -0
- package/dist/Pagination/Pagination.js.map +1 -0
- package/dist/Pagination/index.js +4 -0
- package/dist/Pagination/index.js.map +1 -0
- package/dist/README.md +0 -0
- package/dist/Typography/Typography.js +37 -0
- package/dist/Typography/Typography.js.map +1 -0
- package/dist/Typography/index.js +4 -0
- package/dist/Typography/index.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-4a7b2c14.js +291 -0
- package/dist/_rollupPluginBabelHelpers-4a7b2c14.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-4a841245.js +291 -0
- package/dist/_rollupPluginBabelHelpers-4a841245.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-faf45dab.js +303 -0
- package/dist/_rollupPluginBabelHelpers-faf45dab.js.map +1 -0
- package/dist/bds-react.js +9 -0
- package/dist/bds-react.js.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +33 -0
- package/package.json +35 -0
- package/rollup.config.mjs +36 -0
- package/src/Button/Button.js +54 -0
- package/src/Button/index.js +1 -0
- package/src/CallToAction/CallToAction.js +18 -0
- package/src/CallToAction/index.js +1 -0
- package/src/ErrorSummary/ErrorSummary.js +66 -0
- package/src/ErrorSummary/index.js +2 -0
- package/src/FieldTextInput/FieldTextInput.js +50 -0
- package/src/FieldTextInput/index.js +1 -0
- package/src/Pagination/Pagination.js +107 -0
- package/src/Pagination/index.js +1 -0
- package/src/Typography/Typography.js +34 -0
- package/src/Typography/index.js +1 -0
- package/src/index.js +6 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// import clsx from 'clsx';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
function usePages(currentPage, totalPages) {
|
|
5
|
+
const pages = [1, currentPage - 1, currentPage, currentPage + 1, totalPages].filter(
|
|
6
|
+
(x) => x >= 1 && x <= totalPages,
|
|
7
|
+
);
|
|
8
|
+
return [...new Set(pages)];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function Pagination({ buildPageUrl, className, currentPage, onPageClick, totalPages, ...props }) {
|
|
12
|
+
const pages = usePages(currentPage, totalPages);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<nav
|
|
16
|
+
aria-label="pagination"
|
|
17
|
+
// className={clsx('bds-pagination', className)}
|
|
18
|
+
className="bds-pagination"
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
{currentPage !== 1 && (
|
|
22
|
+
<>
|
|
23
|
+
<a href={buildPageUrl(1)} className="bds-first-page">
|
|
24
|
+
<svg
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
focusable="false"
|
|
28
|
+
height="1em"
|
|
29
|
+
width="auto"
|
|
30
|
+
viewBox="0 63.95 512 384.1"
|
|
31
|
+
>
|
|
32
|
+
<path d="M459.5 440.6c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29V96c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4L288 214.3v83.4l171.5 142.9zM256 352V96c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4l-192 160C4.2 237.5 0 246.5 0 256s4.2 18.5 11.5 24.6l192 160c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29v-64z" />
|
|
33
|
+
</svg>
|
|
34
|
+
First
|
|
35
|
+
</a>
|
|
36
|
+
<a aria-label="previous" href={buildPageUrl(currentPage - 1)} rel="prev">
|
|
37
|
+
<svg
|
|
38
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
focusable="false"
|
|
41
|
+
width="auto"
|
|
42
|
+
height="1em"
|
|
43
|
+
viewBox="0.02 95.9 192.08 320.17"
|
|
44
|
+
>
|
|
45
|
+
<path d="M9.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l128-128c9.2-9.2 22.9-11.9 34.9-6.9s19.8 16.6 19.8 29.6v256c0 12.9-7.8 24.6-19.8 29.6s-25.7 2.2-34.9-6.9l-128-128z" />
|
|
46
|
+
</svg>
|
|
47
|
+
Prev.
|
|
48
|
+
</a>
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
51
|
+
<ul>
|
|
52
|
+
{pages.map((page, index) => {
|
|
53
|
+
const handlePageClick = () => {
|
|
54
|
+
if (!onPageClick) return;
|
|
55
|
+
|
|
56
|
+
onPageClick(page);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<React.Fragment key={page}>
|
|
61
|
+
<li>
|
|
62
|
+
<a
|
|
63
|
+
aria-current={page === currentPage ? 'page' : undefined}
|
|
64
|
+
href={buildPageUrl(page)}
|
|
65
|
+
onClick={handlePageClick}
|
|
66
|
+
>
|
|
67
|
+
<span className="visually-hidden">Page</span> {page}
|
|
68
|
+
</a>
|
|
69
|
+
</li>
|
|
70
|
+
{pages[index + 1] > page + 1 ? <li data-overflow="">...</li> : null}
|
|
71
|
+
</React.Fragment>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</ul>
|
|
75
|
+
{currentPage !== totalPages && (
|
|
76
|
+
<>
|
|
77
|
+
<a href={buildPageUrl(currentPage + 1)} rel="next">
|
|
78
|
+
Next
|
|
79
|
+
<svg
|
|
80
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
81
|
+
aria-hidden="true"
|
|
82
|
+
focusable="false"
|
|
83
|
+
viewBox="63.9 95.9 192.1 320.17"
|
|
84
|
+
width="auto"
|
|
85
|
+
height="1em"
|
|
86
|
+
>
|
|
87
|
+
<path d="M246.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9S63.9 115 63.9 128v256c0 12.9 7.8 24.6 19.8 29.6s25.7 2.2 34.9-6.9l128-128z" />
|
|
88
|
+
</svg>
|
|
89
|
+
</a>
|
|
90
|
+
<a href={buildPageUrl(totalPages)} className="bds-last-page">
|
|
91
|
+
Last
|
|
92
|
+
<svg
|
|
93
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
94
|
+
aria-hidden="true"
|
|
95
|
+
focusable="false"
|
|
96
|
+
width="auto"
|
|
97
|
+
height="1em"
|
|
98
|
+
viewBox="0 63.95 512 384.1"
|
|
99
|
+
>
|
|
100
|
+
<path d="M52.5 440.6c-9.5 7.9-22.8 9.7-34.1 4.4S0 428.4 0 416V96c0-12.4 7.2-23.7 18.4-29s24.5-3.6 34.1 4.4L224 214.3v83.4L52.5 440.6zM256 352V96c0-12.4 7.2-23.7 18.4-29s24.5-3.6 34.1 4.4l192 160c7.3 6.1 11.5 15.1 11.5 24.6s-4.2 18.5-11.5 24.6l-192 160c-9.5 7.9-22.8 9.7-34.1 4.4S256 428.4 256 416v-64z" />
|
|
101
|
+
</svg>
|
|
102
|
+
</a>
|
|
103
|
+
</>
|
|
104
|
+
)}
|
|
105
|
+
</nav>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Pagination';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// import clsx from 'clsx';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
const componentMap = {
|
|
5
|
+
h1: 'h1',
|
|
6
|
+
h2: 'h2',
|
|
7
|
+
h3: 'h3',
|
|
8
|
+
h4: 'h4',
|
|
9
|
+
h5: 'h5',
|
|
10
|
+
body: 'p',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const classMap = {
|
|
14
|
+
h1: 'bds-h1',
|
|
15
|
+
h2: 'bds-h2',
|
|
16
|
+
h3: 'bds-h3',
|
|
17
|
+
h4: 'bds-h4',
|
|
18
|
+
h5: 'bds-h5',
|
|
19
|
+
body: 'bds-body',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Typography = React.forwardRef(({ className, component, variant = 'body', ...props }, ref) => {
|
|
23
|
+
const Component = component ?? componentMap[variant];
|
|
24
|
+
return (
|
|
25
|
+
<Component
|
|
26
|
+
// className={clsx(classMap[variant], className)}
|
|
27
|
+
className={classMap[variant]}
|
|
28
|
+
ref={ref}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default Typography;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Typography';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Button } from './Button/index';
|
|
2
|
+
export { default as CallToAction } from './CallToAction/index';
|
|
3
|
+
export { default as ErrorSummary } from './ErrorSummary/index';
|
|
4
|
+
export { default as FieldTextInput } from './FieldTextInput/index';
|
|
5
|
+
export { default as Pagination } from './Pagination/index';
|
|
6
|
+
export { default as Typography } from './Typography/index';
|