Skip to content

Commit

Permalink
fix: fontSize props
Browse files Browse the repository at this point in the history
  • Loading branch information
minikas committed Jul 11, 2024
1 parent e5406e1 commit 3cfcf40
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packages/ui/src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import classNames from "classnames";
import { twMerge } from "tailwind-merge";
import { RiAddLine, RiSearchLine, RiSubtractLine } from "@remixicon/react";

import { isValidComponent } from "../helpers";
import { fontSizeClasses, isValidComponent } from "../helpers";

import { Button as PolkadexButton } from "./button";
import type { ButtonProps as PolkadexButtonProps } from "./button";
Expand All @@ -39,16 +39,21 @@ const Action = forwardRef<

Action.displayName = "Action";

const Base = forwardRef<ElementRef<"input">, ComponentPropsWithoutRef<"input">>(
({ className, ...props }, ref) => {
interface BaseProps extends ComponentPropsWithoutRef<"input"> {
fontSize?: keyof typeof fontSizeClasses;
}

const Base = forwardRef<ElementRef<"input">, BaseProps>(
({ className, fontSize = "sm", ...props }, ref) => {
return (
<input
ref={ref}
size={props.placeholder?.length}
type="text"
className={twMerge(
classNames(
"flex-1 bg-transparent text-white placeholder:text-secondary outline-none max-sm:focus:text-[16px]"
"flex-1 bg-transparent text-white placeholder:text-secondary outline-none max-sm:focus:text-[16px]",
fontSizeClasses[fontSize]
),
className
)}
Expand All @@ -63,9 +68,17 @@ Base.displayName = "Base";
interface InputWithContainerProps extends ComponentPropsWithoutRef<"input"> {
containerProps?: ComponentProps<"div">;
vertical?: boolean;
fontSize?: keyof typeof fontSizeClasses;
}
const Primary = forwardRef<ElementRef<"input">, InputWithContainerProps>(
({ children, className, vertical, containerProps, ...props }) => {
({
children,
className,
vertical,
fontSize = "sm",
containerProps,
...props
}) => {
const ref = useRef<HTMLInputElement>(null);

const ButtonComponents = isValidComponent(children, Button);
Expand Down Expand Up @@ -111,7 +124,8 @@ const Primary = forwardRef<ElementRef<"input">, InputWithContainerProps>(
)}
<Base
ref={ref}
className={twMerge("text-sm", className)}
className={className}
fontSize={fontSize}
{...props}
/>
</div>
Expand Down

0 comments on commit 3cfcf40

Please sign in to comment.