UNPKG

@git-temporal/git-temporal-react

Version:

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

53 lines (52 loc) 1.75 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const styles_1 = require("app/styles"); const containerStyle = { _extends: ['normalText', 'block'], position: 'relative', marginLeft: 10, }; const constrainedStyle = { maxHeight: 70, overflow: 'hidden', marginBottom: 10, boxShadow: 'rgba(245, 245, 245, 0.5) 0px -34px 11px -18px inset', }; const constrainedIndicatorStyle = { position: 'absolute', bottom: 0, display: 'block', height: 20, width: '100%', background: 'linear-gradient(#ffffff00, white)', }; const breakLineStyle = { display: 'block', marginBottom: 5, }; const renderBreakLine = (line, index) => { return (react_1.default.createElement("div", { key: index, style: styles_1.style(breakLineStyle) }, line)); }; const renderBrText = text => { return text.split(/\<br\>/gi).map(renderBreakLine); }; const renderContstrainedIndicator = isExpanded => { return isExpanded ? null : react_1.default.createElement("div", { style: styles_1.style(constrainedIndicatorStyle) }); }; exports.CommitBody = (props) => { if (!props.text || props.text.replace(/\s/g, '') === '') { return null; } const styles = [containerStyle, props.style]; if (!props.isExpanded) { styles.push(constrainedStyle); } return (react_1.default.createElement("div", { style: styles_1.style(styles) }, renderBrText(props.text), renderContstrainedIndicator(props.isExpanded))); }; exports.CommitBody.displayName = 'CommitBody';