Skip to content

Commit

Permalink
fix(build): card, title
Browse files Browse the repository at this point in the history
  • Loading branch information
brianorwhatever committed Jan 30, 2025
1 parent 09d4766 commit 2389a87
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
node_modules
2 changes: 1 addition & 1 deletion src/components/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cn } from "../../utils/cn";

export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {}

export const Card = React.forwardRef<HTMLDivElement, CardProps>(
const Card = React.forwardRef<HTMLDivElement, CardProps>(
({ className, ...props }, ref) => (
<div
ref={ref}
Expand Down
29 changes: 19 additions & 10 deletions src/components/typography/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ export interface TitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
level?: 1 | 2 | 3 | 4 | 5 | 6;
}

const HeadingComponents = {
1: 'h1',
2: 'h2',
3: 'h3',
4: 'h4',
5: 'h5',
6: 'h6'
} as const;

export const Title = React.forwardRef<HTMLHeadingElement, TitleProps>(
({ className, level = 1, children, ...props }, ref) => {
const Component = `h${level}` as keyof JSX.IntrinsicElements;
const Component = HeadingComponents[level as keyof typeof HeadingComponents];

const styles = {
1: "text-3xl font-bold tracking-tight",
Expand All @@ -16,16 +25,16 @@ export const Title = React.forwardRef<HTMLHeadingElement, TitleProps>(
4: "text-lg font-semibold tracking-tight",
5: "text-base font-semibold tracking-tight",
6: "text-sm font-semibold tracking-tight",
};
} as const;

return (
<Component
ref={ref}
className={cn(styles[level], className)}
{...props}
>
{children}
</Component>
return React.createElement(
Component,
{
ref,
className: cn(styles[level], className),
...props
},
children
);
}
);
Expand Down

0 comments on commit 2389a87

Please sign in to comment.