Skip to content

Commit 8845b5d

Browse files
committed
Makes bookmark optional on tutorial cards
Allows tutorial cards to be displayed without a bookmark button. This change provides the flexibility to display tutorial cards in contexts where bookmarking functionality is not desired or applicable. Specifically, it disables the bookmark button within the tutorial cards grid list.
1 parent 7500fbe commit 8845b5d

File tree

4 files changed

+169
-169
lines changed

4 files changed

+169
-169
lines changed

src/components/cards-grid-list/components/tutorial-cards-grid-list/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const TutorialCardsGridList = ({ tutorials, ...restProps }) => {
3030
tutorialIds.push(tutorial.id)
3131
cardsGridListItems.push(
3232
<div className={s.sandboxCardBox} key={tutorial.id}>
33-
<TutorialCardWithAuthElements {...tutorial} />
33+
<TutorialCardWithAuthElements {...tutorial} hasBookmark={false} />
3434
</div>
3535
)
3636
})

src/components/tutorial-card/helpers/with-auth-elements.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getSpeakableDuration } from './build-aria-label'
1919
export function TutorialCardWithAuthElements({
2020
id: tutorialId,
2121
collectionId,
22+
hasBookmark = true,
2223
BookmarkButtonComponent = TutorialCardBookmarkButton,
2324
...restProps
2425
}: TutorialCardPropsWithId) {
@@ -58,9 +59,11 @@ export function TutorialCardWithAuthElements({
5859
) : (
5960
<CardEyebrowText>{restProps.duration}</CardEyebrowText>
6061
)}
61-
<BookmarkButtonComponent
62-
tutorial={{ id: tutorialId, name: restProps.heading }}
63-
/>
62+
{hasBookmark && (
63+
<BookmarkButtonComponent
64+
tutorial={{ id: tutorialId, name: restProps.heading }}
65+
/>
66+
)}
6467
</>
6568
}
6669
/>

src/components/tutorial-card/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export interface TutorialCardPropsWithId extends TutorialCardProps {
7777
* achieve this flexibility. We default to our basic bookmark button
7878
* if BookmarkButtonComponent is not provided.
7979
*/
80+
hasBookmark?: boolean
81+
/**
82+
*
83+
* A component that renders a bookmark button for the tutorial.
84+
*
85+
*/
8086
BookmarkButtonComponent?: ({
8187
tutorial,
8288
}: {

0 commit comments

Comments
 (0)