UNPKG

@hhgtech/hhg-components

Version:
37 lines (34 loc) 1.89 kB
import { _ as __rest } from './tslib.es6-ea4dfe68.js'; import React__default, { useMemo } from 'react'; import { Spoiler as Spoiler$1 } from '@mantine/core'; import { T as Text } from './index-9f5659e8.js'; import { u as useTranslations } from './index-9d21b711.js'; import { theme } from './miscTheme.js'; const Spoiler = (_a) => { var { children, line, lineHeight, trackingAttributes, maxHeight: _maxHeight, customExpandFn } = _a, rest = __rest(_a, ["children", "line", "lineHeight", "trackingAttributes", "maxHeight", "customExpandFn"]); const { t } = useTranslations(); const maxHeight = useMemo(() => { if (_maxHeight) return _maxHeight; if (line && lineHeight) return line * lineHeight; console.error('[HHG-Comp]:[Spoiler] Please provide maxHeight, or line with lineHeight'); return 0; }, []); if (!children) console.error('[HHG-Comp]:[Spoiler] Please provide children'); const gaAttributes = useMemo(() => { if (trackingAttributes) { return { 'data-event-category': trackingAttributes.dataEventCategory, 'data-event-action': trackingAttributes.dataEventAction, 'data-event-label': trackingAttributes.dataEventLabel, }; } else { return {}; } }, [trackingAttributes]); return (React__default.createElement(Spoiler$1, Object.assign({ showLabel: React__default.createElement(Text, Object.assign({ size: "p3", color: theme.colors.primaryBase }, gaAttributes, { onClick: customExpandFn }), t('articlePage.readMore')), hideLabel: React__default.createElement(Text, Object.assign({ size: "p3", color: theme.colors.primaryBase }, gaAttributes), t('articlePage.showLess')) }, rest, { maxHeight: maxHeight }), children)); }; export { Spoiler as S };