oneslash-design-system 1.2.9 → 1.2.11

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,4 +1,4 @@
1
- import { JSX } from 'react';
1
+ import React, { JSX } from 'react';
2
2
  interface MenuItemProps {
3
3
  href?: string;
4
4
  iconName?: string;
@@ -8,6 +8,12 @@ interface MenuItemProps {
8
8
  isSelected?: boolean;
9
9
  onClick?: any;
10
10
  className?: string;
11
+ size?: 'medium' | 'large';
12
+ tag?: {
13
+ label: React.ReactNode;
14
+ iconName?: string;
15
+ };
16
+ iconRight?: string;
11
17
  }
12
- export default function MenuItem({ href, iconName, userHandle, userImgUrl, label, isSelected, onClick, className, }: MenuItemProps): JSX.Element;
18
+ export default function MenuItem({ href, iconName, userHandle, userImgUrl, label, isSelected, onClick, className, size, tag, iconRight, }: MenuItemProps): JSX.Element;
13
19
  export {};
@@ -38,10 +38,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  import React, { useState, useEffect, useCallback } from 'react';
39
39
  import NextLink from 'next/link';
40
40
  import UserImage from './userImage';
41
+ import Tag from './tag';
41
42
  export default function MenuItem(_a) {
42
43
  var _this = this;
43
- var href = _a.href, iconName = _a.iconName, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, isSelected = _a.isSelected, onClick = _a.onClick, _b = _a.className, className = _b === void 0 ? '' : _b;
44
- var _c = useState(null), IconLeft = _c[0], setIconLeft = _c[1];
44
+ var href = _a.href, iconName = _a.iconName, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, isSelected = _a.isSelected, onClick = _a.onClick, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, tag = _a.tag, iconRight = _a.iconRight;
45
+ var _d = useState(null), IconLeft = _d[0], setIconLeft = _d[1];
46
+ var _e = useState(null), IconRight = _e[0], setIconRight = _e[1];
45
47
  var loadIcon = useCallback(function (iconName) { return __awaiter(_this, void 0, void 0, function () {
46
48
  var module_1, IconComponent, error_1;
47
49
  return __generator(this, function (_a) {
@@ -67,29 +69,47 @@ export default function MenuItem(_a) {
67
69
  }); }, []);
68
70
  useEffect(function () {
69
71
  var fetchIcon = function () { return __awaiter(_this, void 0, void 0, function () {
70
- var _a;
71
- return __generator(this, function (_b) {
72
- switch (_b.label) {
72
+ var _a, _b;
73
+ return __generator(this, function (_c) {
74
+ switch (_c.label) {
73
75
  case 0:
74
76
  if (!iconName) return [3 /*break*/, 2];
75
77
  _a = setIconLeft;
76
78
  return [4 /*yield*/, loadIcon(iconName)];
77
79
  case 1:
78
- _a.apply(void 0, [_b.sent()]);
79
- _b.label = 2;
80
- case 2: return [2 /*return*/];
80
+ _a.apply(void 0, [_c.sent()]);
81
+ _c.label = 2;
82
+ case 2:
83
+ if (!iconRight) return [3 /*break*/, 4];
84
+ _b = setIconRight;
85
+ return [4 /*yield*/, loadIcon(iconRight)];
86
+ case 3:
87
+ _b.apply(void 0, [_c.sent()]);
88
+ _c.label = 4;
89
+ case 4: return [2 /*return*/];
81
90
  }
82
91
  });
83
92
  }); };
84
93
  fetchIcon();
85
- }, [iconName, loadIcon]);
86
- var content = (<div className={"\n flex items-center space-x-2 p-2 rounded-[8px] cursor-pointer justify-start transition-colors duration-200 ease-in-out\n ".concat(isSelected
94
+ }, [iconName, iconRight, loadIcon]);
95
+ // Size-based icon and text classes
96
+ var iconSize = size === 'large' ? 'w-6 h-6' : 'w-5 h-5';
97
+ var labelClass = size === 'large' ? 'text-body1' : 'text-body2';
98
+ var tagSize = size === 'large' ? 'medium' : 'small';
99
+ var content = (<div className={"\n flex items-center p-2 rounded-[8px] cursor-pointer justify-between transition-colors duration-200 ease-in-out\n ".concat(isSelected
87
100
  ? 'bg-light-background-accent300 dark:bg-dark-background-accent300 hover:bg-light-background-accent200 dark:hover:bg-dark-background-accent200'
88
101
  : 'hover:bg-light-background-accent200 hover:dark:bg-dark-background-accent200', "\n ").concat(className, "\n ")} style={{ width: '100%' }} onClick={onClick}>
89
- {userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : (IconLeft && (<IconLeft className="w-6 h-6 text-light-text-secondary dark:text-dark-text-secondary"/>))}
90
- <span className="whitespace-nowrap text-body1 px-2 text-light-text-primary dark:text-dark-text-primary">
91
- {label}
92
- </span>
102
+ {/* Left group: icon/userImg + label + tag with 8px gap */}
103
+ <div className="flex items-center gap-1">
104
+ {userImgUrl ? (<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl}/>) : (IconLeft && (<IconLeft className={"".concat(iconSize, " text-light-text-secondary dark:text-dark-text-secondary")}/>))}
105
+ <span className={"whitespace-nowrap ".concat(labelClass, " text-light-text-primary dark:text-dark-text-primary")}>
106
+ {label}
107
+ </span>
108
+ {tag && (<Tag variant="contained" size={tagSize} label={tag.label} iconName={tag.iconName}/>)}
109
+ </div>
110
+
111
+ {/* Right icon aligned to the right */}
112
+ {IconRight && (<IconRight className={"".concat(iconSize, " text-light-text-secondary dark:text-dark-text-secondary flex-shrink-0")}/>)}
93
113
  </div>);
94
114
  return href ? <NextLink href={href}>{content}</NextLink> : content;
95
115
  }
@@ -7,7 +7,6 @@ interface TagProps {
7
7
  label: React.ReactNode;
8
8
  iconName?: keyof typeof HeroIcons;
9
9
  onClick?: React.MouseEventHandler<HTMLDivElement>;
10
- color?: 'default' | 'info';
11
10
  }
12
- export default function Tag({ variant, size, state, label, iconName, onClick, color, }: TagProps): JSX.Element;
11
+ export default function Tag({ variant, size, state, label, iconName, onClick, }: TagProps): JSX.Element;
13
12
  export {};
@@ -2,9 +2,9 @@
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import * as HeroIcons from '@heroicons/react/24/outline';
4
4
  export default function Tag(_a) {
5
- var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, label = _a.label, iconName = _a.iconName, onClick = _a.onClick, _c = _a.color, color = _c === void 0 ? 'default' : _c;
6
- var _d = useState(false), isHovered = _d[0], setIsHovered = _d[1];
7
- var _e = useState(null), Icon = _e[0], setIcon = _e[1];
5
+ var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, label = _a.label, iconName = _a.iconName, onClick = _a.onClick;
6
+ var _c = useState(false), isHovered = _c[0], setIsHovered = _c[1];
7
+ var _d = useState(null), Icon = _d[0], setIcon = _d[1];
8
8
  // Load icon directly from HeroIcons
9
9
  useEffect(function () {
10
10
  if (iconName) {
@@ -13,30 +13,30 @@ export default function Tag(_a) {
13
13
  }, [iconName]);
14
14
  // Size and padding
15
15
  var sizeClasses = size === 'medium' ? 'text-body2 px-2 py-1' : 'text-caption px-2 py-[3px]';
16
+ // Selected state styles
17
+ var isSelected = state === 'selected';
16
18
  // Background color
17
- var bgClasses = variant === 'contained'
18
- ? (color === 'info'
19
- ? 'bg-light-info-main dark:bg-dark-info-main'
20
- : 'bg-light-background-accent300 dark:bg-dark-background-accent300')
21
- : '';
19
+ var bgClasses = isSelected && variant === 'contained'
20
+ ? 'bg-light-accent-main dark:bg-dark-accent-main'
21
+ : variant === 'contained'
22
+ ? 'bg-light-background-accent300 dark:bg-dark-background-accent300'
23
+ : '';
22
24
  // Font color
23
- var fontClasses = variant === 'textOnly'
24
- ? (color === 'info'
25
- ? 'text-light-info-main dark:text-dark-info-main'
26
- : 'text-light-text-primary dark:text-dark-text-primary')
25
+ var fontClasses = isSelected
26
+ ? 'text-white'
27
27
  : 'text-light-text-primary dark:text-dark-text-primary';
28
- // Border for contained variant
29
- var borderClasses = variant === 'contained'
30
- ? 'border border-light-misc-divider dark:border-dark-misc-divider'
31
- : '';
32
- // State and hover
33
- var stateClasses = state === 'selected'
34
- ? 'bg-light-accent-main dark:bg-dark-accent-main text-white'
35
- : 'cursor-pointer';
36
- var hoverClasses = variant === 'contained' && isHovered
28
+ // Border styles
29
+ var borderClasses = isSelected && variant === 'textOnly'
30
+ ? 'border border-light-accent-main dark:border-dark-accent-main'
31
+ : variant === 'contained'
32
+ ? 'border border-light-misc-divider dark:border-dark-misc-divider'
33
+ : '';
34
+ // Hover (only when not selected and onClick is provided)
35
+ var hoverClasses = !isSelected && variant === 'contained' && isHovered && onClick
37
36
  ? 'bg-light-background-accent200 dark:bg-dark-background-accent200'
38
37
  : '';
39
- return (<div className={"\n flex items-center space-x-1 rounded-full \n ".concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(borderClasses, " ").concat(stateClasses, " ").concat(hoverClasses, "\n transition-colors duration-200 ease-in-out\n ")} onMouseEnter={function () { return setIsHovered(true); }} onMouseLeave={function () { return setIsHovered(false); }} onClick={onClick}>
38
+ var cursorClass = onClick && !isSelected ? 'cursor-pointer' : '';
39
+ return (<div className={"\n flex items-center space-x-1 rounded-full\n ".concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(borderClasses, " ").concat(hoverClasses, " ").concat(cursorClass, "\n transition-colors duration-200 ease-in-out\n ")} onMouseEnter={function () { return onClick && setIsHovered(true); }} onMouseLeave={function () { return onClick && setIsHovered(false); }} onClick={onClick}>
40
40
  {Icon && <Icon className="w-4 h-4"/>}
41
41
  <span>{label}</span>
42
42
  </div>);
package/dist/output.css CHANGED
@@ -708,6 +708,9 @@ video {
708
708
  .justify-between {
709
709
  justify-content: space-between;
710
710
  }
711
+ .gap-1 {
712
+ gap: 0.25rem;
713
+ }
711
714
  .gap-2 {
712
715
  gap: 0.5rem;
713
716
  }
@@ -973,10 +976,6 @@ video {
973
976
  --tw-text-opacity: 1;
974
977
  color: rgb(211 47 47 / var(--tw-text-opacity));
975
978
  }
976
- .text-light-info-main {
977
- --tw-text-opacity: 1;
978
- color: rgb(0 135 212 / var(--tw-text-opacity));
979
- }
980
979
  .text-light-text-contrast {
981
980
  --tw-text-opacity: 1;
982
981
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -1250,11 +1249,6 @@ body {
1250
1249
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
1251
1250
  }
1252
1251
 
1253
- .dark\:text-dark-info-main {
1254
- --tw-text-opacity: 1;
1255
- color: rgb(0 175 255 / var(--tw-text-opacity));
1256
- }
1257
-
1258
1252
  .dark\:text-dark-text-contrast {
1259
1253
  --tw-text-opacity: 1;
1260
1254
  color: rgb(0 0 0 / var(--tw-text-opacity));