@mbpockets/shared-ui 0.1.19 → 0.1.20

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,14 +1,13 @@
1
1
  "use client";
2
- import { Card, CardContent, Typography, CardMedia } from '@mui/material';
2
+ import { Card, CardContent, Typography, CardMedia, CardHeader, TextField, useTheme, useMediaQuery, NoSsr, Box, Grid } from '@mui/material';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
- import { useState, useEffect } from 'react';
5
- import Grid from '@mui/material/Grid';
6
- import Card4 from '@mui/material/Card';
7
- import CardHeader from '@mui/material/CardHeader';
8
- import CardContent4 from '@mui/material/CardContent';
4
+ import { useState, useEffect, useMemo } from 'react';
5
+ import Autocomplete from '@mui/material/Autocomplete';
6
+ import Popper from '@mui/material/Popper';
9
7
 
10
8
  // src/components/PlayerPage/PlayerDetailsCard.tsx
11
- var PlayerDetails = ({
9
+ var PlayerDetailsCard = ({
10
+ preferredPronouns,
12
11
  age,
13
12
  yearsPlaying,
14
13
  discordUsername,
@@ -58,6 +57,23 @@ var PlayerDetails = ({
58
57
  }
59
58
  ),
60
59
  /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
60
+ preferredPronouns && /* @__PURE__ */ jsxs(
61
+ Typography,
62
+ {
63
+ variant: "body2",
64
+ className: "text-sm font-medium",
65
+ sx: {
66
+ color: "#FFFFFF",
67
+ textShadow: "0px 2px 6px rgba(0, 0, 0, 0.5)",
68
+ fontWeight: "bold"
69
+ },
70
+ children: [
71
+ /* @__PURE__ */ jsx("span", { className: "font-extrabold text-cyan-300", children: "Preferred Pronouns:" }),
72
+ " ",
73
+ preferredPronouns
74
+ ]
75
+ }
76
+ ),
61
77
  age !== null && /* @__PURE__ */ jsxs(
62
78
  Typography,
63
79
  {
@@ -109,7 +125,7 @@ var PlayerDetails = ({
109
125
  ]
110
126
  }
111
127
  ),
112
- preferredGames && preferredGames.length > 0 && /* @__PURE__ */ jsxs(
128
+ preferredGames && /* @__PURE__ */ jsxs(
113
129
  Typography,
114
130
  {
115
131
  variant: "body2",
@@ -122,7 +138,7 @@ var PlayerDetails = ({
122
138
  children: [
123
139
  /* @__PURE__ */ jsx("span", { className: "font-extrabold text-cyan-300", children: "Preferred Games:" }),
124
140
  " ",
125
- preferredGames.join(", ")
141
+ Array.isArray(preferredGames) ? preferredGames.join(", ") : preferredGames
126
142
  ]
127
143
  }
128
144
  )
@@ -145,24 +161,20 @@ var PlayerDetails = ({
145
161
  }
146
162
  );
147
163
  };
148
- var PlayerDetailsCard_default = PlayerDetails;
164
+ var PlayerDetailsCard_default = PlayerDetailsCard;
149
165
 
150
166
  // src/data/values.tsx
151
167
  var ProfilePictureSettings = {
152
168
  aspectRatio: 4 / 5};
153
- var { aspectRatio } = ProfilePictureSettings;
154
- var PlayerDisplayCard = ({
155
- profilePicture,
156
- username,
157
- bio,
158
- preferredPronouns
159
- }) => {
160
- const [imageSrc, setImageSrc] = useState("/man-walking-silhouette-clipart.jpg");
169
+ var PlayerDisplayCard = ({ profilePicture, username, bio, preferredPronouns }) => {
170
+ const defaultImg = "/man-walking-silhouette-clipart.jpg";
171
+ const [imageSrc, setImageSrc] = useState(defaultImg);
172
+ const { aspectRatio } = ProfilePictureSettings;
161
173
  useEffect(() => {
162
174
  async function validateImage() {
163
- const newImage = profilePicture || "/man-walking-silhouette-clipart.jpg";
175
+ const newImage = profilePicture || defaultImg;
164
176
  if (!profilePicture) {
165
- setImageSrc("/man-walking-silhouette-clipart.jpg");
177
+ setImageSrc(defaultImg);
166
178
  return;
167
179
  }
168
180
  const img = new Image();
@@ -171,7 +183,7 @@ var PlayerDisplayCard = ({
171
183
  setImageSrc(newImage);
172
184
  };
173
185
  img.onerror = () => {
174
- setImageSrc("/man-walking-silhouette-clipart.jpg");
186
+ setImageSrc(defaultImg);
175
187
  };
176
188
  }
177
189
  validateImage();
@@ -205,7 +217,7 @@ var PlayerDisplayCard = ({
205
217
  height: "auto",
206
218
  // Updates to maintain aspect ratio and fill space nicely
207
219
  width: "100%",
208
- objectFit: "scale-down"
220
+ objectFit: "cover"
209
221
  }
210
222
  }
211
223
  ),
@@ -264,61 +276,6 @@ var PlayerDisplayCard = ({
264
276
  );
265
277
  };
266
278
  var PlayerDisplayCard_default = PlayerDisplayCard;
267
- var PlayerPromptCard = ({ title, description }) => {
268
- return /* @__PURE__ */ jsx(
269
- Card,
270
- {
271
- sx: {
272
- margin: "1rem",
273
- background: "linear-gradient(135deg, rgba(25, 118, 210, 0.8), rgba(25, 118, 210, 1))",
274
- // Gradient color scheme
275
- boxShadow: "0px 8px 15px rgba(25, 118, 210, 0.3)",
276
- // Card shadow
277
- borderRadius: "12px",
278
- // Rounded corners
279
- color: "#FFFFFF",
280
- // Text contrast with the background
281
- overflow: "hidden"
282
- // Keeps consistent and clean card shape
283
- },
284
- className: "transition duration-300 transform hover:scale-105 hover:shadow-2xl",
285
- children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6", children: [
286
- title && /* @__PURE__ */ jsx(
287
- Typography,
288
- {
289
- variant: "h5",
290
- className: "font-bold text-lg uppercase text-center tracking-wide mb-4",
291
- sx: {
292
- color: "#FFFFFF",
293
- // Bright white for high visibility
294
- textShadow: "0px 3px 6px rgba(0, 0, 0, 0.5)",
295
- // Strong text shadow for contrast
296
- fontSize: "1.5rem"
297
- },
298
- children: title
299
- }
300
- ),
301
- description && /* @__PURE__ */ jsx(
302
- Typography,
303
- {
304
- variant: "body2",
305
- className: "text-sm font-medium text-center",
306
- sx: {
307
- color: "#E3F2FD",
308
- // Softer light blue for description
309
- textShadow: "0px 2px 4px rgba(0, 0, 0, 0.3)",
310
- // Subtle shadow
311
- lineHeight: 1.6,
312
- marginTop: "1rem"
313
- },
314
- children: description
315
- }
316
- )
317
- ] })
318
- }
319
- );
320
- };
321
- var PlayerPromptCard_default = PlayerPromptCard;
322
279
  function Chip({ tag, removeCallback }) {
323
280
  var _a;
324
281
  const color = (_a = tag.color) != null ? _a : "#bfbcbb";
@@ -351,23 +308,263 @@ function Chip({ tag, removeCallback }) {
351
308
  tag.id
352
309
  ) });
353
310
  }
354
- function PlayerTagsCard(props) {
355
- return /* @__PURE__ */ jsx(Grid, { container: true, children: /* @__PURE__ */ jsx(Grid, { size: { xs: 12, md: 3 }, children: /* @__PURE__ */ jsxs(Card4, { children: [
356
- /* @__PURE__ */ jsx(CardHeader, { title: "Player Tags", style: {
311
+ var PlayerTagsCard = ({ tags = [] }) => {
312
+ return /* @__PURE__ */ jsxs(Card, { sx: {
313
+ margin: "1rem",
314
+ borderRadius: "12px",
315
+ boxShadow: "0px 8px 15px rgba(25, 118, 210, 0.3)",
316
+ overflow: "hidden"
317
+ }, className: "transition duration-300 transform hover:scale-105 hover:shadow-2xl", children: [
318
+ /* @__PURE__ */ jsx(
319
+ CardHeader,
320
+ {
321
+ title: "Player Tags",
322
+ sx: {
323
+ background: "linear-gradient(135deg, rgba(25, 118, 210, 0.8), rgba(25, 118, 210, 1))",
324
+ color: "#FFFFFF",
325
+ fontSize: "1.5rem",
326
+ textShadow: "0px 3px 6px rgba(0, 0, 0, 0.5)",
327
+ "& .MuiCardHeader-title": {
328
+ fontWeight: "bold",
329
+ fontSize: "1.5rem",
330
+ textAlign: "center",
331
+ textTransform: "uppercase",
332
+ letterSpacing: "0.05em"
333
+ }
334
+ }
335
+ }
336
+ ),
337
+ /* @__PURE__ */ jsx(CardContent, { className: "p-6", children: /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: tags.map((tag) => /* @__PURE__ */ jsx(Chip, { tag }, tag.id)) }) })
338
+ ] });
339
+ };
340
+ var PlayerTagsCard_default = PlayerTagsCard;
341
+ var PlayerPromptCard = ({ title, description }) => /* @__PURE__ */ jsx(
342
+ Card,
343
+ {
344
+ sx: {
345
+ margin: "1rem",
357
346
  background: "linear-gradient(135deg, rgba(25, 118, 210, 0.8), rgba(25, 118, 210, 1))",
347
+ // Gradient color scheme
348
+ boxShadow: "0px 8px 15px rgba(25, 118, 210, 0.3)",
349
+ // Card shadow
350
+ borderRadius: "12px",
351
+ // Rounded corners
358
352
  color: "#FFFFFF",
359
- // Pure white for username
360
- fontSize: "1.5rem",
361
- textShadow: "0px 3px 6px rgba(0, 0, 0, 0.5)"
362
- // Strong shadow for visibility
363
- } }),
364
- /* @__PURE__ */ jsx(CardContent4, { children: renderLabels(props.PlayerTags) })
353
+ // Text contrast with the background
354
+ overflow: "hidden"
355
+ // Keeps consistent and clean card shape
356
+ },
357
+ className: "transition duration-300 transform hover:scale-105 hover:shadow-2xl",
358
+ children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6", children: [
359
+ title && /* @__PURE__ */ jsx(
360
+ Typography,
361
+ {
362
+ variant: "h5",
363
+ className: "font-bold text-lg uppercase text-center tracking-wide mb-4",
364
+ sx: {
365
+ color: "#FFFFFF",
366
+ // Bright white for high visibility
367
+ textShadow: "0px 3px 6px rgba(0, 0, 0, 0.5)",
368
+ // Strong text shadow for contrast
369
+ fontSize: "1.5rem"
370
+ },
371
+ children: title
372
+ }
373
+ ),
374
+ description && /* @__PURE__ */ jsx(
375
+ Typography,
376
+ {
377
+ variant: "body2",
378
+ className: "text-sm font-medium text-center",
379
+ sx: {
380
+ color: "#E3F2FD",
381
+ // Softer light blue for description
382
+ textShadow: "0px 2px 4px rgba(0, 0, 0, 0.3)",
383
+ // Subtle shadow
384
+ lineHeight: 1.6,
385
+ marginTop: "1rem"
386
+ },
387
+ children: description
388
+ }
389
+ )
390
+ ] })
391
+ }
392
+ );
393
+ var PlayerPromptCard_default = PlayerPromptCard;
394
+ var PlayerTagsEdit = ({
395
+ selectedTags = [],
396
+ possibleTags = [],
397
+ onToggleTag
398
+ }) => {
399
+ const [inputValue, setInputValue] = useState("");
400
+ const selectedIds = useMemo(() => selectedTags.map((tag) => tag.id), [selectedTags]);
401
+ const options = useMemo(
402
+ () => possibleTags.map((tag) => ({ value: tag.id, label: tag.label, alternate_title: tag.alternate_title })),
403
+ [possibleTags]
404
+ );
405
+ return /* @__PURE__ */ jsxs(Card, { sx: {
406
+ margin: "1rem",
407
+ borderRadius: "12px",
408
+ boxShadow: "0px 8px 15px rgba(25, 118, 210, 0.3)",
409
+ overflow: "hidden"
410
+ }, children: [
411
+ /* @__PURE__ */ jsx(
412
+ CardHeader,
413
+ {
414
+ title: "Player Tags",
415
+ sx: {
416
+ background: "linear-gradient(135deg, rgba(25, 118, 210, 0.8), rgba(25, 118, 210, 1))",
417
+ color: "#FFFFFF",
418
+ fontSize: "1.5rem",
419
+ textShadow: "0px 3px 6px rgba(0, 0, 0, 0.5)",
420
+ "& .MuiCardHeader-title": {
421
+ fontWeight: "bold",
422
+ fontSize: "1.5rem",
423
+ textAlign: "center",
424
+ textTransform: "uppercase",
425
+ letterSpacing: "0.05em"
426
+ }
427
+ }
428
+ }
429
+ ),
430
+ /* @__PURE__ */ jsxs(CardContent, { className: "p-6", children: [
431
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 mb-4", children: selectedTags.map((tag) => /* @__PURE__ */ jsx(
432
+ Chip,
433
+ {
434
+ tag,
435
+ removeCallback: () => onToggleTag(tag.id)
436
+ },
437
+ tag.id
438
+ )) }),
439
+ /* @__PURE__ */ jsx(
440
+ Autocomplete,
441
+ {
442
+ options,
443
+ filterOptions: (availableOptions, state) => {
444
+ const query = state.inputValue.toLowerCase();
445
+ return availableOptions.filter(
446
+ (option) => {
447
+ var _a;
448
+ return !selectedIds.includes(option.value) && (option.label.toLowerCase().includes(query) || ((_a = option.alternate_title) == null ? void 0 : _a.some((title) => title.toLowerCase().includes(query))));
449
+ }
450
+ ).slice(0, 5);
451
+ },
452
+ value: null,
453
+ inputValue,
454
+ onInputChange: (event, newInputValue) => {
455
+ if (event && event.type === "change") {
456
+ setInputValue(newInputValue);
457
+ }
458
+ },
459
+ onChange: (event, newValue) => {
460
+ if (newValue) {
461
+ onToggleTag(newValue.value);
462
+ }
463
+ setInputValue("");
464
+ },
465
+ slots: { popper: CustomPopper },
466
+ renderInput: (params) => /* @__PURE__ */ jsx(
467
+ TextField,
468
+ {
469
+ ...params,
470
+ label: "Select Tags",
471
+ variant: "outlined"
472
+ }
473
+ )
474
+ },
475
+ selectedIds.join("-")
476
+ )
477
+ ] })
478
+ ] });
479
+ };
480
+ var CustomPopper = (props) => {
481
+ return /* @__PURE__ */ jsx(
482
+ Popper,
483
+ {
484
+ ...props,
485
+ modifiers: [
486
+ {
487
+ name: "preventOverflow",
488
+ options: {
489
+ boundary: "viewport"
490
+ }
491
+ },
492
+ {
493
+ name: "offset",
494
+ options: {
495
+ offset: [0, -10]
496
+ }
497
+ }
498
+ ],
499
+ placement: "top-start"
500
+ }
501
+ );
502
+ };
503
+ var PlayerTagsEdit_default = PlayerTagsEdit;
504
+ function PlayerPageLayout({
505
+ playerData,
506
+ tags = [],
507
+ blurbs = [],
508
+ isOwner = false,
509
+ possibleTags = [],
510
+ onToggleTag = () => {
511
+ }
512
+ }) {
513
+ const theme = useTheme();
514
+ const isSmallScreen = useMediaQuery(theme.breakpoints.down("lg"));
515
+ const tagsElement = isOwner ? /* @__PURE__ */ jsx(
516
+ PlayerTagsEdit_default,
517
+ {
518
+ selectedTags: tags,
519
+ possibleTags,
520
+ onToggleTag
521
+ }
522
+ ) : /* @__PURE__ */ jsx(PlayerTagsCard_default, { tags });
523
+ return /* @__PURE__ */ jsx(NoSsr, { children: /* @__PURE__ */ jsx(Box, { sx: { padding: "2rem", marginRight: "auto", marginLeft: "auto" }, justifyContent: "center", children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 3, justifyContent: "center", sx: { marginRight: "auto", marginLeft: "auto" }, children: [
524
+ !isSmallScreen && /* @__PURE__ */ jsxs(Grid, { size: { xs: 12, lg: 3 }, children: [
525
+ /* @__PURE__ */ jsx(
526
+ PlayerDetailsCard_default,
527
+ {
528
+ preferredPronouns: playerData.preferredPronouns,
529
+ age: playerData.age,
530
+ yearsPlaying: playerData.yearsPlaying,
531
+ discordUsername: playerData.discordUsername,
532
+ preferredGames: playerData.preferredGames
533
+ }
534
+ ),
535
+ tagsElement
536
+ ] }),
537
+ /* @__PURE__ */ jsx(Grid, { size: { xs: 12, lg: 6 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 3, children: [
538
+ /* @__PURE__ */ jsx(Grid, { size: { xs: 12, lg: 8 }, children: /* @__PURE__ */ jsx(
539
+ PlayerDisplayCard_default,
540
+ {
541
+ profilePicture: playerData.profilePicture,
542
+ username: playerData.username,
543
+ bio: playerData.bio,
544
+ preferredPronouns: playerData.preferredPronouns
545
+ }
546
+ ) }),
547
+ isSmallScreen && /* @__PURE__ */ jsx(Grid, { size: { xs: 12, lg: 3 }, children: /* @__PURE__ */ jsx(
548
+ PlayerDetailsCard_default,
549
+ {
550
+ preferredPronouns: playerData.preferredPronouns,
551
+ age: playerData.age,
552
+ yearsPlaying: playerData.yearsPlaying,
553
+ discordUsername: playerData.discordUsername,
554
+ preferredGames: playerData.preferredGames
555
+ }
556
+ ) }),
557
+ blurbs.map((blurb, index) => /* @__PURE__ */ jsx(Grid, { size: { xs: 12, lg: 8 }, children: /* @__PURE__ */ jsx(
558
+ PlayerPromptCard_default,
559
+ {
560
+ title: blurb.title,
561
+ description: blurb.description
562
+ }
563
+ ) }, index))
564
+ ] }) })
365
565
  ] }) }) });
366
566
  }
367
- var renderLabels = (tags) => {
368
- return /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: tags.map((tag) => /* @__PURE__ */ jsx(Chip, { tag }, tag.id)) });
369
- };
370
567
 
371
- export { PlayerDetailsCard_default as PlayerDetailsCard, PlayerDisplayCard_default as PlayerDisplayCard, PlayerPromptCard_default as PlayerPromptCard, PlayerTagsCard };
568
+ export { PlayerDetailsCard_default as PlayerDetailsCard, PlayerDisplayCard_default as PlayerDisplayCard, PlayerPageLayout, PlayerPromptCard_default as PlayerPromptCard, PlayerTagsCard_default as PlayerTagsCard, PlayerTagsEdit_default as PlayerTagsEdit };
372
569
  //# sourceMappingURL=PlayerPage.mjs.map
373
570
  //# sourceMappingURL=PlayerPage.mjs.map