Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 65c81ce

Browse files
committed
refactor: input icons
1 parent 75a1e20 commit 65c81ce

File tree

7 files changed

+53
-52
lines changed

7 files changed

+53
-52
lines changed

apps/docs/src/components/ui/input/input.stories.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ export const ReactHookForm: Story = {
165165
export const StartIcon: Story = {
166166
args: {
167167
placeholder: 'Search...',
168-
startIcon: SearchIcon,
168+
startIcon: <SearchIcon className="w-4.5 h-4.5" />,
169169
type: 'text',
170170
},
171171
};
172172

173173
// End Icon
174174
export const EndIcon: Story = {
175175
args: {
176-
endIcon: SearchIcon,
176+
endIcon: <SearchIcon className="w-4.5 h-4.5" />,
177177
placeholder: 'Search...',
178178
type: 'text',
179179
},
@@ -182,9 +182,9 @@ export const EndIcon: Story = {
182182
// Start and End Icon
183183
export const StartAndEndIcon: Story = {
184184
args: {
185-
endIcon: CogIcon,
185+
endIcon: <CogIcon className="w-4.5 h-4.5" />,
186186
placeholder: 'Search...',
187-
startIcon: SearchIcon,
187+
startIcon: <SearchIcon className="w-4.5 h-4.5" />,
188188
type: 'text',
189189
},
190190
};
@@ -194,15 +194,15 @@ export const InlineWithStartIcon: Story = {
194194
args: {
195195
inline: true,
196196
placeholder: 'Search...',
197-
startIcon: SearchIcon,
197+
startIcon: <SearchIcon className="w-4.5 h-4.5" />,
198198
type: 'text',
199199
},
200200
};
201201

202202
// Inline with End Icon
203203
export const InlineWithEndIcon: Story = {
204204
args: {
205-
endIcon: SearchIcon,
205+
endIcon: <SearchIcon className="w-4.5 h-4.5" />,
206206
inline: true,
207207
placeholder: 'Search...',
208208
type: 'text',
@@ -212,10 +212,10 @@ export const InlineWithEndIcon: Story = {
212212
// Inline with Start and End Icon
213213
export const InlineWithStartAndEndIcon: Story = {
214214
args: {
215-
endIcon: CogIcon,
215+
endIcon: <CogIcon className="w-4.5 h-4.5" />,
216216
inline: true,
217217
placeholder: 'Search...',
218-
startIcon: SearchIcon,
218+
startIcon: <SearchIcon className="w-4.5 h-4.5" />,
219219
type: 'text',
220220
},
221221
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"clean": "turbo run clean && rm -rf node_modules",
1212
"dev": "turbo run dev",
1313
"postinstall": "pnpm exec simple-git-hooks",
14-
"lint": "turbo run lint -- --fix",
14+
"lint": "turbo run lint",
1515
"pnpm:install": "pnpm install",
1616
"pnpm:reinstall": "pnpm run clean && pnpm install",
1717
"pnpm:update": "pnpm update --latest --interactive --recursive",

packages/ui/src/mail/forgot-password-template.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as React from 'react';
12
import {
23
Body,
34
Button,

packages/ui/src/mail/magic-link-template.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Tailwind,
1111
Text,
1212
} from '@react-email/components';
13+
import * as React from 'react';
1314

1415
export function MagicLinkTemplate({
1516
magicLink,

packages/ui/src/mail/verify-email-template.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Tailwind,
1111
Text,
1212
} from '@react-email/components';
13+
import * as React from 'react';
1314

1415
export function VerifyEmailTemplate({
1516
verifyEmailLink,

packages/ui/src/react/data-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export function DataTableSearch<TData>({
349349
className="w-full max-w-sm"
350350
onChange={onChange}
351351
placeholder="Search all columns..."
352-
startIcon={SearchIcon}
352+
startIcon={<SearchIcon className="w-4.5 h-4.5" />}
353353
type="search"
354354
/>
355355
);

packages/ui/src/react/input.tsx

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { EyeIcon, EyeOffIcon } from 'lucide-react';
66
import * as React from 'react';
77
import { forwardRef, useState } from 'react';
88
import { twMerge } from 'tailwind-merge';
9-
import type { IconType } from '@/react/icons';
109
import { Button } from '@/react/button';
1110
import { inputVariants, primitiveInputVariants } from '@/cva/input';
1211

@@ -78,57 +77,56 @@ InputPassword.displayName = 'InputPassword';
7877
export const Input = forwardRef<
7978
React.ElementRef<typeof PrimitiveInput>,
8079
React.ComponentPropsWithoutRef<typeof PrimitiveInput> & {
81-
startIcon?: IconType;
82-
endIcon?: IconType;
80+
startIcon?: React.ReactNode;
81+
endIcon?: React.ReactNode;
8382
classNames?: {
8483
startIcon?: string;
8584
endIcon?: string;
8685
input?: string;
8786
};
8887
}
89-
>(
90-
(
91-
{ startIcon: StartIcon, endIcon: EndIcon, classNames, className, ...props },
92-
forwardedRef,
93-
) => (
94-
<div
88+
>(({ startIcon, endIcon, classNames, className, ...props }, forwardedRef) => (
89+
<div
90+
className={twMerge(
91+
'relative',
92+
props.inline ? 'inline-block' : 'w-full',
93+
className,
94+
)}
95+
>
96+
{startIcon ? (
97+
<span
98+
className={twMerge(
99+
'text-muted-foreground absolute left-3 top-1/2 -translate-y-1/2',
100+
classNames?.startIcon,
101+
)}
102+
>
103+
{startIcon}
104+
</span>
105+
) : null}
106+
107+
<PrimitiveInput
95108
className={twMerge(
96-
'relative',
97-
props.inline ? 'inline-block' : 'w-full',
98-
className,
109+
inputVariants({
110+
className: twMerge('max-h-full', classNames?.input),
111+
hasEndIcon: Boolean(endIcon),
112+
hasStartIcon: Boolean(startIcon),
113+
}),
99114
)}
100-
>
101-
{StartIcon ? (
102-
<StartIcon
103-
className={twMerge(
104-
'h-4.5 w-4.5 text-muted-foreground absolute left-3 top-1/2 -translate-y-1/2',
105-
classNames?.startIcon,
106-
)}
107-
/>
108-
) : null}
115+
ref={forwardedRef}
116+
{...props}
117+
/>
109118

110-
<PrimitiveInput
119+
{endIcon ? (
120+
<span
111121
className={twMerge(
112-
inputVariants({
113-
className: twMerge('max-h-full', classNames?.input),
114-
hasEndIcon: Boolean(EndIcon),
115-
hasStartIcon: Boolean(StartIcon),
116-
}),
122+
'text-muted-foreground absolute right-3 top-1/2 -translate-y-1/2',
123+
classNames?.endIcon,
117124
)}
118-
ref={forwardedRef}
119-
{...props}
120-
/>
121-
122-
{EndIcon ? (
123-
<EndIcon
124-
className={twMerge(
125-
'h-4.5 w-4.5 text-muted-foreground absolute right-3 top-1/2 -translate-y-1/2',
126-
classNames?.endIcon,
127-
)}
128-
/>
129-
) : null}
130-
</div>
131-
),
132-
);
125+
>
126+
{endIcon}
127+
</span>
128+
) : null}
129+
</div>
130+
));
133131

134132
Input.displayName = PrimitiveInput.displayName;

0 commit comments

Comments
 (0)