@uqds/react 1.0.0-alpha.1
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/CHANGELOG.md +10 -0
- package/README.md +25 -0
- package/dist/css/main.css +1 -0
- package/dist/js/main.d.ts +122 -0
- package/dist/js/main.js +287 -0
- package/package.json +69 -0
- package/src/jsx/components/UqCard/UqCard.tsx +31 -0
- package/src/jsx/components/UqIcon/UqIcon.tsx +16 -0
- package/src/jsx/components/UqPagination/UqPagination.tsx +180 -0
- package/src/jsx/components/UqPagination/UqPaginationItem.tsx +55 -0
- package/src/jsx/components/UqPane/UqPane.tsx +34 -0
- package/src/jsx/components/UqStoryCard/UqStoryCard.tsx +38 -0
- package/src/jsx/enum/index.ts +42 -0
- package/src/jsx/layout/UqCardGrid/UqCardGrid.tsx +17 -0
- package/src/jsx/layout/UqContainer/UqContainer.tsx +7 -0
- package/src/jsx/main.tsx +21 -0
- package/src/scss/main.scss +7 -0
- package/tsconfig.json +23 -0
- package/vite.config.js +25 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { MouseEventHandler } from 'react';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export declare const UqCard: FC<UqCardProps>;
|
|
7
|
+
|
|
8
|
+
export declare const UqCardGrid: FC<UqCardGridProps>;
|
|
9
|
+
|
|
10
|
+
declare interface UqCardGridProps extends PropsWithChildren {
|
|
11
|
+
target?: UqCardGridTarget;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare enum UqCardGridTarget {
|
|
15
|
+
x1 = "1x",
|
|
16
|
+
x2 = "2x",
|
|
17
|
+
x3 = "3x",
|
|
18
|
+
x4 = "4x"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare interface UqCardProps {
|
|
22
|
+
title: ReactNode;
|
|
23
|
+
variant: UqCardVariant;
|
|
24
|
+
image?: ReactNode;
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare const enum UqCardVariant {
|
|
30
|
+
text = "text",
|
|
31
|
+
image = "image",
|
|
32
|
+
icon = "icon",
|
|
33
|
+
iconNav = "icon-nav"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare const UqContainer: FC<UqContainerProps>;
|
|
37
|
+
|
|
38
|
+
declare interface UqContainerProps extends PropsWithChildren {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare const UqIcon: FC<UqIconProps>;
|
|
42
|
+
|
|
43
|
+
declare interface UqIconProps {
|
|
44
|
+
name: string;
|
|
45
|
+
variant?: UqIconVariant;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare const enum UqIconVariant {
|
|
49
|
+
light = "light",
|
|
50
|
+
text = "text"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare const UqPagination: FC<UqPaginationProps>;
|
|
54
|
+
|
|
55
|
+
export declare const UqPaginationItem: FC<UqPaginationItemProps>;
|
|
56
|
+
|
|
57
|
+
declare interface UqPaginationItemProps {
|
|
58
|
+
As?: "button" | "a";
|
|
59
|
+
type?: UqPaginationItemType;
|
|
60
|
+
number?: number;
|
|
61
|
+
current?: boolean;
|
|
62
|
+
href?: string;
|
|
63
|
+
value?: string;
|
|
64
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare const enum UqPaginationItemType {
|
|
68
|
+
Previous = "previous",
|
|
69
|
+
Next = "next",
|
|
70
|
+
Ellipsis = "ellipsis"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare interface UqPaginationProps {
|
|
74
|
+
As?: "button" | "a";
|
|
75
|
+
totalResults: number;
|
|
76
|
+
resultsPerPage: number;
|
|
77
|
+
currentPage: number;
|
|
78
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export declare const UqPane: FC<UqPaneProps>;
|
|
82
|
+
|
|
83
|
+
declare interface UqPaneProps {
|
|
84
|
+
title: string;
|
|
85
|
+
variant: UqPaneVariant;
|
|
86
|
+
image?: ReactNode;
|
|
87
|
+
icon?: ReactNode;
|
|
88
|
+
video?: ReactNode;
|
|
89
|
+
description?: ReactNode;
|
|
90
|
+
links?: ReactNode;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export declare const enum UqPaneVariant {
|
|
94
|
+
text = "text",
|
|
95
|
+
image = "image",
|
|
96
|
+
video = "video",
|
|
97
|
+
icon = "icon",
|
|
98
|
+
iconLarge = "icon-large",
|
|
99
|
+
textShaded = "text-shaded",
|
|
100
|
+
iconShaded = "icon-shaded"
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export declare const UqStoryCard: FC<UqStoryCardProps>;
|
|
104
|
+
|
|
105
|
+
declare interface UqStoryCardProps {
|
|
106
|
+
title: ReactNode;
|
|
107
|
+
variant: UqStoryCardVariant;
|
|
108
|
+
image?: ReactNode;
|
|
109
|
+
description?: ReactNode;
|
|
110
|
+
topLabel: string;
|
|
111
|
+
bottomLabel: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export declare const enum UqStoryCardVariant {
|
|
115
|
+
story = "story",
|
|
116
|
+
news = "news",
|
|
117
|
+
event = "event",
|
|
118
|
+
landscape = "landscape",
|
|
119
|
+
feature = "feature"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { }
|
package/dist/js/main.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { jsx as a, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as f } from "react";
|
|
3
|
+
const B = ({ children: e }) => /* @__PURE__ */ a("div", { className: "uq-container", children: e });
|
|
4
|
+
function y(e) {
|
|
5
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
|
+
}
|
|
7
|
+
var x = { exports: {} };
|
|
8
|
+
/*!
|
|
9
|
+
Copyright (c) 2018 Jed Watson.
|
|
10
|
+
Licensed under the MIT License (MIT), see
|
|
11
|
+
http://jedwatson.github.io/classnames
|
|
12
|
+
*/
|
|
13
|
+
var q;
|
|
14
|
+
function w() {
|
|
15
|
+
return q || (q = 1, function(e) {
|
|
16
|
+
(function() {
|
|
17
|
+
var i = {}.hasOwnProperty;
|
|
18
|
+
function r() {
|
|
19
|
+
for (var s = "", t = 0; t < arguments.length; t++) {
|
|
20
|
+
var m = arguments[t];
|
|
21
|
+
m && (s = c(s, n(m)));
|
|
22
|
+
}
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
function n(s) {
|
|
26
|
+
if (typeof s == "string" || typeof s == "number")
|
|
27
|
+
return s;
|
|
28
|
+
if (typeof s != "object")
|
|
29
|
+
return "";
|
|
30
|
+
if (Array.isArray(s))
|
|
31
|
+
return r.apply(null, s);
|
|
32
|
+
if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]"))
|
|
33
|
+
return s.toString();
|
|
34
|
+
var t = "";
|
|
35
|
+
for (var m in s)
|
|
36
|
+
i.call(s, m) && s[m] && (t = c(t, m));
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
function c(s, t) {
|
|
40
|
+
return t ? s ? s + " " + t : s + t : s;
|
|
41
|
+
}
|
|
42
|
+
e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
|
|
43
|
+
})();
|
|
44
|
+
}(x)), x.exports;
|
|
45
|
+
}
|
|
46
|
+
var E = w();
|
|
47
|
+
const v = /* @__PURE__ */ y(E);
|
|
48
|
+
var g = /* @__PURE__ */ ((e) => (e.text = "text", e.image = "image", e.icon = "icon", e.iconNav = "icon-nav", e))(g || {}), S = /* @__PURE__ */ ((e) => (e.x1 = "1x", e.x2 = "2x", e.x3 = "3x", e.x4 = "4x", e))(S || {}), j = /* @__PURE__ */ ((e) => (e.light = "light", e.text = "text", e))(j || {}), d = /* @__PURE__ */ ((e) => (e.Previous = "previous", e.Next = "next", e.Ellipsis = "ellipsis", e))(d || {}), M = /* @__PURE__ */ ((e) => (e.text = "text", e.image = "image", e.video = "video", e.icon = "icon", e.iconLarge = "icon-large", e.textShaded = "text-shaded", e.iconShaded = "icon-shaded", e))(M || {}), O = /* @__PURE__ */ ((e) => (e.story = "story", e.news = "news", e.event = "event", e.landscape = "landscape", e.feature = "feature", e))(O || {});
|
|
49
|
+
const H = ({ children: e, target: i }) => /* @__PURE__ */ a(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: v("uq-card-grid", {
|
|
53
|
+
[`uq-card-grid--target-${i}`]: i
|
|
54
|
+
}),
|
|
55
|
+
children: e
|
|
56
|
+
}
|
|
57
|
+
), $ = ({ name: e, variant: i }) => /* @__PURE__ */ a(
|
|
58
|
+
"span",
|
|
59
|
+
{
|
|
60
|
+
className: v("uq-icon", `uq-icon--${e}`, {
|
|
61
|
+
[`uq-icon--${i}`]: i
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
), J = ({
|
|
65
|
+
image: e,
|
|
66
|
+
icon: i,
|
|
67
|
+
title: r,
|
|
68
|
+
description: n,
|
|
69
|
+
variant: c
|
|
70
|
+
}) => /* @__PURE__ */ u(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: v("uq-card", `uq-card--${c}`),
|
|
74
|
+
"data-gtm-category": "Card",
|
|
75
|
+
children: [
|
|
76
|
+
e && /* @__PURE__ */ a("div", { className: "uq-card__image", children: e }),
|
|
77
|
+
/* @__PURE__ */ u("div", { className: "uq-card__content", children: [
|
|
78
|
+
i && /* @__PURE__ */ a("div", { className: "uq-card__icon", children: i }),
|
|
79
|
+
/* @__PURE__ */ a("h3", { className: "uq-card__title", children: r }),
|
|
80
|
+
n && /* @__PURE__ */ a("div", { className: "uq-card__description", children: n })
|
|
81
|
+
] })
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
), K = ({
|
|
85
|
+
image: e,
|
|
86
|
+
icon: i,
|
|
87
|
+
title: r,
|
|
88
|
+
description: n,
|
|
89
|
+
variant: c,
|
|
90
|
+
links: s,
|
|
91
|
+
video: t
|
|
92
|
+
}) => /* @__PURE__ */ u("div", { className: v("uq-pane", `uq-pane--${c}`), children: [
|
|
93
|
+
e && /* @__PURE__ */ a("div", { className: "uq-pane__image", children: e }),
|
|
94
|
+
t && /* @__PURE__ */ a("div", { className: "uq-pane__video", children: t }),
|
|
95
|
+
/* @__PURE__ */ u("div", { className: "uq-pane__content", children: [
|
|
96
|
+
i && /* @__PURE__ */ a("div", { className: "uq-pane__icon", children: i }),
|
|
97
|
+
/* @__PURE__ */ a("h3", { className: "uq-pane__title", children: r }),
|
|
98
|
+
n && /* @__PURE__ */ a("div", { className: "uq-pane__description", children: n }),
|
|
99
|
+
s && /* @__PURE__ */ a("div", { className: "uq-pane__actions", children: s })
|
|
100
|
+
] })
|
|
101
|
+
] }), L = ({
|
|
102
|
+
image: e,
|
|
103
|
+
title: i,
|
|
104
|
+
description: r,
|
|
105
|
+
variant: n,
|
|
106
|
+
topLabel: c,
|
|
107
|
+
bottomLabel: s
|
|
108
|
+
}) => /* @__PURE__ */ u(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: v("uq-story-card", `uq-story-card--${n}`),
|
|
112
|
+
"data-gtm-category": "StoryCard",
|
|
113
|
+
children: [
|
|
114
|
+
e && /* @__PURE__ */ a("div", { className: "uq-story-card__image", children: e }),
|
|
115
|
+
/* @__PURE__ */ u("div", { className: "uq-story-card__content", children: [
|
|
116
|
+
c && /* @__PURE__ */ a("div", { className: "uq-story-card__top-label", children: c }),
|
|
117
|
+
/* @__PURE__ */ a("h3", { className: "uq-story-card__title", children: i }),
|
|
118
|
+
r && /* @__PURE__ */ a("div", { className: "uq-story-card__description", children: r }),
|
|
119
|
+
s && /* @__PURE__ */ a("div", { className: "uq-story-card__bottom-label", children: s })
|
|
120
|
+
] })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
), h = ({
|
|
124
|
+
As: e = "button",
|
|
125
|
+
type: i,
|
|
126
|
+
number: r,
|
|
127
|
+
current: n = !1,
|
|
128
|
+
href: c,
|
|
129
|
+
value: s,
|
|
130
|
+
onClick: t
|
|
131
|
+
}) => /* @__PURE__ */ a("li", { className: "uq-pagination__list-item", children: /* @__PURE__ */ u(
|
|
132
|
+
e,
|
|
133
|
+
{
|
|
134
|
+
className: v("uq-pagination__item", {
|
|
135
|
+
[`uq-pagination__${i}`]: i,
|
|
136
|
+
"uq-pagination__current": n
|
|
137
|
+
}),
|
|
138
|
+
"aria-current": n && "page",
|
|
139
|
+
onClick: t,
|
|
140
|
+
href: c,
|
|
141
|
+
value: s,
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ u("span", { className: "visually-hidden", children: [
|
|
144
|
+
!i && "Page",
|
|
145
|
+
i === d.Previous && "Previous page",
|
|
146
|
+
i === d.Next && "Previous page",
|
|
147
|
+
i === d.Ellipsis && `Skip to page ${r}`
|
|
148
|
+
] }),
|
|
149
|
+
!i && `${r}`,
|
|
150
|
+
i === d.Previous && /* @__PURE__ */ a($, { name: "standard--chevron-left" }),
|
|
151
|
+
i === d.Next && /* @__PURE__ */ a($, { name: "standard--chevron-right" }),
|
|
152
|
+
i === d.Ellipsis && "…"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
) }), Q = ({
|
|
156
|
+
As: e = "button",
|
|
157
|
+
totalResults: i,
|
|
158
|
+
resultsPerPage: r,
|
|
159
|
+
currentPage: n,
|
|
160
|
+
onClick: c
|
|
161
|
+
}) => {
|
|
162
|
+
const s = f(
|
|
163
|
+
() => Math.ceil(i / r),
|
|
164
|
+
[i, r]
|
|
165
|
+
), t = f(() => {
|
|
166
|
+
const l = [];
|
|
167
|
+
if (!i || r >= i)
|
|
168
|
+
return l;
|
|
169
|
+
if (Math.ceil(i / r) < 6 || n > s) {
|
|
170
|
+
let o = 2;
|
|
171
|
+
for (; o < s; )
|
|
172
|
+
l.push(o), o += 1;
|
|
173
|
+
return l;
|
|
174
|
+
}
|
|
175
|
+
if (n === 1) {
|
|
176
|
+
let o = 2;
|
|
177
|
+
for (; o < 5; )
|
|
178
|
+
l.push(o), o += 1;
|
|
179
|
+
return l;
|
|
180
|
+
}
|
|
181
|
+
if (n === s) {
|
|
182
|
+
let o = s - 3;
|
|
183
|
+
for (; o < s; )
|
|
184
|
+
l.push(o), o += 1;
|
|
185
|
+
return l;
|
|
186
|
+
}
|
|
187
|
+
let p = Math.max(n - 1, 2), _ = Math.min(n + 1, s - 1);
|
|
188
|
+
p === 2 && (_ = p + 2), _ === s - 1 && (p = _ - 2);
|
|
189
|
+
let N = p;
|
|
190
|
+
for (; N <= _; )
|
|
191
|
+
l.push(N), N += 1;
|
|
192
|
+
return l;
|
|
193
|
+
}, [i, s, r, n]), m = f(
|
|
194
|
+
() => t.length !== 0 && t[0] !== 2,
|
|
195
|
+
[t]
|
|
196
|
+
), b = f(
|
|
197
|
+
() => t.length !== 0 && t[t.length - 1] !== s - 1,
|
|
198
|
+
[t, s]
|
|
199
|
+
);
|
|
200
|
+
return /* @__PURE__ */ a("nav", { className: "uq-pagination", "aria-label": "Pagination", children: /* @__PURE__ */ u("ul", { className: "uq-pagination__list", children: [
|
|
201
|
+
n !== 1 && /* @__PURE__ */ a(
|
|
202
|
+
h,
|
|
203
|
+
{
|
|
204
|
+
As: e,
|
|
205
|
+
type: d.Previous,
|
|
206
|
+
onClick: c,
|
|
207
|
+
value: `${n - 1}`
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
/* @__PURE__ */ a(
|
|
211
|
+
h,
|
|
212
|
+
{
|
|
213
|
+
As: e,
|
|
214
|
+
number: 1,
|
|
215
|
+
current: n === 1,
|
|
216
|
+
onClick: c,
|
|
217
|
+
value: "1"
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
m && /* @__PURE__ */ a(
|
|
221
|
+
h,
|
|
222
|
+
{
|
|
223
|
+
As: e,
|
|
224
|
+
type: d.Ellipsis,
|
|
225
|
+
value: `${n - 3}`,
|
|
226
|
+
number: n - 3,
|
|
227
|
+
onClick: c
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
t.map((l) => /* @__PURE__ */ a(
|
|
231
|
+
h,
|
|
232
|
+
{
|
|
233
|
+
As: e,
|
|
234
|
+
number: l,
|
|
235
|
+
current: n === l,
|
|
236
|
+
onClick: c,
|
|
237
|
+
value: `${l}`
|
|
238
|
+
},
|
|
239
|
+
l.toString()
|
|
240
|
+
)),
|
|
241
|
+
b && /* @__PURE__ */ a(
|
|
242
|
+
h,
|
|
243
|
+
{
|
|
244
|
+
As: e,
|
|
245
|
+
type: d.Ellipsis,
|
|
246
|
+
value: `${n + 3}`,
|
|
247
|
+
number: n + 3,
|
|
248
|
+
onClick: c
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
s > 1 && /* @__PURE__ */ a(
|
|
252
|
+
h,
|
|
253
|
+
{
|
|
254
|
+
As: e,
|
|
255
|
+
number: s,
|
|
256
|
+
current: n === s,
|
|
257
|
+
onClick: c,
|
|
258
|
+
value: `${s}`
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
n !== s && /* @__PURE__ */ a(
|
|
262
|
+
h,
|
|
263
|
+
{
|
|
264
|
+
As: e,
|
|
265
|
+
type: d.Next,
|
|
266
|
+
onClick: c,
|
|
267
|
+
value: `${n + 1}`
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
] }) });
|
|
271
|
+
};
|
|
272
|
+
export {
|
|
273
|
+
J as UqCard,
|
|
274
|
+
H as UqCardGrid,
|
|
275
|
+
S as UqCardGridTarget,
|
|
276
|
+
g as UqCardVariant,
|
|
277
|
+
B as UqContainer,
|
|
278
|
+
$ as UqIcon,
|
|
279
|
+
j as UqIconVariant,
|
|
280
|
+
Q as UqPagination,
|
|
281
|
+
h as UqPaginationItem,
|
|
282
|
+
d as UqPaginationItemType,
|
|
283
|
+
K as UqPane,
|
|
284
|
+
M as UqPaneVariant,
|
|
285
|
+
L as UqStoryCard,
|
|
286
|
+
O as UqStoryCardVariant
|
|
287
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uqds/react",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"description": "React components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"uqds",
|
|
7
|
+
"uq",
|
|
8
|
+
"University of Queensland",
|
|
9
|
+
"design system",
|
|
10
|
+
"scss",
|
|
11
|
+
"sass",
|
|
12
|
+
"css",
|
|
13
|
+
"accordion",
|
|
14
|
+
"react"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "University of Queensland",
|
|
21
|
+
"email": "webservices@uq.edu.au",
|
|
22
|
+
"url": "https://uq.edu.au"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/uq-its-ss/design-system#readme",
|
|
25
|
+
"license": "ISC",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/js/main.js"
|
|
30
|
+
},
|
|
31
|
+
"./src/jsx/*": "./src/jsx/*",
|
|
32
|
+
"./src/scss/*": "./src/scss/*"
|
|
33
|
+
},
|
|
34
|
+
"style": "dist/css/main.css",
|
|
35
|
+
"main": "dist/js/main.js",
|
|
36
|
+
"types": "dist/js/main.d.ts",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/uq-its-ss/design-system.git"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"prepare": "gulp -f ../../gulpfile.js --cwd=. prepare && vite build",
|
|
43
|
+
"lint-tsc": "tsc"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/uq-its-ss/design-system/issues"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@uqds/body": "^3.0.0-alpha.0",
|
|
50
|
+
"@uqds/card": "^3.0.0-alpha.1",
|
|
51
|
+
"@uqds/core": "^4.0.0-alpha.0",
|
|
52
|
+
"@uqds/icon": "^3.0.0-alpha.0",
|
|
53
|
+
"@uqds/layout": "6.0.0-alpha.0",
|
|
54
|
+
"@uqds/pagination": "^3.0.0-alpha.0",
|
|
55
|
+
"@uqds/pane": "^3.0.0-alpha.0",
|
|
56
|
+
"classnames": "^2.5.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/react": "^18.3.18",
|
|
60
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
61
|
+
"typescript": "^5.7.3",
|
|
62
|
+
"vite": "^6.0.11",
|
|
63
|
+
"vite-plugin-dts": "^4.5.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"react": "^18.3.1"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "3cbffaa8ca0d7ab54ae1908bdd5feb5f05ecc5d2"
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FC, ReactNode } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { UqCardVariant } from "../../enum";
|
|
4
|
+
|
|
5
|
+
export interface UqCardProps {
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
variant: UqCardVariant;
|
|
8
|
+
image?: ReactNode;
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const UqCard: FC<UqCardProps> = ({
|
|
14
|
+
image,
|
|
15
|
+
icon,
|
|
16
|
+
title,
|
|
17
|
+
description,
|
|
18
|
+
variant,
|
|
19
|
+
}) => (
|
|
20
|
+
<div
|
|
21
|
+
className={classNames("uq-card", `uq-card--${variant}`)}
|
|
22
|
+
data-gtm-category="Card"
|
|
23
|
+
>
|
|
24
|
+
{image && <div className="uq-card__image">{image}</div>}
|
|
25
|
+
<div className="uq-card__content">
|
|
26
|
+
{icon && <div className="uq-card__icon">{icon}</div>}
|
|
27
|
+
<h3 className="uq-card__title">{title}</h3>
|
|
28
|
+
{description && <div className="uq-card__description">{description}</div>}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { UqIconVariant } from "../../enum";
|
|
4
|
+
|
|
5
|
+
export interface UqIconProps {
|
|
6
|
+
name: string;
|
|
7
|
+
variant?: UqIconVariant;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const UqIcon: FC<UqIconProps> = ({ name, variant }) => (
|
|
11
|
+
<span
|
|
12
|
+
className={classNames("uq-icon", `uq-icon--${name}`, {
|
|
13
|
+
[`uq-icon--${variant}`]: variant,
|
|
14
|
+
})}
|
|
15
|
+
></span>
|
|
16
|
+
);
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { type FC, type MouseEventHandler, useMemo } from "react";
|
|
2
|
+
import { UqPaginationItem } from "./UqPaginationItem";
|
|
3
|
+
import { UqPaginationItemType } from "../../enum";
|
|
4
|
+
|
|
5
|
+
export interface UqPaginationProps {
|
|
6
|
+
As?: "button" | "a";
|
|
7
|
+
totalResults: number;
|
|
8
|
+
resultsPerPage: number;
|
|
9
|
+
currentPage: number;
|
|
10
|
+
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const UqPagination: FC<UqPaginationProps> = ({
|
|
14
|
+
As = "button",
|
|
15
|
+
totalResults,
|
|
16
|
+
resultsPerPage,
|
|
17
|
+
currentPage,
|
|
18
|
+
onClick,
|
|
19
|
+
}) => {
|
|
20
|
+
/**
|
|
21
|
+
* The last page is the totalResults / resultsPerPage, rounded up.
|
|
22
|
+
*/
|
|
23
|
+
const lastPage = useMemo<number>(
|
|
24
|
+
() => Math.ceil(totalResults / resultsPerPage),
|
|
25
|
+
[totalResults, resultsPerPage],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create an array representation of the visible pages.
|
|
30
|
+
*/
|
|
31
|
+
const visiblePages = useMemo<number[]>(() => {
|
|
32
|
+
const pages: number[] = [];
|
|
33
|
+
|
|
34
|
+
// If there's only 1 visible page go no further.
|
|
35
|
+
if (!totalResults || resultsPerPage >= totalResults) {
|
|
36
|
+
return pages;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const totalPages = Math.ceil(totalResults / resultsPerPage);
|
|
40
|
+
|
|
41
|
+
// Show all pages.
|
|
42
|
+
// Do this if there are less than 6 pages,
|
|
43
|
+
// or if incorrect props have been passed down.
|
|
44
|
+
if (totalPages < 6 || currentPage > lastPage) {
|
|
45
|
+
let marker = 2;
|
|
46
|
+
while (marker < lastPage) {
|
|
47
|
+
pages.push(marker);
|
|
48
|
+
marker += 1;
|
|
49
|
+
}
|
|
50
|
+
return pages;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Show up to page 4 if we are on the first page.
|
|
54
|
+
if (currentPage === 1) {
|
|
55
|
+
let marker = 2;
|
|
56
|
+
while (marker < 5) {
|
|
57
|
+
pages.push(marker);
|
|
58
|
+
marker += 1;
|
|
59
|
+
}
|
|
60
|
+
return pages;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Show the last 4 pages if we are on the last page.
|
|
64
|
+
if (currentPage === lastPage) {
|
|
65
|
+
let marker = lastPage - 3;
|
|
66
|
+
while (marker < lastPage) {
|
|
67
|
+
pages.push(marker);
|
|
68
|
+
marker += 1;
|
|
69
|
+
}
|
|
70
|
+
return pages;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Show the current page plus and minus 1 page.
|
|
74
|
+
let start = Math.max(currentPage - 1, 2);
|
|
75
|
+
let end = Math.min(currentPage + 1, lastPage - 1);
|
|
76
|
+
// Unless we are on page 2, then show plus 2 pages.
|
|
77
|
+
if (start === 2) {
|
|
78
|
+
end = start + 2;
|
|
79
|
+
}
|
|
80
|
+
// Unless we are on the second last page, then show minus 2 pages.
|
|
81
|
+
if (end === lastPage - 1) {
|
|
82
|
+
start = end - 2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Build the array of visible pages.
|
|
86
|
+
let marker = start;
|
|
87
|
+
while (marker <= end) {
|
|
88
|
+
pages.push(marker);
|
|
89
|
+
marker += 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return pages;
|
|
93
|
+
}, [totalResults, lastPage, resultsPerPage, currentPage]);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The first ellipsis will show if the first visible page is > 2.
|
|
97
|
+
*/
|
|
98
|
+
const showFirstEllipsis = useMemo<boolean>(
|
|
99
|
+
() => visiblePages.length !== 0 && visiblePages[0] !== 2,
|
|
100
|
+
[visiblePages],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The last ellipsis will show if the last visible page is -1 less than the
|
|
105
|
+
* last page.
|
|
106
|
+
*/
|
|
107
|
+
const showLastEllipsis = useMemo<boolean>(
|
|
108
|
+
() =>
|
|
109
|
+
visiblePages.length !== 0 &&
|
|
110
|
+
visiblePages[visiblePages.length - 1] !== lastPage - 1,
|
|
111
|
+
[visiblePages, lastPage],
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<nav className="uq-pagination" aria-label="Pagination">
|
|
116
|
+
<ul className="uq-pagination__list">
|
|
117
|
+
{currentPage !== 1 && (
|
|
118
|
+
<UqPaginationItem
|
|
119
|
+
As={As}
|
|
120
|
+
type={UqPaginationItemType.Previous}
|
|
121
|
+
onClick={onClick}
|
|
122
|
+
value={`${currentPage - 1}`}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
<UqPaginationItem
|
|
126
|
+
As={As}
|
|
127
|
+
number={1}
|
|
128
|
+
current={currentPage === 1}
|
|
129
|
+
onClick={onClick}
|
|
130
|
+
value="1"
|
|
131
|
+
/>
|
|
132
|
+
{showFirstEllipsis && (
|
|
133
|
+
<UqPaginationItem
|
|
134
|
+
As={As}
|
|
135
|
+
type={UqPaginationItemType.Ellipsis}
|
|
136
|
+
value={`${currentPage - 3}`}
|
|
137
|
+
number={currentPage - 3}
|
|
138
|
+
onClick={onClick}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
{visiblePages.map((page) => (
|
|
142
|
+
<UqPaginationItem
|
|
143
|
+
As={As}
|
|
144
|
+
key={page.toString()}
|
|
145
|
+
number={page}
|
|
146
|
+
current={currentPage === page}
|
|
147
|
+
onClick={onClick}
|
|
148
|
+
value={`${page}`}
|
|
149
|
+
/>
|
|
150
|
+
))}
|
|
151
|
+
{showLastEllipsis && (
|
|
152
|
+
<UqPaginationItem
|
|
153
|
+
As={As}
|
|
154
|
+
type={UqPaginationItemType.Ellipsis}
|
|
155
|
+
value={`${currentPage + 3}`}
|
|
156
|
+
number={currentPage + 3}
|
|
157
|
+
onClick={onClick}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
{lastPage > 1 && (
|
|
161
|
+
<UqPaginationItem
|
|
162
|
+
As={As}
|
|
163
|
+
number={lastPage}
|
|
164
|
+
current={currentPage === lastPage}
|
|
165
|
+
onClick={onClick}
|
|
166
|
+
value={`${lastPage}`}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
169
|
+
{currentPage !== lastPage && (
|
|
170
|
+
<UqPaginationItem
|
|
171
|
+
As={As}
|
|
172
|
+
type={UqPaginationItemType.Next}
|
|
173
|
+
onClick={onClick}
|
|
174
|
+
value={`${currentPage + 1}`}
|
|
175
|
+
/>
|
|
176
|
+
)}
|
|
177
|
+
</ul>
|
|
178
|
+
</nav>
|
|
179
|
+
);
|
|
180
|
+
};
|