UNPKG

@finos/legend-application-marketplace

Version:
36 lines 2.7 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; /** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import {} from 'react'; import { Button } from '@mui/material'; import DOMPurify from 'dompurify'; import { LegendMarketplaceCard } from '../MarketplaceCard/LegendMarketplaceCard.js'; const MAX_DESCRIPTION_LENGTH = 250; export const LegendMarketplaceProductSearchCard = (props) => { const { productSearchResult, onPreviewClick, onLearnMoreClick } = props; const descriptionSnippet = productSearchResult.data_product_description.substring(0, MAX_DESCRIPTION_LENGTH); const truncatedDescriptionSnippet = `${descriptionSnippet.substring(0, descriptionSnippet.lastIndexOf(' '))}...`; const descriptionHTML = { __html: productSearchResult.data_product_description.length > MAX_DESCRIPTION_LENGTH ? DOMPurify.sanitize(truncatedDescriptionSnippet) : DOMPurify.sanitize(productSearchResult.data_product_description), }; const content = (_jsxs(_Fragment, { children: [_jsx("div", { className: "legend-marketplace-product-search-result-card__vendor-name", children: productSearchResult.vendor_name }), _jsx("div", { className: "legend-marketplace-product-search-result-card__data-product-name", children: productSearchResult.data_product_name }), _jsx("div", { className: "legend-marketplace-product-search-result-card__data-product-description", children: productSearchResult.data_product_description.length > 0 && (_jsx("div", { dangerouslySetInnerHTML: descriptionHTML })) })] })); const actions = (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outlined", onClick: () => onPreviewClick(productSearchResult), children: "Preview" }), productSearchResult.data_product_link && (_jsx(Button, { variant: "contained", onClick: () => onLearnMoreClick(productSearchResult), children: "Learn More" }))] })); return (_jsx(LegendMarketplaceCard, { size: "large", content: content, actions: actions, className: "legend-marketplace-product-search-result-card" })); }; //# sourceMappingURL=LegendMarketplaceDataProductSearchCard.js.map