2025-04-01 16:15:20 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { linkClasses } from '@freesewing/utils'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An anchor link component
|
|
|
|
*
|
2025-05-24 15:28:43 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} props.children - The component children, will be rendered inside the link
|
|
|
|
* @param {string} [props.id = ''] - The ID of the anchor to link to
|
|
|
|
* @param {string} [props.title = false] - An optional link title
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const AnchorLink = ({ children, id = '', title = false }) => (
|
|
|
|
<a href={`#${id}`} className={linkClasses} title={title ? title : ''}>
|
|
|
|
{children}
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A regular link component
|
|
|
|
*
|
2025-05-24 15:28:43 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} props.children - The component children, will be rendered inside the link
|
|
|
|
* @param {string} [props.className = @freesewing/utils/linkClasses] - Any non-default CSS classes to apply
|
|
|
|
* @param {string} props.href - The URL to link to
|
|
|
|
* @param {object} [props.style = {}] - Any non-default styles to apply
|
|
|
|
* @param {string} [props.target = undefined] - An optional link title
|
|
|
|
* @param {string} [props.title = false] - An optional link title
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
2025-04-13 08:57:54 +00:00
|
|
|
export const Link = ({
|
|
|
|
children,
|
|
|
|
className = linkClasses,
|
2025-05-24 15:28:43 +02:00
|
|
|
href,
|
2025-04-13 08:57:54 +00:00
|
|
|
style = {},
|
2025-05-24 15:28:43 +02:00
|
|
|
target,
|
|
|
|
title = false,
|
2025-04-13 08:57:54 +00:00
|
|
|
}) => (
|
|
|
|
<a href={href} target={target} className={className} title={title ? title : ''} style={style}>
|
2025-04-01 16:15:20 +02:00
|
|
|
{children}
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
|
|
|
|
const BaseLink = Link
|
|
|
|
|
|
|
|
/**
|
2025-05-24 15:28:43 +02:00
|
|
|
* A regular link, but intended to be used on a success background
|
2025-04-01 16:15:20 +02:00
|
|
|
*
|
2025-05-24 15:28:43 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} props.children - The component children, will be rendered inside the link
|
|
|
|
* @param {string} props.href - The URL to link to
|
|
|
|
* @param {string} [props.title = false] - An optional link title
|
|
|
|
* @param {React.FC} [Link = undefined] - An optional framework-specific Link component
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
2025-05-30 11:29:55 +02:00
|
|
|
export const SuccessLink = ({ children, href, title = false, Link }) =>
|
|
|
|
Link ? (
|
|
|
|
<Link href={href} className={linkClasses} title={title ? title : ''}>
|
|
|
|
<span className="tw:text-success-content tw:hover:text-success-content">{children}</span>
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
<a href={href} className={linkClasses} title={title ? title : ''}>
|
|
|
|
<span className="tw:text-success-content tw:hover:text-success-content">{children}</span>
|
|
|
|
</a>
|
|
|
|
)
|
2025-04-01 16:15:20 +02:00
|
|
|
|
2025-05-24 15:28:43 +02:00
|
|
|
/**
|
|
|
|
* A link styled as a card
|
|
|
|
*
|
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} props.children - The component children, will be rendered inside the link
|
|
|
|
* @param {string} [props.className = @freesewing/utils/linkClasses + "tw:text-success-content tw:hover:text-success-content"] - Any non-default CSS classes to apply
|
|
|
|
* @param {string} props.href - The URL to link to
|
|
|
|
* @param {string} [props.title = false] - An optional link title
|
|
|
|
* @param {JSX.Element} props.icon - An icon to render
|
|
|
|
* @param {React.FC} [Link = undefined] - An optional framework-specific Link component
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
*/
|
2025-04-01 16:15:20 +02:00
|
|
|
export const CardLink = ({
|
2025-05-24 15:28:43 +02:00
|
|
|
children,
|
|
|
|
className = 'tw:bg-base-200 tw:text-base-content',
|
2025-04-01 16:15:20 +02:00
|
|
|
href,
|
|
|
|
title,
|
|
|
|
icon,
|
|
|
|
Link,
|
|
|
|
}) => {
|
|
|
|
if (!Link) Link = BaseLink
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
href={href}
|
2025-04-18 08:07:13 +00:00
|
|
|
className={`tw:px-8 tw:py-10 tw:rounded-lg tw:block ${className}
|
|
|
|
tw:hover:bg-secondary/5 tw:shadow-lg tw:bg-base-200
|
|
|
|
tw:transition-color tw:duration-300 grow tw:hover:no-underline no-hover-decoration`}
|
2025-04-01 16:15:20 +02:00
|
|
|
>
|
2025-04-18 08:07:13 +00:00
|
|
|
<h2 className="tw:mb-4 tw:text-base-content tw:flex tw:flex-row tw:gap-4 tw:justify-between tw:items-center">
|
|
|
|
<span className="tw:text-base-content">{title}</span>
|
|
|
|
<span className="tw:shrink-0 tw:text-base-content">{icon}</span>
|
2025-04-01 16:15:20 +02:00
|
|
|
</h2>
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:text-base-content">{children}</div>
|
2025-04-01 16:15:20 +02:00
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|