|
1 |
| -import cx from 'classnames' |
2 | 1 | import { useProductGuidesContext } from 'src/landings/components/ProductGuidesContext'
|
3 |
| -import { ArrowRightIcon, StarFillIcon } from '@primer/octicons-react' |
4 |
| -import { useTranslation } from 'components/hooks/useTranslation' |
5 |
| -import { Link } from 'components/Link' |
6 |
| -import { TruncateLines } from 'components/ui/TruncateLines' |
7 | 2 | import { Lead } from 'components/ui/Lead'
|
8 |
| -import styles from './GuidesHero.module.scss' |
9 | 3 |
|
10 |
| -export const GuidesHero = () => { |
11 |
| - const { title, intro, featuredTrack } = useProductGuidesContext() |
12 |
| - const { t } = useTranslation('product_guides') |
13 |
| - const cardWidth = 280 |
14 |
| - const firstCardWidth = cardWidth + 10 // so the english text doesn't wrap |
15 |
| - |
16 |
| - const guideItems = featuredTrack?.guides?.map((guide) => ( |
17 |
| - <li className="px-2 d-flex flex-shrink-0" key={guide.href} style={{ width: cardWidth }}> |
18 |
| - <Link |
19 |
| - href={`${guide.href}?learn=${featuredTrack.trackName}&learnProduct=${featuredTrack.trackProduct}`} |
20 |
| - className="d-inline-block Box p-5 color-bg-default color-border-default no-underline" |
21 |
| - > |
22 |
| - <div className="d-flex flex-justify-between flex-items-center"> |
23 |
| - <div |
24 |
| - className="color-bg-default color-fg-accent border d-inline-flex flex-items-center flex-justify-center circle" |
25 |
| - style={{ width: 40, height: 40 }} |
26 |
| - > |
27 |
| - {featuredTrack.guides && ( |
28 |
| - <span className="f2 lh-condensed-ultra text-center text-bold"> |
29 |
| - {featuredTrack.guides?.indexOf(guide) + 1} |
30 |
| - </span> |
31 |
| - )} |
32 |
| - </div> |
33 |
| - <div className="color-fg-muted h6 text-uppercase"> |
34 |
| - {t('guide_types')[guide.page?.type || '']} |
35 |
| - </div> |
36 |
| - </div> |
37 |
| - <h3 className="text-semibold my-4 color-fg-default">{guide.title}</h3> |
38 |
| - <TruncateLines maxLines={8} className="color-fg-muted f5 my-4"> |
39 |
| - <span dangerouslySetInnerHTML={{ __html: guide.intro }} /> |
40 |
| - </TruncateLines> |
41 |
| - </Link> |
42 |
| - </li> |
43 |
| - )) |
| 4 | +export function GuidesHero() { |
| 5 | + const { title, intro } = useProductGuidesContext() |
44 | 6 |
|
45 | 7 | return (
|
46 | 8 | <div>
|
47 |
| - <header className="d-flex gutter mb-6 my-4"> |
| 9 | + <header className="gutter mb-6 my-4"> |
48 | 10 | <div className="col-12">
|
49 | 11 | <h1 id="title-h1">{title}</h1>
|
50 | 12 | {intro && <Lead data-search="lead">{intro}</Lead>}
|
51 | 13 | </div>
|
52 | 14 | </header>
|
53 |
| - {featuredTrack && featuredTrack.guides && featuredTrack.guides.length > 0 && ( |
54 |
| - <div className="mb-6 position-relative overflow-hidden mr-n3 ml-n3 px-3"> |
55 |
| - <ul |
56 |
| - data-testid="feature-track" |
57 |
| - className="list-style-none d-flex flex-nowrap overflow-x-scroll px-2" |
58 |
| - > |
59 |
| - <li className="px-2 d-flex flex-shrink-0" style={{ width: firstCardWidth }}> |
60 |
| - <div className="d-inline-block Box p-5 color-bg-subtle"> |
61 |
| - <div |
62 |
| - className="d-inline-flex flex-items-center flex-justify-center circle border" |
63 |
| - style={{ width: 40, height: 40, border: '2px white solid' }} |
64 |
| - > |
65 |
| - <StarFillIcon size={24} /> |
66 |
| - </div> |
67 |
| - <h2 className="text-semibold my-4 f3">{featuredTrack.title}</h2> |
68 |
| - <div className="f5 my-4">{featuredTrack.description}</div> |
69 |
| - <Link |
70 |
| - {...{ 'aria-label': `${featuredTrack.title} - ${t('start_path')}` }} |
71 |
| - className="d-inline-flex flex-items-center flex-justify-center btn ws-normal px-4 py-2 f5 no-underline text-bold" |
72 |
| - role="button" |
73 |
| - href={`${featuredTrack.guides[0].href}?learn=${featuredTrack.trackName}&learnProduct=${featuredTrack.trackProduct}`} |
74 |
| - > |
75 |
| - {t(`start_path`)} |
76 |
| - <ArrowRightIcon size={20} className="ml-2" /> |
77 |
| - </Link> |
78 |
| - </div> |
79 |
| - </li> |
80 |
| - {guideItems} |
81 |
| - </ul> |
82 |
| - <div |
83 |
| - className={cx('position-absolute top-0 bottom-0 left-0 ml-3 pl-3', styles.fadeLeft)} |
84 |
| - ></div> |
85 |
| - <div |
86 |
| - className={cx('position-absolute top-0 bottom-0 right-0 mr-3 pr-3', styles.fadeRight)} |
87 |
| - ></div> |
88 |
| - </div> |
89 |
| - )} |
90 | 15 | </div>
|
91 | 16 | )
|
92 | 17 | }
|
0 commit comments