({ track }: Props)
| 15 | |
| 16 | const DEFAULT_VISIBLE_GUIDES = 4 |
| 17 | export const LearningTrack = ({ track }: Props) => { |
| 18 | const [numVisible, setNumVisible] = useState(DEFAULT_VISIBLE_GUIDES) |
| 19 | const { t } = useTranslation('product_guides') |
| 20 | const titleSlug = track?.title ? slug(track?.title) : '' |
| 21 | const showAll = () => { |
| 22 | setNumVisible(track?.guides?.length || 0) |
| 23 | } |
| 24 | |
| 25 | return ( |
| 26 | <div data-testid="learning-track" className="my-3 px-4 col-12 col-md-6"> |
| 27 | <div className="Box d-flex flex-column"> |
| 28 | <div className="Box-header color-bg-subtle p-4 d-flex flex-1 flex-items-start flex-wrap"> |
| 29 | <div className="d-flex flex-auto flex-items-start col-7 col-md-7 col-xl-7"> |
| 30 | <div className="my-xl-0 mr-xl-3"> |
| 31 | <h3 |
| 32 | id={titleSlug} |
| 33 | className={cx('mb-3 color-text f3 text-semibold', styles.hashAnchor)} |
| 34 | > |
| 35 | <a className="color-unset" href={`#${titleSlug}`}> |
| 36 | {track?.title} |
| 37 | </a> |
| 38 | </h3> |
| 39 | <TruncateLines as="p" maxLines={3} className="color-text"> |
| 40 | {track?.description} |
| 41 | </TruncateLines> |
| 42 | </div> |
| 43 | </div> |
| 44 | <Link |
| 45 | {...{ 'aria-label': `${track?.title} - ${t('start_path')}` }} |
| 46 | className="d-inline-flex btn no-wrap mt-3 mt-md-0 flex-items-center flex-justify-center" |
| 47 | href={`${track?.guides && track?.guides[0].href}?learn=${ |
| 48 | track?.trackName |
| 49 | }&learnProduct=${track?.trackProduct}`} |
| 50 | > |
| 51 | <span>{t('start_path')}</span> |
| 52 | <ArrowRightIcon size={20} className="ml-2" /> |
| 53 | </Link> |
| 54 | </div> |
| 55 | |
| 56 | {track && track.guides && ( |
| 57 | <div style={{ counterReset: 'li' }}> |
| 58 | <ActionList as="ol" variant="full"> |
| 59 | {track?.guides?.slice(0, numVisible).map((guide) => { |
| 60 | return ( |
| 61 | <ActionList.Item |
| 62 | as="li" |
| 63 | key={guide.href + track?.trackName} |
| 64 | className="width-full p-0" |
| 65 | sx={{ |
| 66 | position: 'relative', |
| 67 | borderRadius: 0, |
| 68 | ':hover': { |
| 69 | borderRadius: 0, |
| 70 | }, |
| 71 | ':before': { |
| 72 | width: 'calc(1.5rem - 0px)', |
| 73 | height: 'calc(1.5rem - 0px)', |
| 74 | fontSize: 'calc(1rem - 1px)', |
nothing calls this directly
no test coverage detected