Skip to content

Commit 9d79148

Browse files
authored
ActionList for LearningTracks (#23335)
* ActionList for LearningTracks * Try to resolve TS error
1 parent ea4a5f1 commit 9d79148

1 file changed

Lines changed: 52 additions & 24 deletions

File tree

components/guides/LearningTrack.tsx

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cx from 'classnames'
22
import { useTranslation } from 'components/hooks/useTranslation'
33
import { ArrowRightIcon } from '@primer/octicons-react'
4+
import { ActionList } from '@primer/components'
45
import { useState } from 'react'
56
import { FeaturedTrack } from 'components/context/ProductGuidesContext'
67
import { TruncateLines } from 'components/ui/TruncateLines'
@@ -48,30 +49,57 @@ export const LearningTrack = ({ track }: Props) => {
4849
</a>
4950
</div>
5051

51-
{track?.guides?.slice(0, numVisible).map((guide) => (
52-
<div key={guide.href + track?.trackName}>
53-
<a
54-
className="Box-row d-flex flex-items-center color-fg-default no-underline"
55-
href={`${guide.href}?learn=${track?.trackName}&learnProduct=${track?.trackProduct}`}
56-
>
57-
<div
58-
className="color-bg-subtle d-inline-flex mr-4 circle flex-items-center flex-justify-center"
59-
style={{ width: 32, height: 32 }}
60-
>
61-
{track?.guides && (
62-
<span className="m-2 f3 lh-condensed-ultra text-center text-bold step-circle-text">
63-
{track.guides?.indexOf(guide) + 1}
64-
</span>
65-
)}
66-
</div>
67-
<h5 className="flex-auto pr-2" dangerouslySetInnerHTML={{ __html: guide.title }} />
68-
<div className="color-fg-muted h6 text-uppercase flex-shrink-0">
69-
{t('guide_types')[guide.page?.type || '']}
70-
</div>
71-
</a>
72-
</div>
73-
))}
74-
52+
{track && track.guides && (
53+
<ActionList
54+
{...{ as: 'ul' }}
55+
items={track?.guides?.slice(0, numVisible).map((guide) => {
56+
return {
57+
renderItem: () => (
58+
<ActionList.Item
59+
as="li"
60+
key={guide.href + track?.trackName}
61+
sx={{
62+
borderRadius: 0,
63+
padding: 0,
64+
':hover': {
65+
borderRadius: 0,
66+
},
67+
':last-of-type': {
68+
marginBottom: '-8px',
69+
},
70+
':first-of-type': {
71+
marginTop: '-8px',
72+
},
73+
}}
74+
>
75+
<a
76+
className="rounded-0 width-full d-block Box-row d-flex flex-items-center color-fg-default no-underline"
77+
href={`${guide.href}?learn=${track?.trackName}&learnProduct=${track?.trackProduct}`}
78+
>
79+
<div
80+
className="color-bg-subtle d-inline-flex mr-4 circle flex-items-center flex-justify-center"
81+
style={{ width: 32, height: 32 }}
82+
>
83+
{track?.guides && (
84+
<span className="m-2 f3 lh-condensed-ultra text-center text-bold step-circle-text">
85+
{track.guides?.indexOf(guide) + 1}
86+
</span>
87+
)}
88+
</div>
89+
<h5
90+
className="flex-auto pr-2"
91+
dangerouslySetInnerHTML={{ __html: guide.title }}
92+
/>
93+
<div className="color-fg-muted h6 text-uppercase flex-shrink-0">
94+
{t('guide_types')[guide.page?.type || '']}
95+
</div>
96+
</a>
97+
</ActionList.Item>
98+
),
99+
}
100+
})}
101+
></ActionList>
102+
)}
75103
{(track?.guides?.length || 0) > numVisible ? (
76104
<button
77105
className="Box-footer btn-link border-top-0 position-relative text-center text-bold color-fg-accent pt-1 pb-3 col-12"

0 commit comments

Comments
 (0)