oneslash-design-system 1.1.32 → 1.1.34

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.
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import React from 'react';
3
+
4
+ interface TableCellProps{
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export default function TableCell({children}: TableCellProps) {
9
+
10
+ return (
11
+ <div className="flex-1 p-2 text-body2 text-light-text-primary dark:text-dark-text-primary border-t border-light-misc-divider dark:border-dark-misc-divider">
12
+ {children}
13
+ </div>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import React from 'react';
3
+
4
+ interface TableContainerProps{
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export default function TableContainer({children}: TableContainerProps) {
9
+
10
+ return (
11
+ <div className="w-full overflow-x-auto bg-light-background-default dark:bg-dark-background-default">
12
+ {children}
13
+ </div>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import React from 'react';
3
+
4
+ interface TableHeaderProps{
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export default function TableHeader({children}: TableHeaderProps) {
9
+
10
+ return (
11
+ <div className="py-2 bg-light-background-default dark:bg-dark-background-default">
12
+ {children}
13
+ </div>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import React from 'react';
3
+
4
+ interface TableHeaderCellProps{
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export default function TableHeaderCell({children}: TableHeaderCellProps) {
9
+
10
+ return (
11
+ <div className="flex-1 p-2 text-body2 text-light-text-primary dark:text-dark-text-primary">
12
+ {children}
13
+ </div>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import React from 'react';
3
+
4
+ interface TableRowProps{
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export default function TableRow({children}: TableRowProps) {
9
+
10
+ return (
11
+ <div className="flex w-full">
12
+ {children}
13
+ </div>
14
+ );
15
+ };
@@ -6,18 +6,48 @@ interface UserImageProps {
6
6
  userImgUrl?: string;
7
7
  }
8
8
 
9
- export default function UserImage({
10
- userHandle,
11
- userImgUrl,
12
- }: UserImageProps) {
9
+ function getColorSeed(userHandle: string): string {
10
+ const words = userHandle.trim().split(/\s+/);
11
+ let letters = words.map(word => word.charAt(0).toLowerCase());
12
+ if (letters.length === 1 && words[0].length >= 2) {
13
+ letters.push(words[0].charAt(1).toLowerCase());
14
+ } else if (letters.length > 2) {
15
+ letters = letters.slice(0, 2);
16
+ } else if (letters.length === 0) {
17
+ letters = ['x', 'x'];
18
+ }
19
+ return letters.join('');
20
+ }
21
+
22
+ function getHash(str: string): number {
23
+ let hash = 0;
24
+ for (let i = 0; i < str.length; i++) {
25
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
26
+ }
27
+ return hash;
28
+ }
29
+
30
+ export default function UserImage({
31
+ userHandle,
32
+ userImgUrl,
33
+ }: UserImageProps) {
34
+ const displayInitial = userHandle.charAt(0).toUpperCase() || 'A';
35
+ const seed = getColorSeed(userHandle);
36
+ const hue = Math.abs(getHash(seed)) % 360;
13
37
 
14
- const defaultInitial = userHandle.charAt(0).toUpperCase();
38
+ // Light mode: vibrant pastel
39
+ const lightBg = `hsl(${hue}, 80%, 80%)`;
40
+ // Dark mode: darker, vibrant variant
41
+ const darkBg = `hsl(${hue}, 80%, 30%)`;
15
42
 
16
43
  return (
17
- <div
18
- className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden
19
- bg-light-background-accent200 dark:bg-dark-background-accent200
20
- text-light-text-secondary dark:text-dark-text-secondary ">
44
+ <div
45
+ style={{
46
+ '--light-bg': lightBg,
47
+ '--dark-bg': darkBg,
48
+ } as React.CSSProperties}
49
+ className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-light-text-secondary dark:text-dark-text-secondary"
50
+ >
21
51
  {userImgUrl ? (
22
52
  <img
23
53
  src={userImgUrl}
@@ -25,9 +55,9 @@ export default function UserImage({
25
55
  className="w-full h-full object-cover rounded-full"
26
56
  />
27
57
  ) : (
28
- <span className="text-body1">
29
- {defaultInitial}
30
- </span>
58
+ <span className="text-body1 text-light-text-secondary dark:text-dark-text-secondary">
59
+ {displayInitial}
60
+ </span>
31
61
  )}
32
62
  </div>
33
63
  );
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface TableCellProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export default function TableCell({ children }: TableCellProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ export default function TableCell(_a) {
4
+ var children = _a.children;
5
+ return (<div className="flex-1 p-2 text-body2 text-light-text-primary dark:text-dark-text-primary border-t border-light-misc-divider dark:border-dark-misc-divider">
6
+ {children}
7
+ </div>);
8
+ }
9
+ ;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface TableContainerProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export default function TableContainer({ children }: TableContainerProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ export default function TableContainer(_a) {
4
+ var children = _a.children;
5
+ return (<div className="w-full overflow-x-auto bg-light-background-default dark:bg-dark-background-default">
6
+ {children}
7
+ </div>);
8
+ }
9
+ ;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface TableHeaderProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export default function TableHeader({ children }: TableHeaderProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ export default function TableHeader(_a) {
4
+ var children = _a.children;
5
+ return (<div className="py-2 bg-light-background-default dark:bg-dark-background-default">
6
+ {children}
7
+ </div>);
8
+ }
9
+ ;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface TableHeaderCellProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export default function TableHeaderCell({ children }: TableHeaderCellProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ export default function TableHeaderCell(_a) {
4
+ var children = _a.children;
5
+ return (<div className="flex-1 p-2 text-body2 text-light-text-primary dark:text-dark-text-primary">
6
+ {children}
7
+ </div>);
8
+ }
9
+ ;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface TableRowProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export default function TableRow({ children }: TableRowProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ export default function TableRow(_a) {
4
+ var children = _a.children;
5
+ return (<div className="flex w-full">
6
+ {children}
7
+ </div>);
8
+ }
9
+ ;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ interface TextareaProps {
3
+ id: string;
4
+ label?: string;
5
+ value: string;
6
+ onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
7
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
8
+ onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
9
+ onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
10
+ autoFocus?: boolean;
11
+ maxRows?: number;
12
+ disabled?: boolean;
13
+ error?: boolean;
14
+ size?: 'large' | 'medium' | 'small';
15
+ }
16
+ export default function Textarea({ id, label, value, onChange, onBlur, onFocus, onKeyDown, autoFocus, maxRows, disabled, error, size, }: TextareaProps): React.JSX.Element;
17
+ export {};
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ export default function Textarea(_a) {
4
+ var id = _a.id, label = _a.label, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, _b = _a.autoFocus, autoFocus = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, error = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? 'medium' : _f;
5
+ var textareaRef = useRef(null);
6
+ var _g = useState(false), isFocused = _g[0], setIsFocused = _g[1];
7
+ useEffect(function () {
8
+ var textarea = textareaRef.current;
9
+ if (!textarea)
10
+ return;
11
+ var adjustHeight = function () {
12
+ textarea.style.height = 'auto'; // Reset height to calculate scrollHeight
13
+ var lineHeight = parseInt(getComputedStyle(textarea).lineHeight);
14
+ var maxHeight = lineHeight * maxRows;
15
+ var scrollHeight = textarea.scrollHeight;
16
+ // Set height to scrollHeight, capped at maxRows, but at least 1 line
17
+ textarea.style.height = "".concat(Math.max(Math.min(scrollHeight, maxHeight), lineHeight), "px");
18
+ // Enable vertical scroll if content exceeds maxRows
19
+ textarea.style.overflowY = scrollHeight > maxHeight ? 'auto' : 'hidden';
20
+ };
21
+ // Set initial rows to 1 for single-line height
22
+ textarea.rows = 1;
23
+ adjustHeight();
24
+ textarea.addEventListener('input', adjustHeight);
25
+ return function () { return textarea.removeEventListener('input', adjustHeight); };
26
+ }, [maxRows]);
27
+ // Define classes for size: text size and padding
28
+ var sizeClasses = {
29
+ large: 'text-body1 p-[7px] leading-[22px]', // body1 (16px), padding 8px(7 + border 1) height 40
30
+ medium: 'text-body1 p-[3px] leading-[22px]', // body1 (16px), padding 4px(3 + border 1), height 32
31
+ small: 'text-body2 p-[3px] leading-[18px]', // body2 (14px), padding 4px(3 + border 1), height 28
32
+ }[size];
33
+ var baseClasses = 'w-full border rounded-[8px]';
34
+ var bgColor = 'bg-light-background-default dark:bg-dark-background-default transition-colors duration-200 ease-in-out';
35
+ var borderColor = 'border-light-outlinedBorder-active dark:border-dark-outlinedBorder-active';
36
+ var containerClasses = "\n ".concat(bgColor, "\n ").concat(borderColor, "\n ").concat(baseClasses, "\n ").concat(sizeClasses, "\n ").concat(disabled ? 'bg-gray-200 cursor-not-allowed' : '', "\n ").concat(error ? 'border-red-500 focus:ring-red-500' : '', "\n ").concat(isFocused ? 'focus:border-light-accent-main focus:dark:border-dark-accent-main outline-none' : '', "\n ").concat(!disabled && !error ? 'hover:border-light-outlinedBorder-hover' : '', "\n border-gray-300\n ");
37
+ return (<div className="flex flex-col w-full">
38
+ {label && (<label htmlFor={id} className="mb-1 text-body2 text-light-text-secondary dark:text-dark-text-secondary">
39
+ {label}
40
+ </label>)}
41
+ <div className="relative">
42
+ <textarea ref={textareaRef} id={id} rows={1} className={containerClasses} value={value} onChange={onChange} onFocus={function (e) {
43
+ setIsFocused(true);
44
+ if (onFocus)
45
+ onFocus(e);
46
+ }} onBlur={function (e) {
47
+ setIsFocused(false);
48
+ if (onBlur)
49
+ onBlur(e);
50
+ }} onKeyDown={onKeyDown} autoFocus={autoFocus} disabled={disabled} autoComplete="off"/>
51
+ </div>
52
+ {error && (<p className="mt-1 text-light-error-main text-body2">
53
+ This field is required
54
+ </p>)}
55
+ </div>);
56
+ }
@@ -1,13 +1,41 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ function getColorSeed(userHandle) {
4
+ var words = userHandle.trim().split(/\s+/);
5
+ var letters = words.map(function (word) { return word.charAt(0).toLowerCase(); });
6
+ if (letters.length === 1 && words[0].length >= 2) {
7
+ letters.push(words[0].charAt(1).toLowerCase());
8
+ }
9
+ else if (letters.length > 2) {
10
+ letters = letters.slice(0, 2);
11
+ }
12
+ else if (letters.length === 0) {
13
+ letters = ['x', 'x'];
14
+ }
15
+ return letters.join('');
16
+ }
17
+ function getHash(str) {
18
+ var hash = 0;
19
+ for (var i = 0; i < str.length; i++) {
20
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
21
+ }
22
+ return hash;
23
+ }
3
24
  export default function UserImage(_a) {
4
25
  var userHandle = _a.userHandle, userImgUrl = _a.userImgUrl;
5
- var defaultInitial = userHandle.charAt(0).toUpperCase();
6
- return (<div className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden
7
- bg-light-background-accent200 dark:bg-dark-background-accent200
8
- text-light-text-secondary dark:text-dark-text-secondary ">
9
- {userImgUrl ? (<img src={userImgUrl} alt={userHandle} className="w-full h-full object-cover rounded-full"/>) : (<span className="text-body1">
10
- {defaultInitial}
11
- </span>)}
26
+ var displayInitial = userHandle.charAt(0).toUpperCase() || 'A';
27
+ var seed = getColorSeed(userHandle);
28
+ var hue = Math.abs(getHash(seed)) % 360;
29
+ // Light mode: vibrant pastel
30
+ var lightBg = "hsl(".concat(hue, ", 80%, 80%)");
31
+ // Dark mode: darker, vibrant variant
32
+ var darkBg = "hsl(".concat(hue, ", 80%, 30%)");
33
+ return (<div style={{
34
+ '--light-bg': lightBg,
35
+ '--dark-bg': darkBg,
36
+ }} className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-light-text-secondary dark:text-dark-text-secondary">
37
+ {userImgUrl ? (<img src={userImgUrl} alt={userHandle} className="w-full h-full object-cover rounded-full"/>) : (<span className="text-body1 text-light-text-secondary dark:text-dark-text-secondary">
38
+ {displayInitial}
39
+ </span>)}
12
40
  </div>);
13
41
  }
package/dist/output.css CHANGED
@@ -579,6 +579,9 @@ video {
579
579
  .flex {
580
580
  display: flex;
581
581
  }
582
+ .hidden {
583
+ display: none;
584
+ }
582
585
  .size-5 {
583
586
  width: 1.25rem;
584
587
  height: 1.25rem;
@@ -641,6 +644,9 @@ video {
641
644
  .max-w-md {
642
645
  max-width: 28rem;
643
646
  }
647
+ .flex-1 {
648
+ flex: 1 1 0%;
649
+ }
644
650
  .transform {
645
651
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
646
652
  }
@@ -708,6 +714,9 @@ video {
708
714
  .overflow-hidden {
709
715
  overflow: hidden;
710
716
  }
717
+ .overflow-x-auto {
718
+ overflow-x: auto;
719
+ }
711
720
  .truncate {
712
721
  overflow: hidden;
713
722
  text-overflow: ellipsis;
@@ -737,6 +746,9 @@ video {
737
746
  .border-4 {
738
747
  border-width: 4px;
739
748
  }
749
+ .border-t {
750
+ border-top-width: 1px;
751
+ }
740
752
  .border-none {
741
753
  border-style: none;
742
754
  }
@@ -767,6 +779,9 @@ video {
767
779
  .border-t-transparent {
768
780
  border-top-color: transparent;
769
781
  }
782
+ .bg-\[var\(--light-bg\)\] {
783
+ background-color: var(--light-bg);
784
+ }
770
785
  .bg-black {
771
786
  --tw-bg-opacity: 1;
772
787
  background-color: rgb(0 0 0 / var(--tw-bg-opacity));
@@ -870,6 +885,10 @@ video {
870
885
  padding-top: 0.25rem;
871
886
  padding-bottom: 0.25rem;
872
887
  }
888
+ .py-2 {
889
+ padding-top: 0.5rem;
890
+ padding-bottom: 0.5rem;
891
+ }
873
892
  .py-6 {
874
893
  padding-top: 1.5rem;
875
894
  padding-bottom: 1.5rem;
@@ -1052,6 +1071,10 @@ body {
1052
1071
  border-color: rgb(176 176 176 / var(--tw-border-opacity));
1053
1072
  }
1054
1073
 
1074
+ .dark\:bg-\[var\(--dark-bg\)\] {
1075
+ background-color: var(--dark-bg);
1076
+ }
1077
+
1055
1078
  .dark\:bg-dark-accent-main {
1056
1079
  --tw-bg-opacity: 1;
1057
1080
  background-color: rgb(255 205 41 / var(--tw-bg-opacity));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oneslash-design-system",
3
3
  "description": "A design system for the Oneslash projects",
4
- "version": "1.1.32",
4
+ "version": "1.1.34",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",