@nualang/nualang-ui-components 0.1.1428 → 0.1.1430

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.
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import PropTypes from "prop-types";
3
- import { Typography, Box, IconButton, Tooltip, Skeleton, Select, MenuItem, FormControl, InputLabel } from "@mui/material";
3
+ import { Typography, Box, IconButton, Tooltip, Skeleton, MenuItem, TextField } from "@mui/material";
4
4
  import AssignmentCard from "../AssignmentCard/AssignmentCard";
5
5
  import Refresh from "@mui/icons-material/Refresh";
6
6
  import TeacherCreate from "../../img/teacher-create-2.svg";
@@ -199,32 +199,27 @@ const AssignmentCardsList = ({
199
199
  display: "flex",
200
200
  justifyContent: "space-between",
201
201
  alignItems: "center",
202
- mb: 3,
203
- mt: "8px"
202
+ mb: 1
204
203
  },
205
- children: [/*#__PURE__*/_jsxs(FormControl, {
206
- size: "large",
204
+ children: [/*#__PURE__*/_jsxs(TextField, {
205
+ select: true,
206
+ size: "small",
207
+ variant: "outlined",
208
+ label: t("view"),
209
+ value: filter,
210
+ onChange: e => setFilter(e.target.value),
207
211
  sx: {
208
- minWidth: 140,
209
- marginTop: 1
212
+ minWidth: 150
210
213
  },
211
- children: [/*#__PURE__*/_jsx(InputLabel, {
212
- children: t("view")
213
- }), /*#__PURE__*/_jsxs(Select, {
214
- value: filter,
215
- onChange: e => setFilter(e.target.value),
216
- label: t("view"),
217
- autoWidth: true,
218
- children: [/*#__PURE__*/_jsx(MenuItem, {
219
- value: "all",
220
- children: t("all")
221
- }), /*#__PURE__*/_jsx(MenuItem, {
222
- value: "pastDue",
223
- children: t("past_due")
224
- }), /*#__PURE__*/_jsx(MenuItem, {
225
- value: "scheduled",
226
- children: t("scheduled")
227
- })]
214
+ children: [/*#__PURE__*/_jsx(MenuItem, {
215
+ value: "all",
216
+ children: t("all")
217
+ }), /*#__PURE__*/_jsx(MenuItem, {
218
+ value: "pastDue",
219
+ children: t("past_due")
220
+ }), /*#__PURE__*/_jsx(MenuItem, {
221
+ value: "scheduled",
222
+ children: t("scheduled")
228
223
  })]
229
224
  }), /*#__PURE__*/_jsx(Tooltip, {
230
225
  placement: "left",
@@ -291,32 +286,27 @@ const AssignmentCardsList = ({
291
286
  display: "flex",
292
287
  justifyContent: isCreator ? "space-between" : "flex-end",
293
288
  alignItems: "center",
294
- mb: 3,
295
- mt: "8px"
289
+ mb: 1
296
290
  },
297
- children: [isCreator && /*#__PURE__*/_jsxs(FormControl, {
298
- size: "large",
291
+ children: [isCreator && /*#__PURE__*/_jsxs(TextField, {
292
+ select: true,
293
+ size: "small",
294
+ variant: "outlined",
295
+ label: t("view"),
296
+ value: filter,
297
+ onChange: e => setFilter(e.target.value),
299
298
  sx: {
300
- minWidth: 140,
301
- marginTop: 1
299
+ minWidth: 150
302
300
  },
303
- children: [/*#__PURE__*/_jsx(InputLabel, {
304
- children: t("view")
305
- }), /*#__PURE__*/_jsxs(Select, {
306
- value: filter,
307
- onChange: e => setFilter(e.target.value),
308
- label: t("view"),
309
- autoWidth: true,
310
- children: [/*#__PURE__*/_jsx(MenuItem, {
311
- value: "all",
312
- children: t("all")
313
- }), /*#__PURE__*/_jsx(MenuItem, {
314
- value: "pastDue",
315
- children: t("past_due")
316
- }), /*#__PURE__*/_jsx(MenuItem, {
317
- value: "scheduled",
318
- children: t("scheduled")
319
- })]
301
+ children: [/*#__PURE__*/_jsx(MenuItem, {
302
+ value: "all",
303
+ children: t("all")
304
+ }), /*#__PURE__*/_jsx(MenuItem, {
305
+ value: "pastDue",
306
+ children: t("past_due")
307
+ }), /*#__PURE__*/_jsx(MenuItem, {
308
+ value: "scheduled",
309
+ children: t("scheduled")
320
310
  })]
321
311
  }), /*#__PURE__*/_jsx(Tooltip, {
322
312
  placement: "left",
@@ -1,6 +1,9 @@
1
+ import { useRef } from "react";
1
2
  import PropTypes from "prop-types";
2
3
  import Typography from "@mui/material/Typography";
4
+ import Tooltip from "@mui/material/Tooltip";
3
5
  import { styled } from "@mui/system";
6
+ import useIsTruncated from "../../../hooks/useIsTruncated";
4
7
  import { jsx as _jsx } from "react/jsx-runtime";
5
8
  const StyledCardTitle = styled(Typography)(({
6
9
  theme
@@ -13,13 +16,20 @@ function CardTitle({
13
16
  component = "h3",
14
17
  compact = false
15
18
  }) {
16
- return /*#__PURE__*/_jsx(StyledCardTitle, {
17
- variant: compact ? "subtitle2" : "subtitle1",
18
- component: component,
19
- compact: compact,
20
- noWrap: true,
21
- "aria-label": title,
22
- children: title
19
+ const titleRef = useRef(null);
20
+ const isTruncated = useIsTruncated(titleRef, [title]);
21
+ return /*#__PURE__*/_jsx(Tooltip, {
22
+ title: title,
23
+ disableHoverListener: !isTruncated,
24
+ children: /*#__PURE__*/_jsx(StyledCardTitle, {
25
+ ref: titleRef,
26
+ variant: compact ? "subtitle2" : "subtitle1",
27
+ component: component,
28
+ compact: compact,
29
+ noWrap: true,
30
+ "aria-label": title,
31
+ children: title
32
+ })
23
33
  });
24
34
  }
25
35
  CardTitle.propTypes = {
@@ -10,7 +10,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  function CardVisibility({
11
11
  t = text => text,
12
12
  visibility = "",
13
- isCourseHidden = false
13
+ isCourseHidden = false,
14
+ compact = false
14
15
  }) {
15
16
  const isPublic = visibility === "public";
16
17
  let icon;
@@ -31,6 +32,22 @@ function CardVisibility({
31
32
  });
32
33
  color = "secondary";
33
34
  }
35
+
36
+ // Compact cards use a smaller pill (24px tall, 12px radius, 14px icon, 6px
37
+ // inset) so the badge doesn't overwhelm the shorter media band.
38
+ const compactSx = compact ? {
39
+ bottom: "6px",
40
+ right: "6px",
41
+ height: "24px",
42
+ borderRadius: "12px",
43
+ fontSize: "11px",
44
+ "& .MuiChip-icon": {
45
+ fontSize: "14px"
46
+ }
47
+ } : {
48
+ bottom: "8px",
49
+ right: "8px"
50
+ };
34
51
  return /*#__PURE__*/_jsxs(Box, {
35
52
  sx: {
36
53
  position: "relative"
@@ -42,8 +59,6 @@ function CardVisibility({
42
59
  sx: theme => ({
43
60
  border: "1px solid",
44
61
  position: "absolute",
45
- bottom: "8px",
46
- right: "8px",
47
62
  fontWeight: "bold",
48
63
  textTransform: "capitalize",
49
64
  pointerEvents: "none",
@@ -51,7 +66,8 @@ function CardVisibility({
51
66
  backgroundColor: isPublic ? theme.palette.success.dark : theme.palette.mode === "light" ? blue[700] : blue[500],
52
67
  ...(theme.palette.mode === "light" && {
53
68
  color: "white"
54
- })
69
+ }),
70
+ ...compactSx
55
71
  })
56
72
  }), isCourseHidden && /*#__PURE__*/_jsx(Chip, {
57
73
  color: "success",
@@ -75,6 +91,7 @@ function CardVisibility({
75
91
  });
76
92
  }
77
93
  CardVisibility.propTypes = {
78
- visibility: PropTypes.string.isRequired
94
+ visibility: PropTypes.string.isRequired,
95
+ compact: PropTypes.bool
79
96
  };
80
97
  export default CardVisibility;
@@ -42,7 +42,8 @@ const CardAvatarImg = styled(Avatar)(({
42
42
  }));
43
43
  const CardAvatar = props => {
44
44
  const {
45
- badgeSize = "default"
45
+ badgeSize = "default",
46
+ compact = false
46
47
  } = props;
47
48
  const passDownProps = {
48
49
  ...props
@@ -50,11 +51,15 @@ const CardAvatar = props => {
50
51
  delete passDownProps.badgeSize;
51
52
  delete passDownProps.verificationStatus;
52
53
  delete passDownProps.gameAward;
54
+ delete passDownProps.compact;
53
55
  return /*#__PURE__*/_jsxs(Box, {
54
56
  sx: theme => ({
55
57
  position: "absolute",
56
- bottom: theme.spacing(-3),
57
- left: theme.spacing(2)
58
+ // Compact cards use a smaller avatar with a tighter overlap over the
59
+ // media band (18px overlap, 12px inset) instead of the default's
60
+ // theme-spaced offsets.
61
+ bottom: compact ? "-18px" : theme.spacing(-3),
62
+ left: compact ? "12px" : theme.spacing(2)
58
63
  }),
59
64
  children: [/*#__PURE__*/_jsx(CardAvatarImg, {
60
65
  ...passDownProps
@@ -1,4 +1,4 @@
1
- import { useState } from "react";
1
+ import { useState, useRef } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { useInView } from "react-intersection-observer";
4
4
  import { Button, Box, Typography, IconButton, Menu, MenuItem, Tooltip, CardActions, CardActionArea, Divider, CircularProgress } from "@mui/material";
@@ -15,6 +15,7 @@ import { capitalize } from "../../utils/index";
15
15
  import PlaceholderImages from "../../utils/placeholder-images/index";
16
16
  import ProgressiveCardMedia from "../../Misc/ProgressiveCardMedia/ProgressiveCardMedia";
17
17
  import useClassroomState from "../../hooks/useClassroomState";
18
+ import useIsTruncated from "../../hooks/useIsTruncated";
18
19
  import { classes, CardContainer, CardAvatar, CardHeader, CardTitle, CardSubheader, CardInfoSection, CardDescription, CardTop, CardContent, CardMenuIcon, CardVisibility } from "../CardElements";
19
20
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
20
21
  function OverflowMenu({
@@ -184,6 +185,8 @@ function ClassroomCard({
184
185
  createdByName,
185
186
  visibility
186
187
  } = classroom;
188
+ const descriptionRef = useRef(null);
189
+ const isDescriptionTruncated = useIsTruncated(descriptionRef, [description]);
187
190
  const viewClassroom = () => {
188
191
  handleViewClassroom(classroom.classroomId);
189
192
  };
@@ -323,20 +326,25 @@ function ClassroomCard({
323
326
  flexGrow: 1
324
327
  }
325
328
  })]
326
- }), /*#__PURE__*/_jsx(CardDescription, {
327
- variant: compact ? "caption" : "body2",
328
- color: "textSecondary",
329
- component: "p",
330
- sx: compact ? {
331
- height: "auto",
332
- lineHeight: 1.4,
333
- display: "-webkit-box",
334
- WebkitLineClamp: 2,
335
- WebkitBoxOrient: "vertical",
336
- overflow: "hidden",
337
- marginBottom: 1
338
- } : {},
339
- children: description
329
+ }), /*#__PURE__*/_jsx(Tooltip, {
330
+ title: description,
331
+ disableHoverListener: !compact || !isDescriptionTruncated,
332
+ children: /*#__PURE__*/_jsx(CardDescription, {
333
+ ref: compact ? descriptionRef : undefined,
334
+ variant: compact ? "caption" : "body2",
335
+ color: "textSecondary",
336
+ component: "p",
337
+ sx: compact ? {
338
+ height: "auto",
339
+ lineHeight: 1.4,
340
+ display: "-webkit-box",
341
+ WebkitLineClamp: 2,
342
+ WebkitBoxOrient: "vertical",
343
+ overflow: "hidden",
344
+ marginBottom: 1
345
+ } : {},
346
+ children: description
347
+ })
340
348
  })]
341
349
  }), !compact && /*#__PURE__*/_jsxs(CardActions, {
342
350
  children: [isCreator && /*#__PURE__*/_jsx(Button, {