Skip to content

Commit f8744c6

Browse files
committed
feat(frontend): enhance onboarding tour with media section navigation
1 parent cb338c6 commit f8744c6

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

apps/frontend/app/lib/state/general.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ export const tourSteps = [
66
{
77
id: "step-1",
88
content:
9-
"Welcome to Ryot! Let's get started by adding a movie to your watchlist. Click on the media section in the sidebar to see what all you can track.",
9+
"Welcome to Ryot! Let's get started by adding a movie to your watchlist.",
10+
//Click on the media section in the sidebar to see what all you can track.",
11+
},
12+
{
13+
id: "step-2",
14+
content:
15+
"Now, click on the movies section to start tracking your favorite movies.",
1016
},
1117
] as OnboardingTourStep[];
1218

apps/frontend/app/routes/_dashboard.tsx

+32-18
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
168168

169169
const mediaLinks = [
170170
...userPreferences.featuresEnabled.media.specific.map((f) => {
171-
return { label: f, href: undefined };
171+
return {
172+
label: f,
173+
href: undefined,
174+
tourStepId: f === MediaLot.Movie ? "step-2" : undefined,
175+
};
172176
}),
173177
userPreferences.featuresEnabled.media.groups
174178
? {
@@ -193,6 +197,7 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
193197
link
194198
? {
195199
label: changeCase(link.label),
200+
tourStepId: "tourStepId" in link ? link.tourStepId : undefined,
196201
link: link.href
197202
? link.href
198203
: $path("/media/:action/:lot", {
@@ -809,7 +814,7 @@ interface LinksGroupProps {
809814
toggle: () => void;
810815
tourStepId?: string;
811816
setOpened: (v: boolean) => void;
812-
links?: Array<{ label: string; link: string }>;
817+
links?: Array<{ label: string; link: string; tourStepId?: string }>;
813818
}
814819

815820
const LinksGroup = ({
@@ -823,23 +828,32 @@ const LinksGroup = ({
823828
tourStepId,
824829
}: LinksGroupProps) => {
825830
const { dir } = useDirection();
831+
826832
const hasLinks = Array.isArray(links);
827833
const ChevronIcon = dir === "ltr" ? IconChevronRight : IconChevronLeft;
828-
const allLinks = (hasLinks ? links || [] : []).filter((s) => s !== undefined);
829-
const items = allLinks.map((link) => (
830-
<NavLink
831-
to={link.link}
832-
key={link.label}
833-
onClick={toggle}
834-
className={classes.link}
835-
>
836-
{({ isActive }) => (
837-
<span style={isActive ? { textDecoration: "underline" } : undefined}>
838-
{link.label}
839-
</span>
840-
)}
841-
</NavLink>
842-
));
834+
const linkItems = (hasLinks ? links || [] : []).map((link) => {
835+
const component = (
836+
<NavLink
837+
to={link.link}
838+
key={link.label}
839+
onClick={toggle}
840+
className={classes.link}
841+
>
842+
{({ isActive }) => (
843+
<span style={isActive ? { textDecoration: "underline" } : undefined}>
844+
{link.label}
845+
</span>
846+
)}
847+
</NavLink>
848+
);
849+
if (link.tourStepId)
850+
return (
851+
<OnboardingTour.Target id={link.tourStepId}>
852+
{component}
853+
</OnboardingTour.Target>
854+
);
855+
return component;
856+
});
843857

844858
const component = (
845859
<Box>
@@ -878,7 +892,7 @@ const LinksGroup = ({
878892
) : null}
879893
</Group>
880894
</UnstyledButton>
881-
{hasLinks ? <Collapse in={opened}>{items}</Collapse> : null}
895+
{hasLinks ? <Collapse in={opened}>{linkItems}</Collapse> : null}
882896
</Box>
883897
);
884898

0 commit comments

Comments
 (0)