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 -->

58 lines (57 loc) 2.92 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 EpochDateTime_1 = require("app/components/EpochDateTime"); const AddedDeleted_1 = require("app/components/AddedDeleted"); const CommitBody_1 = require("app/components/CommitBody"); const CommitCardFiles_1 = require("app/components/CommitCardFiles"); const Selectable_1 = require("app/components/Selectable"); const defaultCardStyle = { _extends: ['card', 'block'], marginRight: 0, padding: 0, }; const dateLineStyle = { _extends: ['smallerText', 'block', 'flexRow'], }; const messageStyle = { _extends: ['largerText', 'block'], marginLeft: 5, }; const authorStyle = { _extends: ['normalText', 'block'], marginLeft: 5, }; const filesStyle = { _extends: ['block', 'normalText'], marginLeft: 10, marginRight: 20, marginBottom: 10, }; const dateDisplayOptions = { month: 'long', minute: 'numeric', }; exports.CommitCard = (props) => { const { commit, isExpanded, isHighlighted, onFileClick, onClick, onDoubleClick, index, } = props; const outerOverrideStyle = isHighlighted ? 'selected' : {}; return (react_1.default.createElement("div", { style: styles_1.style(defaultCardStyle, props.style, outerOverrideStyle) }, react_1.default.createElement(Selectable_1.Selectable, { testId: "commit-card", onClick: evt => onClick && onClick(evt, commit, index), onDoubleClick: evt => onDoubleClick && onDoubleClick(evt, commit, index) }, react_1.default.createElement("div", { style: styles_1.style(dateLineStyle) }, react_1.default.createElement(EpochDateTime_1.EpochDateTime, { value: commit.authorDate, displayOptions: dateDisplayOptions }), react_1.default.createElement("span", { style: { flexGrow: 1, textAlign: 'center' } }, commit.hash), react_1.default.createElement(AddedDeleted_1.AddedDeleted, { linesAdded: commit.linesAdded, linesDeleted: commit.linesDeleted })), react_1.default.createElement("div", { style: styles_1.style(messageStyle) }, commit.message), !props.hideCommitBody && (react_1.default.createElement(CommitBody_1.CommitBody, { text: commit.body, isExpanded: isExpanded })), !props.hideFiles && (react_1.default.createElement(CommitCardFiles_1.CommitCardFiles, { files: commit.files, isExpanded: isExpanded, style: filesStyle, onFileClick: onFileClick })), react_1.default.createElement("div", { style: styles_1.style(authorStyle) }, "Authored by ", commit.authorName, " ", commit.relativeDate)))); }; exports.CommitCard.displayName = 'CommitCard';