@shipfox/react-ui 0.1.0 → 0.3.0

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.
Files changed (98) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/.turbo/turbo-check.log +3 -3
  3. package/.turbo/turbo-type.log +1 -1
  4. package/CHANGELOG.md +12 -0
  5. package/dist/components/alert/alert.d.ts +18 -0
  6. package/dist/components/alert/alert.d.ts.map +1 -0
  7. package/dist/components/alert/alert.js +123 -0
  8. package/dist/components/alert/alert.js.map +1 -0
  9. package/dist/components/alert/alert.stories.js +112 -0
  10. package/dist/components/alert/alert.stories.js.map +1 -0
  11. package/dist/components/alert/index.d.ts +2 -0
  12. package/dist/components/alert/index.d.ts.map +1 -0
  13. package/dist/components/alert/index.js +3 -0
  14. package/dist/components/alert/index.js.map +1 -0
  15. package/dist/components/avatar/avatar-group.d.ts +18 -0
  16. package/dist/components/avatar/avatar-group.d.ts.map +1 -0
  17. package/dist/components/avatar/avatar-group.js +132 -0
  18. package/dist/components/avatar/avatar-group.js.map +1 -0
  19. package/dist/components/avatar/avatar.d.ts +21 -0
  20. package/dist/components/avatar/avatar.d.ts.map +1 -0
  21. package/dist/components/avatar/avatar.js +166 -0
  22. package/dist/components/avatar/avatar.js.map +1 -0
  23. package/dist/components/avatar/avatar.stories.js +255 -0
  24. package/dist/components/avatar/avatar.stories.js.map +1 -0
  25. package/dist/components/avatar/index.d.ts +3 -0
  26. package/dist/components/avatar/index.d.ts.map +1 -0
  27. package/dist/components/avatar/index.js +4 -0
  28. package/dist/components/avatar/index.js.map +1 -0
  29. package/dist/components/icon/custom/index.d.ts +1 -0
  30. package/dist/components/icon/custom/index.d.ts.map +1 -1
  31. package/dist/components/icon/custom/index.js +1 -0
  32. package/dist/components/icon/custom/index.js.map +1 -1
  33. package/dist/components/icon/custom/shipfox-logo.d.ts +8 -0
  34. package/dist/components/icon/custom/shipfox-logo.d.ts.map +1 -0
  35. package/dist/components/icon/custom/shipfox-logo.js +22 -0
  36. package/dist/components/icon/custom/shipfox-logo.js.map +1 -0
  37. package/dist/components/icon/icon.d.ts +4 -1
  38. package/dist/components/icon/icon.d.ts.map +1 -1
  39. package/dist/components/icon/icon.js +6 -3
  40. package/dist/components/icon/icon.js.map +1 -1
  41. package/dist/components/index.d.ts +4 -0
  42. package/dist/components/index.d.ts.map +1 -1
  43. package/dist/components/index.js +4 -0
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/inline-tips/index.d.ts +2 -0
  46. package/dist/components/inline-tips/index.d.ts.map +1 -0
  47. package/dist/components/inline-tips/index.js +3 -0
  48. package/dist/components/inline-tips/index.js.map +1 -0
  49. package/dist/components/inline-tips/inline-tips.d.ts +19 -0
  50. package/dist/components/inline-tips/inline-tips.d.ts.map +1 -0
  51. package/dist/components/inline-tips/inline-tips.js +98 -0
  52. package/dist/components/inline-tips/inline-tips.js.map +1 -0
  53. package/dist/components/inline-tips/inline-tips.stories.js +214 -0
  54. package/dist/components/inline-tips/inline-tips.stories.js.map +1 -0
  55. package/dist/components/textarea/index.d.ts +2 -0
  56. package/dist/components/textarea/index.d.ts.map +1 -0
  57. package/dist/components/textarea/index.js +3 -0
  58. package/dist/components/textarea/index.js.map +1 -0
  59. package/dist/components/textarea/textarea.d.ts +10 -0
  60. package/dist/components/textarea/textarea.d.ts.map +1 -0
  61. package/dist/components/textarea/textarea.js +31 -0
  62. package/dist/components/textarea/textarea.js.map +1 -0
  63. package/dist/components/textarea/textarea.stories.js +333 -0
  64. package/dist/components/textarea/textarea.stories.js.map +1 -0
  65. package/dist/components/tooltip/tooltip.d.ts +7 -0
  66. package/dist/components/tooltip/tooltip.d.ts.map +1 -0
  67. package/dist/components/tooltip/tooltip.js +38 -0
  68. package/dist/components/tooltip/tooltip.js.map +1 -0
  69. package/dist/utils/avatar.d.ts +3 -0
  70. package/dist/utils/avatar.d.ts.map +1 -0
  71. package/dist/utils/avatar.js +32 -0
  72. package/dist/utils/avatar.js.map +1 -0
  73. package/dist/utils/index.d.ts +1 -0
  74. package/dist/utils/index.d.ts.map +1 -1
  75. package/dist/utils/index.js +1 -0
  76. package/dist/utils/index.js.map +1 -1
  77. package/index.css +32 -1
  78. package/package.json +5 -5
  79. package/src/components/alert/alert.stories.tsx +77 -0
  80. package/src/components/alert/alert.tsx +144 -0
  81. package/src/components/alert/index.ts +1 -0
  82. package/src/components/avatar/avatar-group.tsx +186 -0
  83. package/src/components/avatar/avatar.stories.tsx +172 -0
  84. package/src/components/avatar/avatar.tsx +215 -0
  85. package/src/components/avatar/index.ts +2 -0
  86. package/src/components/icon/custom/index.ts +1 -0
  87. package/src/components/icon/custom/shipfox-logo.tsx +20 -0
  88. package/src/components/icon/icon.tsx +11 -1
  89. package/src/components/index.ts +4 -0
  90. package/src/components/inline-tips/index.ts +1 -0
  91. package/src/components/inline-tips/inline-tips.stories.tsx +126 -0
  92. package/src/components/inline-tips/inline-tips.tsx +132 -0
  93. package/src/components/textarea/index.ts +1 -0
  94. package/src/components/textarea/textarea.stories.tsx +190 -0
  95. package/src/components/textarea/textarea.tsx +42 -0
  96. package/src/components/tooltip/tooltip.tsx +52 -0
  97. package/src/utils/avatar.ts +27 -0
  98. package/src/utils/index.ts +1 -0
