| 1 |
import classNames from 'classnames'; |
| 2 |
import { |
| 3 |
bannerButtonVariables, |
| 4 |
buttonHoverClasses, |
| 5 |
colorsOf, |
| 6 |
designButtonVariables, |
| 7 |
} from './colors'; |
| 8 |
import { externalLinkProps } from './notification-link'; |
| 9 |
|
| 10 |
const VARIABLES = { |
| 11 |
banner: bannerButtonVariables, |
| 12 |
design: designButtonVariables, |
| 13 |
}; |
| 14 |
|
| 15 |
export const Cta = ({ |
| 16 |
notification, |
| 17 |
href, |
| 18 |
external, |
| 19 |
onClick, |
| 20 |
surface, |
| 21 |
className, |
| 22 |
}) => { |
| 23 |
const ctaLabel = notification['cta-label']; |
| 24 |
if (!ctaLabel || !href) { |
| 25 |
return null; |
| 26 |
} |
| 27 |
|
| 28 |
const colors = colorsOf(notification); |
| 29 |
|
| 30 |
return ( |
| 31 |
<a |
| 32 |
href={href} |
| 33 |
{...externalLinkProps(external)} |
| 34 |
onClick={onClick} |
| 35 |
className={classNames(className, buttonHoverClasses(colors))} |
| 36 |
style={VARIABLES[surface](colors)} |
| 37 |
> |
| 38 |
{ctaLabel} |
| 39 |
</a> |
| 40 |
); |
| 41 |
}; |
| 42 |
|