|
| 1 | +/** |
| 2 | + * Copyright (c) HashiCorp, Inc. |
| 3 | + * SPDX-License-Identifier: MPL-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +import React from 'react' |
| 7 | +import { ProductSlug } from 'types/products' |
| 8 | +import Card from 'components/card' |
| 9 | +import CardTitle from 'components/card/components/card-title' |
| 10 | +import CardDescription from 'components/card/components/card-description' |
| 11 | +import CardFooter from 'components/card/components/card-footer' |
| 12 | +import ButtonLink from 'components/button-link' |
| 13 | +import ProductIcon from 'components/product-icon' |
| 14 | +import s from './sandbox-card.module.css' |
| 15 | + |
| 16 | +export interface SandboxCardProps { |
| 17 | + title: string |
| 18 | + description: string |
| 19 | + labId: string |
| 20 | + products: string[] |
| 21 | + onLaunch: () => void |
| 22 | + className?: string |
| 23 | +} |
| 24 | + |
| 25 | +const SandboxCard: React.FC<SandboxCardProps> = ({ |
| 26 | + title, |
| 27 | + description, |
| 28 | + labId, |
| 29 | + products, |
| 30 | + onLaunch, |
| 31 | + className, |
| 32 | +}) => { |
| 33 | + return ( |
| 34 | + <div className={`${s.sandboxCardWrapper} ${className || ''}`}> |
| 35 | + <Card className={s.sandboxCard}> |
| 36 | + <div className={s.cardHeader}> |
| 37 | + <CardTitle text={title} /> |
| 38 | + <div className={s.productIcons}> |
| 39 | + {products.map((productSlug) => ( |
| 40 | + <ProductIcon |
| 41 | + key={`product-${labId}-${productSlug}`} |
| 42 | + productSlug={productSlug as ProductSlug} |
| 43 | + size={16} |
| 44 | + className={s.productIcon} |
| 45 | + /> |
| 46 | + ))} |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + <CardDescription text={description} className={s.description} /> |
| 50 | + <CardFooter className={s.footer}> |
| 51 | + <ButtonLink |
| 52 | + href="#" |
| 53 | + className={s.launchButton} |
| 54 | + aria-label={`Launch ${title} Sandbox`} |
| 55 | + onClick={(e) => { |
| 56 | + e.preventDefault() |
| 57 | + e.stopPropagation() |
| 58 | + onLaunch() |
| 59 | + }} |
| 60 | + size="medium" |
| 61 | + text="Launch Sandbox" |
| 62 | + /> |
| 63 | + </CardFooter> |
| 64 | + </Card> |
| 65 | + </div> |
| 66 | + ) |
| 67 | +} |
| 68 | + |
| 69 | +export default SandboxCard |
0 commit comments