* init * whoops * components update * components update * classes * variables * focus * test * spec * test * adjust colors and variables * buttons colors * Update app/javascript/crayons/CTAs/CTA.jsx Co-authored-by: Suzanne Aitchison <suzanne@forem.com> * proptype * remove duplicated tests now in Cypress, enhance Cypress nav menu tests * premove unneeded viewport in test * remove focus check for now * classnames * Update app/javascript/crayons/CTAs/__stories__/CTAs.mdx Co-authored-by: Nick Taylor <nick@iamdeveloper.com> * Update app/javascript/crayons/CTAs/__stories__/CTAs.mdx Co-authored-by: Nick Taylor <nick@iamdeveloper.com> * better contrast * classname * radius-full Co-authored-by: Suzanne Aitchison <suzanne@forem.com> Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames/bind';
|
|
import { defaultChildrenPropTypes } from '../../common-prop-types/default-children-prop-types';
|
|
import { Icon } from '@crayons';
|
|
|
|
export const Link = (props) => {
|
|
const {
|
|
children,
|
|
href = '#',
|
|
variant,
|
|
block,
|
|
icon,
|
|
rounded,
|
|
className,
|
|
...otherProps
|
|
} = props;
|
|
|
|
const classes = classNames('c-link', {
|
|
[`c-link--${variant}`]: variant,
|
|
'c-link--icon-left': icon && children,
|
|
'c-link--icon-alone': icon && !children,
|
|
'c-link--block': block,
|
|
'radius-full': rounded,
|
|
[className]: className,
|
|
});
|
|
|
|
return (
|
|
<a href={href} className={classes} {...otherProps}>
|
|
{icon && (
|
|
<Icon
|
|
src={icon}
|
|
aria-hidden="true"
|
|
focusable="false"
|
|
className="c-link__icon"
|
|
/>
|
|
)}
|
|
{children}
|
|
</a>
|
|
);
|
|
};
|
|
|
|
Link.displayName = 'Link';
|
|
|
|
Link.propTypes = {
|
|
variant: PropTypes.oneOf([undefined, 'branded']),
|
|
block: PropTypes.bool,
|
|
rounded: PropTypes.bool,
|
|
href: PropTypes.string.isRequired,
|
|
className: PropTypes.string,
|
|
children: defaultChildrenPropTypes,
|
|
icon: PropTypes.elementType,
|
|
};
|