@navinc/base-react-components
Version:
Nav's Pattern Library
33 lines • 1.84 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import styled from 'styled-components';
import { Button } from './button.js';
import { Copy } from './copy.js';
import { Icon } from './icon.js';
export const HelperIcon = styled(Icon).withConfig({ displayName: "brc-sc-HelperIcon", componentId: "brc-sc-jf9smw" }) `
max-width: 16px;
max-height: 16px;
fill: ${({ theme }) => theme.navNeutral400};
`;
export const HelperDescription = styled(Copy).attrs(() => ({ size: 'sm', bold: true })).withConfig({ displayName: "brc-sc-HelperDescription", componentId: "brc-sc-1l0h8ab" }) `
color: inherit;
`;
const getHelperItemColor = (theme, isLink) => {
return !isLink && theme.navNeutral400;
};
export const HelperItem = styled.div.attrs(({ isLink }) => isLink && { as: Button, variation: 'buttonLink', type: 'button' }).withConfig({ displayName: "brc-sc-HelperItem", componentId: "brc-sc-12ewc8l" }) `
display: grid;
padding-top: 4px;
grid-template-columns: min-content 1fr;
grid-gap: 4px;
text-align: left;
${({ hasSpaceForErrors }) => (hasSpaceForErrors ? 'min-height: 18px;' : '')}
color: ${({ theme, isLink }) => getHelperItemColor(theme, isLink)}
`;
/**
* Helper is a tooltip component
*
* @returns ReactElement
*/
const _Helper = ({ className, hasSpaceForErrors, helperLinkAction, helperText, iconName = 'actions/circle-faq', }) => (_jsxs(HelperItem, { className: className, isLink: !!helperLinkAction, onClick: helperLinkAction, hasSpaceForErrors: hasSpaceForErrors, children: [iconName && _jsx(HelperIcon, { name: iconName }), _jsx(HelperDescription, { "data-testid": `input:helper-text:${helperText}`, light: true, children: helperText })] }));
export const Helper = styled(_Helper).withConfig({ displayName: "brc-sc-Helper", componentId: "brc-sc-1s1r0xb" }) ``;
//# sourceMappingURL=helper.js.map