@@ -0,0 +1,190 @@
1
+ import type {Meta, StoryObj} from '@storybook/react';
2
+ import {Code, Header} from 'components/typography';
3
+ import {Textarea} from './textarea';
4
+
5
+ const meta = {
6
+ title: 'Components/Textarea',
7
+ component: Textarea,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ placeholder: {control: 'text'},
11
+ disabled: {control: 'boolean'},
12
+ 'aria-invalid': {control: 'boolean'},
13
+ rows: {control: 'number'},
14
+ cols: {control: 'number'},
15
+ },
16
+ args: {
17
+ placeholder: 'Type something…',
18
+ disabled: false,
19
+ 'aria-invalid': false,
20
+ rows: 4,
21
+ },
22
+ } satisfies Meta<typeof Textarea>;
23
+
24
+ export default meta;
25
+
26
+ type Story = StoryObj<typeof meta>;
27
+
28
+ export const Default: Story = {};
29
+
30
+ const variants = ['base', 'component'] as const;
31
+ const sizes = ['base', 'small'] as const;
32
+
33
+ export const States: Story = {
34
+ render: (args) => (
35
+ <div className="flex flex-col gap-32">
36
+ {variants.map((variant) =>
37
+ sizes.map((size) => (
38
+ <div key={variant + size} className="flex flex-col gap-16">
39
+ <Header variant="h3">
40
+ {variant} {size}
41
+ </Header>
42
+ <div className="flex flex-col gap-8">
43
+ <Code variant="label" className="text-foreground-neutral-subtle">
44
+ Default
45
+ </Code>
46
+
47
+ <Textarea {...args} variant={variant} size={size} />
48
+ </div>
49
+
50
+ <div className="flex flex-col gap-8">
51
+ <Code variant="label" className="text-foreground-neutral-subtle">
52
+ Hover
53
+ </Code>
54
+
55
+ <Textarea {...args} className="hover" variant={variant} size={size} />
56
+ </div>
57
+ <div className="flex flex-col gap-8">
58
+ <Code variant="label" className="text-foreground-neutral-subtle">
59
+ Active
60
+ </Code>
61
+
62
+ <Textarea
63
+ {...args}
64
+ className="active"
65
+ defaultValue="The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
66
+ variant={variant}
67
+ size={size}
68
+ />
69
+ </div>
70
+ <div className="flex flex-col gap-8">
71
+ <Code variant="label" className="text-foreground-neutral-subtle">
72
+ Focus
73
+ </Code>
74
+
75
+ <Textarea {...args} className="focus" variant={variant} size={size} />
76
+ </div>
77
+ <div className="flex flex-col gap-8">
78
+ <Code variant="label" className="text-foreground-neutral-subtle">
79
+ Disabled
80
+ </Code>
81
+
82
+ <Textarea {...args} disabled variant={variant} size={size} />
83
+ </div>
84
+ <div className="flex flex-col gap-8">
85
+ <Code variant="label" className="text-foreground-neutral-subtle">
86
+ Invalid
87
+ </Code>
88
+
89
+ <Textarea {...args} aria-invalid variant={variant} size={size} />
90
+ </div>
91
+ </div>
92
+ )),
93
+ )}
94
+ </div>
95
+ ),
96
+ };
97
+
98
+ States.parameters = {
99
+ pseudo: {
100
+ hover: '.hover',
101
+ active: '.active',
102
+ focusVisible: '.focus',
103
+ },
104
+ };
105
+
106
+ export const Sizes: Story = {
107
+ render: (args) => (
108
+ <div className="flex flex-col gap-32">
109
+ <div className="flex flex-col gap-8">
110
+ <Code variant="label" className="text-foreground-neutral-subtle">
111
+ Rows: 2
112
+ </Code>
113
+ <Textarea {...args} rows={2} />
114
+ </div>
115
+ <div className="flex flex-col gap-8">
116
+ <Code variant="label" className="text-foreground-neutral-subtle">
117
+ Rows: 4 (default)
118
+ </Code>
119
+ <Textarea {...args} rows={4} />
120
+ </div>
121
+ <div className="flex flex-col gap-8">
122
+ <Code variant="label" className="text-foreground-neutral-subtle">
123
+ Rows: 6
124
+ </Code>
125
+ <Textarea {...args} rows={6} />
126
+ </div>
127
+ <div className="flex flex-col gap-8">
128
+ <Code variant="label" className="text-foreground-neutral-subtle">
129
+ Rows: 10
130
+ </Code>
131
+ <Textarea {...args} rows={10} />
132
+ </div>
133
+ </div>
134
+ ),
135
+ };
136
+
137
+ export const DesignMock: Story = {
138
+ render: () => {
139
+ const variants = [
140
+ {key: 'base', label: 'Primary'},
141
+ {key: 'component', label: 'Secondary'},
142
+ ] as const;
143
+ const states = [
144
+ {name: 'Default', props: {}},
145
+ {name: 'Hover', props: {className: 'hover'}},
146
+ {name: 'Focus', props: {className: 'focus'}},
147
+ {name: 'Filled', props: {defaultValue: 'Placeholder'}},
148
+ {name: 'Filled Hover', props: {defaultValue: 'Placeholder', className: 'hover'}},
149
+ {name: 'Disabled', props: {disabled: true}},
150
+ {name: 'Error', props: {'aria-invalid': true}},
151
+ ] as const;
152
+
153
+ return (
154
+ <div className="flex flex-col gap-32 pb-64 pt-32 px-32">
155
+ <Header variant="h3" className="text-foreground-neutral-subtle">
156
+ TEXT AREA
157
+ </Header>
158
+ <div className="flex flex-row gap-32">
159
+ {variants.map((variant) => (
160
+ <div key={variant.key} className="flex flex-col gap-32">
161
+ {states.map((state) => (
162
+ <div key={state.name} className="flex flex-col gap-8">
163
+ <Code variant="label" className="text-foreground-neutral-subtle">
164
+ Size=Base (32), State={state.name}, Color={variant.label}
165
+ </Code>
166
+ <div className="w-[280px]">
167
+ <Textarea
168
+ placeholder="Placeholder"
169
+ variant={variant.key}
170
+ size="base"
171
+ rows={2}
172
+ {...state.props}
173
+ />
174
+ </div>
175
+ </div>
176
+ ))}
177
+ </div>
178
+ ))}
179
+ </div>
180
+ </div>
181
+ );
182
+ },
183
+ };
184
+
185
+ DesignMock.parameters = {
186
+ pseudo: {
187
+ hover: '.hover',
188
+ focusVisible: '.focus',
189
+ },
190
+ };
@@ -0,0 +1,42 @@
1
+ import {cva, type VariantProps} from 'class-variance-authority';
2
+ import type {ComponentProps} from 'react';
3
+ import {cn} from 'utils/cn';
4
+
5
+ export const textareaVariants = cva('', {
6
+ variants: {
7
+ variant: {
8
+ base: 'bg-background-field-base',
9
+ component: 'bg-background-field-component',
10
+ },
11
+ size: {
12
+ base: 'py-6',
13
+ small: 'py-4',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'base',
18
+ size: 'base',
19
+ },
20
+ });
21
+
22
+ type TextareaProps = Omit<ComponentProps<'textarea'>, 'size'> &
23
+ VariantProps<typeof textareaVariants>;
24
+
25
+ export function Textarea({className, variant, size, ...props}: TextareaProps) {
26
+ return (
27
+ <textarea
28
+ data-slot="textarea"
29
+ className={cn(
30
+ 'textarea-resize-custom placeholder:text-foreground-neutral-muted w-full min-w-0 rounded-6 px-8 pr-24 text-sm leading-20 text-foreground-neutral-base shadow-border-base transition-[color,box-shadow] outline-none',
31
+ 'hover:bg-background-field-hover',
32
+ 'selection:bg-background-accent-neutral-soft selection:text-foreground-neutral-on-inverted',
33
+ 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-background-neutral-disabled disabled:shadow-none disabled:text-foreground-neutral-disabled',
34
+ 'focus-visible:shadow-border-interactive-with-active',
35
+ 'aria-invalid:shadow-border-error',
36
+ textareaVariants({variant, size}),
37
+ className,
38
+ )}
39
+ {...props}
40
+ />
41
+ );
42
+ }
@@ -0,0 +1,52 @@
1
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
2
+ import {cn} from 'utils/cn';
3
+
4
+ function TooltipProvider({
5
+ delayDuration = 0,
6
+ ...props
7
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
8
+ return (
9
+ <TooltipPrimitive.Provider
10
+ data-slot="tooltip-provider"
11
+ delayDuration={delayDuration}
12
+ {...props}
13
+ />
14
+ );
15
+ }
16
+
17
+ function Tooltip({...props}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
18
+ return (
19
+ <TooltipProvider>
20
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
21
+ </TooltipProvider>
22
+ );
23
+ }
24
+
25
+ function TooltipTrigger({...props}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
26
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
27
+ }
28
+
29
+ function TooltipContent({
30
+ className,
31
+ sideOffset = 0,
32
+ children,
33
+ ...props
34
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
35
+ return (
36
+ <TooltipPrimitive.Portal>
37
+ <TooltipPrimitive.Content
38
+ data-slot="tooltip-content"
39
+ sideOffset={sideOffset}
40
+ className={cn(
41
+ 'rounded-8 bg-background-components-base text-foreground-neutral-base px-8 py-4 text-xs font-medium leading-20 shadow-button-neutral animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md text-balance',
42
+ className,
43
+ )}
44
+ {...props}
45
+ >
46
+ {children}
47
+ </TooltipPrimitive.Content>
48
+ </TooltipPrimitive.Portal>
49
+ );
50
+ }
51
+
52
+ export {Tooltip, TooltipTrigger, TooltipContent, TooltipProvider};
@@ -0,0 +1,27 @@
1
+ const hashString = (str: string): number => {
2
+ let hash = 0;
3
+ for (let i = 0; i < str.length; i++) {
4
+ const char = str.charCodeAt(i);
5
+ hash = (hash << 5) - hash + char;
6
+ hash = hash & hash;
7
+ }
8
+ return Math.abs(hash);
9
+ };
10
+
11
+ export const getPlaceholderImageUrl = (name?: string): string => {
12
+ const backgroundColors = ['BFDFFF', 'BFEAFF', 'CFBFFF', 'FFBFC3', 'FFEABF', 'E3E6EA', 'EAEAEA'];
13
+
14
+ const seed = name?.trim() || 'avatar';
15
+
16
+ const colorIndex = hashString(seed) % backgroundColors.length;
17
+ const backgroundColor = backgroundColors[colorIndex];
18
+
19
+ return `https://api.dicebear.com/9.x/micah/svg?backgroundColor=${backgroundColor}&seed=${encodeURIComponent(seed)}`;
20
+ };
21
+
22
+ export const getInitial = (name?: string): string => {
23
+ if (name) {
24
+ return name.trim()[0]?.toUpperCase() ?? 'L';
25
+ }
26
+ return 'L';
27
+ };
@@ -1,3 +1,4 @@
1
+ export * from './avatar';
1
2
  export * from './clipboard';
2
3
  export * from './cn';
3
4
  export * from './date';