Skip to content

Commit

Permalink
Add HeadingComponent (#16)
Browse files Browse the repository at this point in the history
add component
  • Loading branch information
julienbrg authored Jun 17, 2024
1 parent 977ea1f commit 5732a03
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/components/layout/HeadingComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ReactNode } from 'react'
import { Heading } from '@chakra-ui/react'

interface Props {
as: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl'
children: ReactNode
className?: string
}

export function HeadingComponent(props: Props) {
const className = props.className ?? ''
let size
switch (props.as) {
case 'h1':
size = props.size ?? '2xl'
break
case 'h2':
size = props.size ?? 'xl'
break
case 'h3':
size = props.size ?? 'lg'
break
case 'h4':
size = props.size ?? 'md'
break
case 'h5':
size = props.size ?? 'sm'
break
case 'h6':
size = props.size ?? 'xs'
break
}

return (
<Heading as={props.as} size={size} className={className} mb={2}>
{props.children}
</Heading>
)
}
1 change: 1 addition & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BrowserProvider, Contract, Eip1193Provider, parseEther } from 'ethers'
import { useWeb3ModalProvider, useWeb3ModalAccount } from '@web3modal/ethers/react'
import { ERC20_CONTRACT_ADDRESS, ERC20_CONTRACT_ABI } from '../utils/erc20'
import { LinkComponent } from '../components/layout/LinkComponent'
import { HeadingComponent } from '../components/layout/HeadingComponent'
import { ethers } from 'ethers'
import { Head } from '../components/layout/Head'
import { SITE_NAME, SITE_DESCRIPTION } from '../utils/config'
Expand Down

0 comments on commit 5732a03

Please sign in to comment.