Skip to content

Commit 8ce4b7c

Browse files
tried implementing corrections, so that ci/cd, lint etc. checks get passed
1 parent acf3b5f commit 8ce4b7c

File tree

8 files changed

+90
-88
lines changed

8 files changed

+90
-88
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"lint:md": "markdownlint '**/*.md' --ignore-path .prettierignore",
1616
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,json,css,md}'",
1717
"format:file": "prettier --write",
18-
"format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx,json,css,md}'"
18+
"format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx,json,css,md}'",
19+
"install:legacy": "npm install --legacy-peer-deps"
1920
},
2021
"dependencies": {
2122
"@tailwindcss/vite": "^4.1.14",

src/components/Onboarding.tsx

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React from 'react';
2-
import {
3-
OnboardingProvider,
4-
useOnboarding,
5-
} from '@/contexts/OnboardingContext';
2+
import { OnboardingProvider } from '@/contexts/OnboardingContext';
3+
import { OnboardingStep as OnboardingStepType } from '@/contexts/OnboardingContextDefinition';
4+
import { useOnboarding } from '@/hooks/useOnboarding';
65
import { getOnboardingStepsForPage } from '@/constants/OnboardingSteps';
76

87
interface OnboardingProps {
98
children: React.ReactNode;
109
pageType?: 'homepage' | 'try' | 'about' | 'news';
1110
showProgressIndicator?: boolean;
12-
customSteps?: any[];
11+
customSteps?: OnboardingStepType[];
1312
}
1413

1514
export const Onboarding: React.FC<OnboardingProps> = ({
@@ -72,34 +71,6 @@ const OnboardingContent: React.FC<{
7271

7372
// useOnboarding hook is imported above
7473

75-
// Add data attributes to elements for targeting
76-
export const addOnboardingIds = {
77-
sugarLabsLogo: () => ({
78-
'data-onboarding-id': 'sugar-labs-logo',
79-
className: 'sugar-labs-logo',
80-
}),
81-
mainNavigation: () => ({
82-
'data-onboarding-id': 'main-navigation',
83-
className: 'main-navigation',
84-
}),
85-
trySugarButton: () => ({
86-
'data-onboarding-id': 'try-sugar-button',
87-
className: 'try-sugar-button',
88-
}),
89-
activitiesSection: () => ({
90-
'data-onboarding-id': 'activities-section',
91-
className: 'activities-section',
92-
}),
93-
statsSection: () => ({
94-
'data-onboarding-id': 'stats-section',
95-
className: 'stats-section',
96-
}),
97-
donationSection: () => ({
98-
'data-onboarding-id': 'donation-section',
99-
className: 'donation-section',
100-
}),
101-
};
102-
10374
// Component to add onboarding trigger button
10475
export const OnboardingTrigger: React.FC<{
10576
className?: string;

src/components/OnboardingTrigger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { useOnboarding } from '@/contexts/OnboardingContext';
2+
import { useOnboarding } from '@/hooks/useOnboarding';
33

44
interface OnboardingTriggerProps {
55
className?: string;

src/contexts/OnboardingContext.tsx

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,10 @@
1-
import React, {
2-
createContext,
3-
useContext,
4-
useState,
5-
useEffect,
6-
ReactNode,
7-
} from 'react';
1+
import React, { useState, useEffect, ReactNode } from 'react';
82
import Joyride, { CallBackProps, STATUS, EVENTS } from 'react-joyride';
9-
10-
export interface OnboardingStep {
11-
target: string;
12-
content: ReactNode;
13-
placement?: 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'center';
14-
disableBeacon?: boolean;
15-
spotlightClicks?: boolean;
16-
hideCloseButton?: boolean;
17-
hideBackButton?: boolean;
18-
hideSkipButton?: boolean;
19-
title?: string;
20-
disableOverlayClose?: boolean;
21-
hideFooter?: boolean;
22-
}
23-
24-
export interface OnboardingContextType {
25-
isOnboardingActive: boolean;
26-
currentStep: number;
27-
totalSteps: number;
28-
startOnboarding: () => void;
29-
stopOnboarding: () => void;
30-
skipOnboarding: () => void;
31-
resetOnboarding: () => void;
32-
goToStep: (stepIndex: number) => void;
33-
goToNextStep: () => void;
34-
goToPreviousStep: () => void;
35-
onboardingCompleted: boolean;
36-
onboardingProgress: number;
37-
shouldShowTrigger: () => boolean;
38-
setRun: (run: boolean) => void;
39-
getRun: () => boolean;
40-
stepIndex: number;
41-
lifecycle: string | null;
42-
}
43-
44-
const OnboardingContext = createContext<OnboardingContextType | undefined>(
45-
undefined,
46-
);
3+
import {
4+
OnboardingContext,
5+
OnboardingStep,
6+
OnboardingContextType,
7+
} from './OnboardingContextDefinition';
478

489
const LOCAL_STORAGE_KEY = 'sugar-labs-onboarding';
4910
const ONBOARDING_STEPS_KEY = 'onboarding-steps';
@@ -329,11 +290,3 @@ export const OnboardingProvider: React.FC<OnboardingProviderProps> = ({
329290
</OnboardingContext.Provider>
330291
);
331292
};
332-
333-
export const useOnboarding = (): OnboardingContextType => {
334-
const context = useContext(OnboardingContext);
335-
if (!context) {
336-
throw new Error('useOnboarding must be used within an OnboardingProvider');
337-
}
338-
return context;
339-
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { createContext, ReactNode } from 'react';
2+
3+
export interface OnboardingStep {
4+
target: string;
5+
content: ReactNode;
6+
placement?: 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'center';
7+
disableBeacon?: boolean;
8+
spotlightClicks?: boolean;
9+
hideCloseButton?: boolean;
10+
hideBackButton?: boolean;
11+
hideSkipButton?: boolean;
12+
title?: string;
13+
disableOverlayClose?: boolean;
14+
hideFooter?: boolean;
15+
}
16+
17+
export interface OnboardingContextType {
18+
isOnboardingActive: boolean;
19+
currentStep: number;
20+
totalSteps: number;
21+
startOnboarding: () => void;
22+
stopOnboarding: () => void;
23+
skipOnboarding: () => void;
24+
resetOnboarding: () => void;
25+
goToStep: (stepIndex: number) => void;
26+
goToNextStep: () => void;
27+
goToPreviousStep: () => void;
28+
onboardingCompleted: boolean;
29+
onboardingProgress: number;
30+
shouldShowTrigger: () => boolean;
31+
setRun: (run: boolean) => void;
32+
getRun: () => boolean;
33+
stepIndex: number;
34+
lifecycle: string | null;
35+
}
36+
37+
export const OnboardingContext = createContext<OnboardingContextType | undefined>(
38+
undefined,
39+
);

src/hooks/useOnboarding.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { useContext } from 'react';
2+
import { OnboardingContext, OnboardingContextType } from '@/contexts/OnboardingContextDefinition';
3+
4+
export const useOnboarding = (): OnboardingContextType => {
5+
const context = useContext(OnboardingContext);
6+
if (!context) {
7+
throw new Error('useOnboarding must be used within an OnboardingProvider');
8+
}
9+
return context;
10+
};

src/utils/onboardingHelpers.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Helper functions for onboarding data attributes
2+
export const addOnboardingIds = {
3+
sugarLabsLogo: () => ({
4+
'data-onboarding-id': 'sugar-labs-logo',
5+
className: 'sugar-labs-logo',
6+
}),
7+
mainNavigation: () => ({
8+
'data-onboarding-id': 'main-navigation',
9+
className: 'main-navigation',
10+
}),
11+
trySugarButton: () => ({
12+
'data-onboarding-id': 'try-sugar-button',
13+
className: 'try-sugar-button',
14+
}),
15+
activitiesSection: () => ({
16+
'data-onboarding-id': 'activities-section',
17+
className: 'activities-section',
18+
}),
19+
statsSection: () => ({
20+
'data-onboarding-id': 'stats-section',
21+
className: 'stats-section',
22+
}),
23+
donationSection: () => ({
24+
'data-onboarding-id': 'donation-section',
25+
className: 'donation-section',
26+
}),
27+
};

0 commit comments

Comments
 (0)