react-achievements 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +257 -406
- package/dist/index.d.ts +222 -8
- package/dist/index.js +631 -0
- package/dist/index.js.map +1 -0
- package/dist/stories/Button.d.ts +28 -0
- package/dist/stories/Button.stories.d.ts +23 -0
- package/dist/stories/Header.d.ts +13 -0
- package/dist/stories/Header.stories.d.ts +18 -0
- package/dist/stories/Page.d.ts +3 -0
- package/dist/stories/Page.stories.d.ts +12 -0
- package/dist/types/__mocks__/confetti-wrapper.d.ts +5 -0
- package/dist/types/__mocks__/react-confetti.d.ts +3 -0
- package/dist/types/__mocks__/react-toastify.d.ts +13 -0
- package/dist/types/core/components/BadgesButton.d.ts +10 -0
- package/dist/types/core/components/BadgesModal.d.ts +11 -0
- package/dist/types/core/components/ConfettiWrapper.d.ts +6 -0
- package/dist/types/core/context/AchievementContext.d.ts +5 -0
- package/dist/types/core/icons/defaultIcons.d.ts +81 -0
- package/dist/types/core/storage/LocalStorage.d.ts +16 -0
- package/dist/types/core/storage/MemoryStorage.d.ts +11 -0
- package/dist/types/core/styles/defaultStyles.d.ts +2 -0
- package/dist/types/core/types.d.ts +74 -0
- package/dist/types/hooks/useAchievements.d.ts +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/providers/AchievementProvider.d.ts +24 -0
- package/dist/types/setupTests.d.ts +1 -0
- package/dist/types/stories/Button.d.ts +16 -0
- package/dist/types/stories/Button.stories.d.ts +23 -0
- package/dist/types/stories/Header.d.ts +13 -0
- package/dist/types/stories/Header.stories.d.ts +18 -0
- package/dist/types/stories/Page.d.ts +3 -0
- package/dist/types/stories/Page.stories.d.ts +12 -0
- package/package.json +72 -54
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/react-achievements.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/coverage/clover.xml +0 -131
- package/coverage/coverage-final.json +0 -9
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/components/AchievementModal.tsx.html +0 -229
- package/coverage/lcov-report/src/components/BadgesButton.tsx.html +0 -169
- package/coverage/lcov-report/src/components/BadgesModal.tsx.html +0 -253
- package/coverage/lcov-report/src/components/ConfettiWrapper.tsx.html +0 -157
- package/coverage/lcov-report/src/components/index.html +0 -161
- package/coverage/lcov-report/src/context/AchievementContext.tsx.html +0 -505
- package/coverage/lcov-report/src/context/index.html +0 -116
- package/coverage/lcov-report/src/index.html +0 -146
- package/coverage/lcov-report/src/index.ts.html +0 -121
- package/coverage/lcov-report/src/react-confetti.d.ts.html +0 -139
- package/coverage/lcov-report/src/react-use.d.ts.html +0 -94
- package/coverage/lcov.info +0 -240
- package/demo/src/AchievementConfig.ts +0 -0
- package/public/badges/icon1.svg +0 -1
- package/rollup.config.mjs +0 -34
- package/src/assets/defaultIcons.ts +0 -100
- package/src/components/BadgesButton.tsx +0 -49
- package/src/components/BadgesModal.tsx +0 -47
- package/src/components/ConfettiWrapper.tsx +0 -17
- package/src/defaultStyles.ts +0 -86
- package/src/hooks/useAchievement.ts +0 -17
- package/src/index.ts +0 -25
- package/src/providers/AchievementProvider.tsx +0 -202
- package/src/react-confetti.d.ts +0 -19
- package/src/react-use.d.ts +0 -4
- package/src/redux/achievementSlice.ts +0 -116
- package/src/redux/notificationSlice.ts +0 -26
- package/src/redux/store.ts +0 -16
- package/src/types.ts +0 -39
- package/tsconfig.json +0 -113
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './button.css';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Is this the principal call to action on the page?
|
|
6
|
+
*/
|
|
7
|
+
primary?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* What background color to use
|
|
10
|
+
*/
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How large should the button be?
|
|
14
|
+
*/
|
|
15
|
+
size?: 'small' | 'medium' | 'large';
|
|
16
|
+
/**
|
|
17
|
+
* Button contents
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional click handler
|
|
22
|
+
*/
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Primary UI component for user interaction
|
|
27
|
+
*/
|
|
28
|
+
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react").JSX.Element;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {
|
|
10
|
+
backgroundColor: {
|
|
11
|
+
control: "color";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
args: {
|
|
15
|
+
onClick: import("@vitest/spy").Mock<[], void>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
export declare const Primary: Story;
|
|
21
|
+
export declare const Secondary: Story;
|
|
22
|
+
export declare const Large: Story;
|
|
23
|
+
export declare const Small: Story;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './header.css';
|
|
3
|
+
type User = {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export interface HeaderProps {
|
|
7
|
+
user?: User;
|
|
8
|
+
onLogin?: () => void;
|
|
9
|
+
onLogout?: () => void;
|
|
10
|
+
onCreateAccount?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ user, onLogin, onLogout, onCreateAccount }: import("./Header").HeaderProps) => import("react").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
args: {
|
|
10
|
+
onLogin: import("@vitest/spy").Mock<[], void>;
|
|
11
|
+
onLogout: import("@vitest/spy").Mock<[], void>;
|
|
12
|
+
onCreateAccount: import("@vitest/spy").Mock<[], void>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
export declare const LoggedIn: Story;
|
|
18
|
+
export declare const LoggedOut: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").FC<{}>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof meta>;
|
|
11
|
+
export declare const LoggedOut: Story;
|
|
12
|
+
export declare const LoggedIn: Story;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ToastContent, ToastOptions } from 'react-toastify';
|
|
2
|
+
declare const toast: jest.Mock<any, any, any> & {
|
|
3
|
+
success: jest.Mock<string, [content: ToastContent, options?: ToastOptions<{}> | undefined], any>;
|
|
4
|
+
error: jest.Mock<any, any, any>;
|
|
5
|
+
info: jest.Mock<any, any, any>;
|
|
6
|
+
warn: jest.Mock<any, any, any>;
|
|
7
|
+
dark: jest.Mock<any, any, any>;
|
|
8
|
+
dismiss: jest.Mock<any, any, any>;
|
|
9
|
+
__esModule: boolean;
|
|
10
|
+
default: jest.Mock<any, any, any>;
|
|
11
|
+
};
|
|
12
|
+
export { toast };
|
|
13
|
+
export declare const ToastContainer: jest.Mock<null, [], any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AchievementDetails } from '../types';
|
|
3
|
+
interface BadgesButtonProps {
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
6
|
+
styles?: React.CSSProperties;
|
|
7
|
+
unlockedAchievements: AchievementDetails[];
|
|
8
|
+
}
|
|
9
|
+
export declare const BadgesButton: React.FC<BadgesButtonProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AchievementDetails, StylesProps } from '../types';
|
|
3
|
+
interface BadgesModalProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
achievements: AchievementDetails[];
|
|
7
|
+
styles?: StylesProps['badgesModal'];
|
|
8
|
+
icons?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare const BadgesModal: React.FC<BadgesModalProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
3
|
+
import { AchievementContextValue, AchievementProviderProps } from '../types';
|
|
4
|
+
export declare const useAchievementContext: () => AchievementContextValue;
|
|
5
|
+
export declare const AchievementProvider: React.FC<AchievementProviderProps>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare const defaultAchievementIcons: {
|
|
2
|
+
levelUp: string;
|
|
3
|
+
questComplete: string;
|
|
4
|
+
monsterDefeated: string;
|
|
5
|
+
itemCollected: string;
|
|
6
|
+
challengeCompleted: string;
|
|
7
|
+
milestoneReached: string;
|
|
8
|
+
firstStep: string;
|
|
9
|
+
newBeginnings: string;
|
|
10
|
+
breakthrough: string;
|
|
11
|
+
growth: string;
|
|
12
|
+
shared: string;
|
|
13
|
+
liked: string;
|
|
14
|
+
commented: string;
|
|
15
|
+
followed: string;
|
|
16
|
+
invited: string;
|
|
17
|
+
communityMember: string;
|
|
18
|
+
supporter: string;
|
|
19
|
+
connected: string;
|
|
20
|
+
participant: string;
|
|
21
|
+
influencer: string;
|
|
22
|
+
activeDay: string;
|
|
23
|
+
activeWeek: string;
|
|
24
|
+
activeMonth: string;
|
|
25
|
+
earlyBird: string;
|
|
26
|
+
nightOwl: string;
|
|
27
|
+
streak: string;
|
|
28
|
+
dedicated: string;
|
|
29
|
+
punctual: string;
|
|
30
|
+
consistent: string;
|
|
31
|
+
marathon: string;
|
|
32
|
+
artist: string;
|
|
33
|
+
writer: string;
|
|
34
|
+
innovator: string;
|
|
35
|
+
creator: string;
|
|
36
|
+
expert: string;
|
|
37
|
+
master: string;
|
|
38
|
+
pioneer: string;
|
|
39
|
+
performer: string;
|
|
40
|
+
thinker: string;
|
|
41
|
+
explorer: string;
|
|
42
|
+
bronze: string;
|
|
43
|
+
silver: string;
|
|
44
|
+
gold: string;
|
|
45
|
+
diamond: string;
|
|
46
|
+
legendary: string;
|
|
47
|
+
epic: string;
|
|
48
|
+
rare: string;
|
|
49
|
+
common: string;
|
|
50
|
+
special: string;
|
|
51
|
+
hidden: string;
|
|
52
|
+
one: string;
|
|
53
|
+
ten: string;
|
|
54
|
+
hundred: string;
|
|
55
|
+
thousand: string;
|
|
56
|
+
clicked: string;
|
|
57
|
+
used: string;
|
|
58
|
+
found: string;
|
|
59
|
+
built: string;
|
|
60
|
+
solved: string;
|
|
61
|
+
discovered: string;
|
|
62
|
+
unlocked: string;
|
|
63
|
+
upgraded: string;
|
|
64
|
+
repaired: string;
|
|
65
|
+
defended: string;
|
|
66
|
+
default: string;
|
|
67
|
+
loading: string;
|
|
68
|
+
error: string;
|
|
69
|
+
success: string;
|
|
70
|
+
failure: string;
|
|
71
|
+
trophy: string;
|
|
72
|
+
star: string;
|
|
73
|
+
flag: string;
|
|
74
|
+
puzzle: string;
|
|
75
|
+
gem: string;
|
|
76
|
+
crown: string;
|
|
77
|
+
medal: string;
|
|
78
|
+
ribbon: string;
|
|
79
|
+
badge: string;
|
|
80
|
+
shield: string;
|
|
81
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AchievementStorage, AchievementMetrics } from '../types';
|
|
2
|
+
export declare class LocalStorage implements AchievementStorage {
|
|
3
|
+
private storageKey;
|
|
4
|
+
constructor(storageKey: string);
|
|
5
|
+
private serializeValue;
|
|
6
|
+
private deserializeValue;
|
|
7
|
+
private serializeMetrics;
|
|
8
|
+
private deserializeMetrics;
|
|
9
|
+
private getStorageData;
|
|
10
|
+
private setStorageData;
|
|
11
|
+
getMetrics(): AchievementMetrics;
|
|
12
|
+
setMetrics(metrics: AchievementMetrics): void;
|
|
13
|
+
getUnlockedAchievements(): string[];
|
|
14
|
+
setUnlockedAchievements(achievements: string[]): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AchievementStorage, AchievementMetrics } from '../types';
|
|
2
|
+
export declare class MemoryStorage implements AchievementStorage {
|
|
3
|
+
private metrics;
|
|
4
|
+
private unlockedAchievements;
|
|
5
|
+
constructor();
|
|
6
|
+
getMetrics(): AchievementMetrics;
|
|
7
|
+
setMetrics(metrics: AchievementMetrics): void;
|
|
8
|
+
getUnlockedAchievements(): string[];
|
|
9
|
+
setUnlockedAchievements(achievements: string[]): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type AchievementMetricValue = number | string | boolean | Date | null | undefined;
|
|
2
|
+
export type AchievementMetricArrayValue = AchievementMetricValue | AchievementMetricValue[];
|
|
3
|
+
export declare const isDate: (value: any) => value is Date;
|
|
4
|
+
export interface AchievementMetrics {
|
|
5
|
+
[key: string]: AchievementMetricValue[];
|
|
6
|
+
}
|
|
7
|
+
export interface AchievementDetails {
|
|
8
|
+
achievementId: string;
|
|
9
|
+
achievementTitle: string;
|
|
10
|
+
achievementDescription: string;
|
|
11
|
+
achievementIconKey?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AchievementCondition {
|
|
14
|
+
isConditionMet: (value: AchievementMetricArrayValue, state: AchievementState) => boolean;
|
|
15
|
+
achievementDetails: {
|
|
16
|
+
achievementId: string;
|
|
17
|
+
achievementTitle: string;
|
|
18
|
+
achievementDescription: string;
|
|
19
|
+
achievementIconKey: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface AchievementConfiguration {
|
|
23
|
+
[key: string]: AchievementCondition[];
|
|
24
|
+
}
|
|
25
|
+
export interface InitialAchievementMetrics {
|
|
26
|
+
[key: string]: AchievementMetricValue;
|
|
27
|
+
}
|
|
28
|
+
export interface AchievementState {
|
|
29
|
+
metrics: AchievementMetrics;
|
|
30
|
+
unlockedAchievements: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface AchievementStorage {
|
|
33
|
+
getMetrics(): AchievementMetrics;
|
|
34
|
+
setMetrics(metrics: AchievementMetrics): void;
|
|
35
|
+
getUnlockedAchievements(): string[];
|
|
36
|
+
setUnlockedAchievements(achievements: string[]): void;
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
39
|
+
export interface AchievementContextValue {
|
|
40
|
+
updateMetrics: (metrics: AchievementMetrics | ((prev: AchievementMetrics) => AchievementMetrics)) => void;
|
|
41
|
+
unlockedAchievements: string[];
|
|
42
|
+
resetStorage: () => void;
|
|
43
|
+
}
|
|
44
|
+
export interface StylesProps {
|
|
45
|
+
badgesButton?: React.CSSProperties;
|
|
46
|
+
badgesModal?: {
|
|
47
|
+
overlay?: React.CSSProperties;
|
|
48
|
+
content?: React.CSSProperties;
|
|
49
|
+
header?: React.CSSProperties;
|
|
50
|
+
closeButton?: React.CSSProperties;
|
|
51
|
+
achievementList?: React.CSSProperties;
|
|
52
|
+
achievementItem?: React.CSSProperties;
|
|
53
|
+
achievementTitle?: React.CSSProperties;
|
|
54
|
+
achievementDescription?: React.CSSProperties;
|
|
55
|
+
achievementIcon?: React.CSSProperties;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface AchievementProviderProps {
|
|
59
|
+
children: React.ReactNode;
|
|
60
|
+
config: AchievementConfiguration;
|
|
61
|
+
initialState?: InitialAchievementMetrics & {
|
|
62
|
+
previouslyAwardedAchievements?: string[];
|
|
63
|
+
};
|
|
64
|
+
storageKey?: string;
|
|
65
|
+
badgesButtonPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
66
|
+
styles?: Partial<StylesProps>;
|
|
67
|
+
icons?: Record<string, string>;
|
|
68
|
+
storage?: AchievementStorage;
|
|
69
|
+
onAchievementUnlocked?: (achievement: AchievementDetails) => void;
|
|
70
|
+
}
|
|
71
|
+
export declare enum StorageType {
|
|
72
|
+
Local = "local",
|
|
73
|
+
Memory = "memory"
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAchievements: () => import("../providers/AchievementProvider").AchievementContextType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { AchievementMetrics, AchievementConfiguration, AchievementDetails, AchievementCondition, AchievementMetricValue, AchievementMetricArrayValue, InitialAchievementMetrics, AchievementState, AchievementStorage, AchievementContextValue, StylesProps, AchievementProviderProps, } from './core/types';
|
|
2
|
+
export { LocalStorage } from './core/storage/LocalStorage';
|
|
3
|
+
export { StorageType } from './core/types';
|
|
4
|
+
export { BadgesButton } from './core/components/BadgesButton';
|
|
5
|
+
export { BadgesModal } from './core/components/BadgesModal';
|
|
6
|
+
export { ConfettiWrapper } from './core/components/ConfettiWrapper';
|
|
7
|
+
export { AchievementProvider, AchievementContext } from './providers/AchievementProvider';
|
|
8
|
+
export { useAchievements } from './hooks/useAchievements';
|
|
9
|
+
export { defaultStyles } from './core/styles/defaultStyles';
|
|
10
|
+
export { defaultAchievementIcons } from './core/icons/defaultIcons';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AchievementConfiguration, AchievementStorage, AchievementMetrics, StorageType } from '../core/types';
|
|
3
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
4
|
+
export interface AchievementContextType {
|
|
5
|
+
update: (metrics: Record<string, any>) => void;
|
|
6
|
+
achievements: {
|
|
7
|
+
unlocked: string[];
|
|
8
|
+
all: Record<string, any>;
|
|
9
|
+
};
|
|
10
|
+
reset: () => void;
|
|
11
|
+
getState: () => {
|
|
12
|
+
metrics: AchievementMetrics;
|
|
13
|
+
unlocked: string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare const AchievementContext: React.Context<AchievementContextType | undefined>;
|
|
17
|
+
interface AchievementProviderProps {
|
|
18
|
+
achievements: AchievementConfiguration;
|
|
19
|
+
storage?: AchievementStorage | StorageType;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
icons?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export declare const AchievementProvider: React.FC<AchievementProviderProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './button.css';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
/** Is this the principal call to action on the page? */
|
|
5
|
+
primary?: boolean;
|
|
6
|
+
/** What background color to use */
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
/** How large should the button be? */
|
|
9
|
+
size?: 'small' | 'medium' | 'large';
|
|
10
|
+
/** Button contents */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Optional click handler */
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** Primary UI component for user interaction */
|
|
16
|
+
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react").JSX.Element;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {
|
|
10
|
+
backgroundColor: {
|
|
11
|
+
control: "color";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
args: {
|
|
15
|
+
onClick: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
export declare const Primary: Story;
|
|
21
|
+
export declare const Secondary: Story;
|
|
22
|
+
export declare const Large: Story;
|
|
23
|
+
export declare const Small: Story;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './header.css';
|
|
3
|
+
type User = {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export interface HeaderProps {
|
|
7
|
+
user?: User;
|
|
8
|
+
onLogin?: () => void;
|
|
9
|
+
onLogout?: () => void;
|
|
10
|
+
onCreateAccount?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ user, onLogin, onLogout, onCreateAccount }: import("./Header").HeaderProps) => import("react").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
args: {
|
|
10
|
+
onLogin: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
11
|
+
onLogout: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
12
|
+
onCreateAccount: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
export declare const LoggedIn: Story;
|
|
18
|
+
export declare const LoggedOut: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").FC<{}>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof meta>;
|
|
11
|
+
export declare const LoggedOut: Story;
|
|
12
|
+
export declare const LoggedIn: Story;
|
package/package.json
CHANGED
|
@@ -1,66 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-achievements",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"react",
|
|
7
|
-
"badge",
|
|
8
|
-
"achievement"
|
|
9
|
-
],
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/dave-b-b/react-achievements.git"
|
|
13
|
-
},
|
|
14
|
-
"main": "dist/cjs.js",
|
|
15
|
-
"module": "dist/index.esm.js",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Core achievement system for React applications",
|
|
5
|
+
"main": "dist/index.js",
|
|
16
6
|
"types": "dist/index.d.ts",
|
|
17
7
|
"scripts": {
|
|
18
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
8
|
"build": "rollup -c",
|
|
20
|
-
"
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"prepare": "npm run build",
|
|
21
11
|
"storybook": "storybook dev -p 6006",
|
|
22
12
|
"build-storybook": "storybook build"
|
|
23
13
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"react": ">=16.8.0",
|
|
16
|
+
"react-confetti": "^6.1.0",
|
|
17
|
+
"react-dom": ">=16.8.0",
|
|
18
|
+
"react-modal": "^3.16.1",
|
|
19
|
+
"react-toastify": "^9.1.3",
|
|
20
|
+
"react-use": "^17.4.0"
|
|
21
|
+
},
|
|
26
22
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@rollup/plugin-
|
|
33
|
-
"@rollup/plugin-
|
|
34
|
-
"@
|
|
35
|
-
"@storybook/addon-
|
|
36
|
-
"@storybook/addon-
|
|
37
|
-
"@storybook/addon-onboarding": "^8.6.
|
|
38
|
-
"@storybook/addon-webpack5-compiler-swc": "^
|
|
39
|
-
"@storybook/blocks": "^8.6.
|
|
40
|
-
"@storybook/react": "^8.6.
|
|
41
|
-
"@storybook/react-webpack5": "^8.6.
|
|
42
|
-
"@storybook/test": "^8.6.
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@types/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
23
|
+
"@babel/core": "^7.22.5",
|
|
24
|
+
"@babel/preset-env": "^7.22.5",
|
|
25
|
+
"@babel/preset-react": "^7.22.5",
|
|
26
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
27
|
+
"@reduxjs/toolkit": "^2.7.0",
|
|
28
|
+
"@rollup/plugin-commonjs": "^25.0.2",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
30
|
+
"@rollup/plugin-typescript": "^11.1.1",
|
|
31
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
32
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
33
|
+
"@storybook/addon-onboarding": "^8.6.12",
|
|
34
|
+
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
|
|
35
|
+
"@storybook/blocks": "^8.6.12",
|
|
36
|
+
"@storybook/react": "^8.6.12",
|
|
37
|
+
"@storybook/react-webpack5": "^8.6.12",
|
|
38
|
+
"@storybook/test": "^8.6.12",
|
|
39
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
40
|
+
"@testing-library/react": "^14.0.0",
|
|
41
|
+
"@testing-library/user-event": "^14.4.3",
|
|
42
|
+
"@types/jest": "^29.5.2",
|
|
43
|
+
"@types/react": "^18.2.12",
|
|
44
|
+
"@types/react-dom": "^18.2.5",
|
|
45
|
+
"@types/react-modal": "^3.16.0",
|
|
46
|
+
"identity-obj-proxy": "^3.0.0",
|
|
47
|
+
"jest": "^29.5.0",
|
|
48
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
49
|
+
"prop-types": "^15.8.1",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-confetti": "^6.1.0",
|
|
52
|
+
"react-dom": "^18.2.0",
|
|
53
|
+
"react-modal": "^3.16.1",
|
|
54
|
+
"react-redux": "^9.2.0",
|
|
55
|
+
"react-toastify": "^9.1.3",
|
|
56
|
+
"react-use": "^17.4.0",
|
|
57
|
+
"rollup": "^3.25.1",
|
|
58
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
59
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
60
|
+
"storybook": "^8.6.12",
|
|
61
|
+
"ts-jest": "^29.3.2",
|
|
62
|
+
"typescript": "^5.1.3",
|
|
63
|
+
"zustand": "^5.0.4"
|
|
53
64
|
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
"files": [
|
|
66
|
+
"dist"
|
|
67
|
+
],
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/dave-b-b/react-achievements.git"
|
|
71
|
+
},
|
|
72
|
+
"keywords": [
|
|
73
|
+
"react",
|
|
74
|
+
"achievements",
|
|
75
|
+
"gamification",
|
|
76
|
+
"core"
|
|
77
|
+
],
|
|
78
|
+
"author": "Dave B",
|
|
79
|
+
"license": "MIT",
|
|
80
|
+
"bugs": {
|
|
81
|
+
"url": "https://github.com/dave-b-b/react-achievements/issues"
|
|
62
82
|
},
|
|
63
|
-
"
|
|
64
|
-
"react-toastify": "^10.0.0"
|
|
65
|
-
}
|
|
83
|
+
"homepage": "https://github.com/dave-b-b/react-achievements#readme"
|
|
66
84
|
}
|