1
0
Fork 0
freesewing/sites/shared/components/choice-link.mjs

31 lines
935 B
JavaScript
Raw Normal View History

2023-09-29 16:01:27 +02:00
// __SDEFILE__ - This file is a dependency for the stand-alone environment
2023-04-30 20:31:28 +02:00
import Link from 'next/link'
2023-04-30 21:24:35 +02:00
export const ChoiceLink = ({ title = '', href = '', children, icon = null }) => {
const linkProps = {
href,
className: `flex flex-col flex-nowrap items-start justify-start gap-2 pt-2 pb-4 h-auto w-full mt-3
2023-04-30 20:31:28 +02:00
btn btn-secondary btn-ghost border border-secondary
2023-04-30 21:24:35 +02:00
hover:bg-opacity-20 hover:bg-secondary hover:border hover:border-secondary`,
}
const content = (
<>
<h5 className="flex flex-row items-center justify-between w-full">
<span>{title}</span>
{icon}
</h5>
<div className={`normal-case text-base font-medium text-base-content text-left`}>
{children}
</div>
</>
)
// Deal with external links
return href.slice(0, 4).toLowerCase() === 'http' ? (
<a {...linkProps}>{content}</a>
) : (
<Link {...linkProps}>{content}</Link>
)
}