@hhgtech/hhg-components
Version:
Hello Health Group common components
104 lines (93 loc) • 4.56 kB
JavaScript
import * as React from 'react';
import React__default from 'react';
import classNames from 'classnames';
import styled from '@emotion/styled';
import { Box } from '@mantine/core';
import { M as MediaQueries } from './utils-538169b3.js';
import { theme } from './miscTheme.js';
import { u as useTranslations } from './index-09d9e570.js';
import { T as Text } from './index-0b67696c.js';
/* eslint-disable prettier/prettier */
const ShoppingCartCare = (props) => (React.createElement("svg", Object.assign({ width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "none" }, props),
React.createElement("path", { d: "M1.94434 1.94434L3.44545 2.31989C3.88211 2.42878 4.20989 2.791 4.27545 3.23656L5.55656 11.9454", stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round" }),
React.createElement("path", { d: "M16.9444 14.7218H4.99997C4.23331 14.7218 3.61108 14.0996 3.61108 13.3329C3.61108 12.5662 4.23331 11.944 4.99997 11.944H14.4766C14.9544 11.944 15.38 11.6385 15.5311 11.184L17.0122 6.73957C17.2522 6.01957 16.7166 5.27734 15.9578 5.27734H4.57553", stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", strokeLinejoin: "round" }),
React.createElement("path", { d: "M4.16648 18.8891C4.93354 18.8891 5.55537 18.2673 5.55537 17.5002C5.55537 16.7332 4.93354 16.1113 4.16648 16.1113C3.39941 16.1113 2.77759 16.7332 2.77759 17.5002C2.77759 18.2673 3.39941 18.8891 4.16648 18.8891Z", fill: "currentColor" }),
React.createElement("path", { d: "M15.8332 18.8891C16.6003 18.8891 17.2221 18.2673 17.2221 17.5002C17.2221 16.7332 16.6003 16.1113 15.8332 16.1113C15.0662 16.1113 14.4443 16.7332 14.4443 17.5002C14.4443 18.2673 15.0662 18.8891 15.8332 18.8891Z", fill: "currentColor" })));
const StyledCartCareBox = styled(Box) `
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
border: 1px solid #ffffff33;
position: relative;
flex-shrink: 0;
cursor: pointer;
/* Desktop: Square layout */
border-radius: 28px;
max-height: 40px;
padding: 9px 1rem;
background-color: inherit;
white-space: nowrap;
.cart-care-icon {
width: 20px;
height: 20px;
color: ${theme.colors.white};
flex-shrink: 0;
}
.cart-care-button-text {
display: block;
font-size: 14px;
font-weight: 500;
line-height: 22px;
}
/* Mobile: Circle layout */
${MediaQueries.mbDown} {
border-radius: 100%;
aspect-ratio: 1/1;
width: 32px;
height: 32px;
padding: auto;
background-color: ${theme.colors.white};
max-height: none;
padding: 0;
.cart-care-icon {
width: 20px;
height: 20px;
color: ${theme.colors.blue900};
flex-shrink: 0;
}
.cart-care-button-text {
display: none;
}
}
`;
const StyledCartCareButtonCount = styled(Box) `
min-width: 20px;
min-height: 20px;
aspect-ratio: 1/1;
border-radius: 100%;
background-color: ${theme.colors.red500};
color: ${theme.colors.white};
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
position: absolute;
top: -4px;
right: -4px;
${MediaQueries.mbDown} {
top: -8px;
right: -8px;
}
`;
const CartCareButton = (props) => {
const { count = 0, href, classes, boxProps, anchorProps, tracking } = props;
const { t } = useTranslations();
return (React__default.createElement("a", Object.assign({ className: classNames('cart-care-button'), href: href, "data-testid": "cart-care-button", "data-event-category": "Hamburger Navigation", "data-event-action": "Cart Click", "data-event-label": href }, tracking, anchorProps),
React__default.createElement(StyledCartCareBox, Object.assign({ className: classNames('cart-care-button-box', classes === null || classes === void 0 ? void 0 : classes.box) }, boxProps),
React__default.createElement(ShoppingCartCare, { className: "cart-care-icon" }),
React__default.createElement(Text, { size: "label1", color: theme.colors.white, fw: 500, className: "cart-care-button-text" }, t('navigation.button.cartCareService')),
count > 0 && (React__default.createElement(StyledCartCareButtonCount, { className: classNames('cart-care-button-count-box', classes === null || classes === void 0 ? void 0 : classes.count) },
React__default.createElement(Text, { size: count > 99 ? 'label2' : 'c1', color: theme.colors.white, fw: 600, className: "cart-care-button-count-text" }, count > 99 ? '99+' : count))))));
};
export { CartCareButton as C, ShoppingCartCare as S };