-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fbdf91
commit fa581bd
Showing
3 changed files
with
13 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters