Skip to content

Commit

Permalink
Update Heading, Tile
Browse files Browse the repository at this point in the history
  • Loading branch information
adamplesnik committed Sep 30, 2024
1 parent 7fbdf91 commit fa581bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
34 changes: 8 additions & 26 deletions src/components/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
import clsx from 'clsx'
import { PropsWithChildren } from 'react'
import { addWithSpace } from '../utils/addWithSpace'

const Heading = ({
size = 1,
className = '',
children,
id = '',
}: PropsWithChildren<TitleProps>) => {
const defaultClasses = 'relative w-full text-zinc-950' + addWithSpace(className)
const anchor = id ? <a id={id} className={'absolute -top-32'} /> : ''
const Heading = ({ size = 1, className = '', children }: PropsWithChildren<TitleProps>) => {
const defaultClasses = clsx('relative w-full text-zinc-950', className)

if (size === 1) {
return (
<h1 className={defaultClasses + ' pb-8 text-xl font-medium leading-normal'}>
<h1 className={clsx(defaultClasses, 'pb-8 text-xl font-medium leading-normal')}>
{children}
{anchor}
</h1>
)
} else if (size === 2) {
return (
<h2 className={defaultClasses + ' pb-4 text-2xl font-medium opacity-90'}>
{children}
{anchor}
</h2>
<h2 className={clsx(defaultClasses, 'pb-4 text-2xl font-medium opacity-90')}>{children}</h2>
)
} else if (size === 3) {
return (
<h3 className={defaultClasses + ' pb-4 text-lg font-semibold opacity-90'}>
{children}
{anchor}
</h3>
<h3 className={clsx(defaultClasses, 'pb-4 text-lg font-semibold opacity-90')}>{children}</h3>
)
} else {
return (
<h4 className={defaultClasses + ' text-md pb-4 font-semibold'}>
{children}
{anchor}
</h4>
)
return <h4 className={clsx(defaultClasses + 'text-md pb-4 font-semibold')}>{children}</h4>
}
}

export interface TitleProps {
children: PropsWithChildren
size: 1 | 2 | 3 | 4
className?: string
id?: string
}

export default Heading
2 changes: 1 addition & 1 deletion src/components/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Heading from './Heading'
const Tile = ({ children, className, title, badge }: PropsWithChildren<TileWrapperProps>) => {
return (
<div className={'' + addWithSpace(className)}>
<div className="flex justify-between">
<div className="flex gap-4">
<Heading size={4}>{title}</Heading>
{badge && badge}
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/__snapshots__/Tile.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ exports[`Tile 1`] = `
className=""
>
<div
className="flex justify-between"
className="flex gap-4"
>
<h4
className="relative w-full text-zinc-950 text-md pb-4 font-semibold"
className="relative w-full text-zinc-950text-md pb-4 font-semibold"
>
Test Title
</h4>
Expand All @@ -22,10 +22,10 @@ exports[`Tile with class name 1`] = `
className=" test-class"
>
<div
className="flex justify-between"
className="flex gap-4"
>
<h4
className="relative w-full text-zinc-950 text-md pb-4 font-semibold"
className="relative w-full text-zinc-950text-md pb-4 font-semibold"
>
Test Title
</h4>
Expand Down

0 comments on commit fa581bd

Please sign in to comment.