1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/components/landing/CodeExampleCard.tsx
Grace Park 0afdf66a08 Primer Update: Table of Contents (#22933)
* update to ActionList

* fix nested mini tocs

* adding key

* remove li and fix tests

* update font size to 14px

* remove border radius
2021-11-18 00:27:12 +00:00

45 lines
1.4 KiB
TypeScript

import { RepoIcon } from '@primer/octicons-react'
import { CodeExample } from 'components/context/ProductLandingContext'
import { TruncateLines } from 'components/ui/TruncateLines'
import { Label } from '@primer/components'
type Props = {
example: CodeExample
}
export const CodeExampleCard = ({ example }: Props) => {
return (
<a
className="Box d-flex flex-column flex-justify-between height-full color-shadow-medium hover-shadow-large no-underline color-fg-default"
data-testid="code-example-card"
href={`https://github.com/${example.href}`}
>
<div className="p-4">
<h4 dangerouslySetInnerHTML={{ __html: example.title }} />
<p
className="mt-2 mb-4 color-fg-muted"
dangerouslySetInnerHTML={{ __html: example.description }}
/>
<div className="d-flex flex-wrap">
{example.tags.map((tag) => {
return (
<Label key={tag} variant="small" sx={{ bg: 'accent.emphasis', mb: 1, mr: 2 }}>
{tag}
</Label>
)
})}
</div>
</div>
<footer className="border-top p-4 color-fg-muted d-flex flex-items-center">
<RepoIcon className="flex-shrink-0" />
<TruncateLines
as="span"
maxLines={1}
className="ml-2 text-mono text-small color-fg-accent line-break-anywhere"
>
{example.href}
</TruncateLines>
</footer>
</a>
)
}