Skip to content

Commit

Permalink
Merge pull request #11622 from github/repo-sync
Browse files Browse the repository at this point in the history
repo sync
  • Loading branch information
Octomerger authored Nov 2, 2021
2 parents d6bb1af + 58d3867 commit 6f4f537
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions components/sublanding/LearningTrack.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.fadeBottom {
background: linear-gradient(to top, var(--color-canvas-default), transparent);
}

/* Because of the sticky header */
.hashAnchor {
&:target {
scroll-margin-top: 75px;
}
}
8 changes: 7 additions & 1 deletion components/sublanding/LearningTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ArrowRightIcon } from '@primer/octicons-react'
import { useState } from 'react'
import { FeaturedTrack } from 'components/context/ProductSubLandingContext'
import { TruncateLines } from 'components/ui/TruncateLines'
import slugger from 'github-slugger'
import styles from './LearningTrack.module.scss'

type Props = {
Expand All @@ -17,14 +18,19 @@ export const LearningTrack = ({ track }: Props) => {
setNumVisible(track?.guides?.length || 0)
}
const { t } = useTranslation('product_sublanding')
const slug = track?.title ? slugger.slug(track?.title) : ''

return (
<div data-testid="learning-track" className="my-3 px-4 col-12 col-md-6">
<div className="Box d-flex flex-column">
<div className="Box-header color-bg-subtle p-4 d-flex flex-1 flex-items-start flex-wrap">
<div className="d-flex flex-auto flex-items-start col-8 col-md-12 col-xl-8">
<div className="my-xl-0 mr-xl-3">
<h5 className="mb-3 color-text f3 text-semibold">{track?.title}</h5>
<h5 id={slug} className={cx('mb-3 color-text f3 text-semibold', styles.hashAnchor)}>
<a className="color-unset" href={`#${slug}`}>
{track?.title}
</a>
</h5>
<TruncateLines as="p" maxLines={3} className="color-text">
{track?.description}
</TruncateLines>
Expand Down
2 changes: 1 addition & 1 deletion tests/rendering/learning-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('learning tracks', () => {
const $ = await getDOM('/en/code-security/guides')
expect($('[data-testid=learning-track]').length).toBeGreaterThanOrEqual(4)
$('[data-testid=learning-track]').each((i, trackElem) => {
const href = $(trackElem).find('.Box-header a').first().attr('href')
const href = $(trackElem).find('.Box-header a:nth-child(2)').first().attr('href')
const found = href.match(/.*\?learn=(.*)/i)
expect(found).not.toBeNull()
const trackName = found[1]
Expand Down

0 comments on commit 6f4f537

Please sign in to comment.