UNPKG

@hhgtech/hhg-components

Version:
43 lines (37 loc) 2.09 kB
'use strict'; var tslib_es6 = require('./tslib.es6-92cccef3.js'); var React = require('react'); var core = require('@mantine/core'); var index$1 = require('./index-25f2e7a5.js'); var index = require('./index-c2c283f8.js'); var miscTheme = require('./miscTheme.js'); function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } var React__default = /*#__PURE__*/_interopDefault(React); const Spoiler = (_a) => { var { children, line, lineHeight, trackingAttributes, maxHeight: _maxHeight, customExpandFn } = _a, rest = tslib_es6.__rest(_a, ["children", "line", "lineHeight", "trackingAttributes", "maxHeight", "customExpandFn"]); const { t } = index.useTranslations(); const maxHeight = React.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 = React.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["default"].createElement(core.Spoiler, Object.assign({ showLabel: React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3", color: miscTheme.theme.colors.primaryBase }, gaAttributes, { onClick: customExpandFn }), t('articlePage.readMore')), hideLabel: React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3", color: miscTheme.theme.colors.primaryBase }, gaAttributes), t('articlePage.showLess')) }, rest, { maxHeight: maxHeight }), children)); }; exports.Spoiler = Spoiler;