/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ import React, { ReactNode, useCallback } from "react"; import classNames from "classnames"; import styled from "styled-components"; import { Link } from "react-router-dom"; type Props = { link?: string; avatar?: ReactNode; title: ReactNode; description?: string; contentRight?: ReactNode; footerLeft: ReactNode; footerRight: ReactNode; action?: () => void; className?: string; }; const NoEventWrapper = styled.article` position: relative; pointer-events: none; z-index: 1; `; const InheritFlexShrinkDiv = styled.div` flex-shrink: inherit; pointer-events: all; `; const InvisibleButton = styled.button` background: none; border: none; cursor: pointer; `; const CardColumn = React.forwardRef( ({ link, avatar, title, description, contentRight, footerLeft, footerRight, action, className }, ref) => { const renderAvatar = avatar ?
{avatar}
: null; const renderDescription = description ?

{description}

: null; const renderContentRight = contentRight ?
{contentRight}
: null; const executeRef = useCallback( (el: HTMLButtonElement | HTMLAnchorElement | null) => { if (typeof ref === "function") { ref(el); } else if (ref) { ref.current = el; } }, [ref] ); let createLink = null; if (link) { createLink = ; } else if (action) { createLink = ( { e.preventDefault(); action(); }} tabIndex={0} /> ); } return ( <> {createLink} {renderAvatar}

{title}

{renderDescription}
{renderContentRight}
{footerLeft}
{footerRight}
); } ); export default CardColumn;