1
0
mirror of synced 2026-01-04 09:06:46 -05:00
Files
docs/components/landing/ArticleList.tsx
Kevin Heis 9f7c20dae8 Upgrade Primer CSS to version 17, removing marketing styles (#20965)
* Package updates

* Fix up things that look broken

* Add to utils

* Lead now just sets font size, just use f3 where needed

* Update package-lock.json

* Update index.tsx

* Delete bump-link.scss

* Update trigger-error.js

* Update components/GenericError.tsx

Co-authored-by: Ash Guillaume <10384315+ashygee@users.noreply.github.com>

* Update ArticlePage.tsx

* Update ActionBar.tsx

* Changes from meeting

* Found a few more monos

* Fix from a merge conflict

* Missed a few f3s

* Update SubLandingHero.tsx

* Bye gradients

* Match up breadcrumbs

* Update SubLandingHero.tsx

* Update lists.scss

Co-authored-by: Ash Guillaume <10384315+ashygee@users.noreply.github.com>
2021-08-31 14:49:39 -07:00

91 lines
2.7 KiB
TypeScript

import cx from 'classnames'
import dayjs from 'dayjs'
import { Link } from 'components/Link'
import { ArrowRightIcon } from '@primer/octicons-react'
import { FeaturedLink } from 'components/context/ProductLandingContext'
import { TruncateLines } from 'components/TruncateLines'
import { BumpLink } from 'components/ui/BumpLink'
type Props = {
title?: string
viewAllHref?: string
articles: Array<FeaturedLink>
variant?: 'compact' | 'spaced'
titleVariant?: 'large' | 'default'
}
export const ArticleList = ({
title,
viewAllHref,
articles,
variant = 'compact',
titleVariant = 'default',
}: Props) => {
return (
<>
{title && (
<div className="mb-4 d-flex flex-items-baseline">
<h3
className={cx(
titleVariant === 'large'
? 'f4 font-weight-semibold'
: 'f5 text-normal underline-dashed color-text-secondary'
)}
>
{title}
</h3>
{viewAllHref && (
<Link href={viewAllHref} className="ml-4">
View all <ArrowRightIcon size={14} className="v-align-middle" />
</Link>
)}
</div>
)}
<ul className="list-style-none" data-testid="article-list">
{articles.map((link) => {
return (
<li key={link.href} className={cx(variant === 'compact' && 'border-top')}>
<BumpLink
as={Link}
href={link.href}
className="py-3"
title={
<h4 data-testid="link-with-intro-title">
<span
dangerouslySetInnerHTML={
link.fullTitle ? { __html: link.fullTitle } : { __html: link.title }
}
/>
</h4>
}
>
{!link.hideIntro && link.intro && (
<TruncateLines
as="p"
maxLines={variant === 'spaced' ? 6 : 2}
className="color-text-secondary mb-0 mt-1"
>
<span
data-testid="link-with-intro-intro"
dangerouslySetInnerHTML={{ __html: link.intro }}
/>
</TruncateLines>
)}
{link.date && (
<time
className="tooltipped tooltipped-n color-text-tertiary text-mono mt-1"
aria-label={dayjs(link.date).format('LLL')}
>
{dayjs(link.date).format('MMMM DD')}
</time>
)}
</BumpLink>
</li>
)
})}
</ul>
</>
)
}