magic-pill 7.1.2 → 8.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/CHANGELOG.md +45 -0
- package/README.md +132 -68
- package/dist/MagicPill.d.ts +8 -0
- package/dist/Navbar/Navbar.d.ts +9 -0
- package/dist/Navbar/NavbarConfig.d.ts +8 -0
- package/dist/Notification/Notification.d.ts +9 -0
- package/dist/Notification/NotificationConfigBottom.d.ts +9 -0
- package/dist/Notification/NotificationConfigTop.d.ts +9 -0
- package/dist/defaultPillData.d.ts +2 -0
- package/dist/icons/arrow_label.d.ts +3 -0
- package/dist/icons/box_label.d.ts +3 -0
- package/dist/icons/checkmark.d.ts +3 -0
- package/dist/icons/checkmark_label.d.ts +3 -0
- package/dist/icons/coupon.d.ts +3 -0
- package/dist/icons/cross_label.d.ts +3 -0
- package/dist/icons/info.d.ts +3 -0
- package/dist/icons/mail_label.d.ts +3 -0
- package/dist/icons/plus_label.d.ts +3 -0
- package/dist/icons/questionmark.d.ts +3 -0
- package/dist/icons/quotation_label.d.ts +3 -0
- package/dist/icons/tel_label.d.ts +3 -0
- package/dist/icons/undo_label.d.ts +3 -0
- package/dist/index.d.ts +4 -42
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/magicpill.css +58 -4
- package/dist/types/index.d.ts +6 -0
- package/dist/types/magicPill.d.ts +47 -0
- package/dist/types/navbar.d.ts +26 -0
- package/dist/types/notification.d.ts +139 -0
- package/dist/utils/handlers.d.ts +21 -0
- package/dist/utils/icons.d.ts +18 -0
- package/package.json +32 -8
- package/dist/index.css +0 -1
- package/dist/index.esm.css +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the structure of a navigation item in the Magic Pill navbar.
|
|
3
|
+
* Each item has an icon, an optional label, and a link.
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* {
|
|
7
|
+
* icon: "home",
|
|
8
|
+
* label: "Home",
|
|
9
|
+
* link: "/home"
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
* @see {@link MagicPillNavbar} for the structure of the navbar that contains these items.
|
|
13
|
+
*/
|
|
14
|
+
export interface MagicPillNavbarItem {
|
|
15
|
+
icon: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
link: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines the structure of the navbar in the Magic Pill component.
|
|
21
|
+
* It contains an array of navigation items.
|
|
22
|
+
* @see {@link MagicPillNavbarItem} for the structure of each item in the navbar.
|
|
23
|
+
*/
|
|
24
|
+
export interface MagicPillNavbar {
|
|
25
|
+
navItems: MagicPillNavbarItem[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the structure of a call to action (CTA) in the Magic Pill notification.
|
|
3
|
+
* Each CTA has an icon, an optional label, and an optional link.
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* {
|
|
7
|
+
* icon: "action",
|
|
8
|
+
* label: "Take Action",
|
|
9
|
+
* link: "/action"
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
* @see {@link MagicPillNotification} for the structure of the notification that contains this CTA.
|
|
13
|
+
*/
|
|
14
|
+
export interface MagicPillNotificationCTA {
|
|
15
|
+
icon: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
link?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines the structure of additional information in the Magic Pill notification.
|
|
21
|
+
* This can include a title, content (which can contain HTML), and a close label.
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* {
|
|
25
|
+
* title: "Notification Title",
|
|
26
|
+
* content: "This is the content of the notification.",
|
|
27
|
+
* closeLabel: "Close"
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
* @see {@link MagicPillNotification} for the structure of the notification that contains this information.
|
|
31
|
+
* @see {@link MagicPillNotificationCTA} for the structure of the call to action in the notification.
|
|
32
|
+
*/
|
|
33
|
+
export interface MagicPillNotificationInfo {
|
|
34
|
+
title?: string;
|
|
35
|
+
content: string;
|
|
36
|
+
closeLabel: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Defines the structure of a Magic Pill notification CTA with a link.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* {
|
|
43
|
+
* icon: "info",
|
|
44
|
+
* label: "Learn More",
|
|
45
|
+
* link: "/learn-more"
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
* @see {@link MagicPillNotificationWithLink} for the whole notification structure that incorporates this very type..
|
|
49
|
+
*/
|
|
50
|
+
interface MagicPillNotificationCTAWithLink {
|
|
51
|
+
icon: string;
|
|
52
|
+
label?: string;
|
|
53
|
+
link: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Defines the structure of a Magic Pill notification CTA without a link.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* {
|
|
60
|
+
* icon: "info",
|
|
61
|
+
* label: "No Link Available"
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
* @see {@link MagicPillNotificationWithoutLink} for the whole notification structure that incorporates this very type.
|
|
65
|
+
*/
|
|
66
|
+
interface MagicPillNotificationCTAWithoutLink {
|
|
67
|
+
icon: string;
|
|
68
|
+
label?: string;
|
|
69
|
+
link?: undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Defines the base structure of a Magic Pill notification.
|
|
73
|
+
* It includes an optional icon and a mandatory message.
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* {
|
|
77
|
+
* icon: "info",
|
|
78
|
+
* message: "This is a notification message."
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
* @see {@link MagicPillNotificationWithLink} for notifications that include a CTA with a link.
|
|
82
|
+
* @see {@link MagicPillNotificationWithoutLink} for notifications that include a CTA without a link.
|
|
83
|
+
* @see {@link MagicPillNotificationWithoutCTA} for notifications that do not include a CTA.
|
|
84
|
+
*/
|
|
85
|
+
interface MagicPillNotificationBase {
|
|
86
|
+
icon?: string;
|
|
87
|
+
message: string;
|
|
88
|
+
cta?: MagicPillNotificationCTA;
|
|
89
|
+
info?: MagicPillNotificationInfo;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Defines the structure of a Magic Pill notification with a CTA that includes a link.
|
|
93
|
+
* This type extends the base notification structure and includes a CTA with a mandatory link.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* {
|
|
97
|
+
* icon: "info",
|
|
98
|
+
* message: "This is a notification with a link.",
|
|
99
|
+
* cta: {
|
|
100
|
+
* icon: "action",
|
|
101
|
+
* label: "Take Action",
|
|
102
|
+
* link: "/action"
|
|
103
|
+
* }
|
|
104
|
+
* }
|
|
105
|
+
* ````
|
|
106
|
+
* @see {@link MagicPillNotificationBase} for the base structure of the notification.
|
|
107
|
+
* @see {@link MagicPillNotificationCTAWithLink} for the structure of the CTA with a link.
|
|
108
|
+
*/
|
|
109
|
+
type MagicPillNotificationWithLink = MagicPillNotificationBase & {
|
|
110
|
+
cta: MagicPillNotificationCTAWithLink;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Defines the structure of a Magic Pill notification without a link in the CTA.
|
|
114
|
+
* This type extends the base notification structure and includes a CTA without a mandatory link.
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* {
|
|
118
|
+
* icon: "info",
|
|
119
|
+
* message: "This is a notification without a link.",
|
|
120
|
+
* cta: {
|
|
121
|
+
* icon: "action",
|
|
122
|
+
* label: "No Link Available"
|
|
123
|
+
* },
|
|
124
|
+
* info: {
|
|
125
|
+
* title: "Notification Title",
|
|
126
|
+
* content: "This is the content of the notification.",
|
|
127
|
+
* closeLabel: "Close"
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
* @see {@link MagicPillNotificationBase} for the base structure of the notification.
|
|
132
|
+
* @see {@link MagicPillNotificationCTAWithoutLink} for the structure of the CTA without a link.
|
|
133
|
+
*/
|
|
134
|
+
type MagicPillNotificationWithoutLink = MagicPillNotificationBase & {
|
|
135
|
+
cta: MagicPillNotificationCTAWithoutLink;
|
|
136
|
+
info: MagicPillNotificationInfo;
|
|
137
|
+
};
|
|
138
|
+
export type MagicPillNotification = MagicPillNotificationWithLink | MagicPillNotificationWithoutLink | MagicPillNotificationBase;
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MagicPillType } from '../types/index';
|
|
2
|
+
import { SetStateAction, Dispatch } from 'react';
|
|
3
|
+
type SetPillData = Dispatch<SetStateAction<MagicPillType>>;
|
|
4
|
+
export declare const handleModeChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
5
|
+
export declare const handleIconChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
6
|
+
export declare const handleMessageChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
7
|
+
export declare const handleTextChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
8
|
+
export declare const handleCTAIconChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
9
|
+
export declare const handleCTAMessageChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
10
|
+
export declare const handleCTATextChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
11
|
+
export declare const handleCTALinkChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
12
|
+
export declare const handleCTACustomLinkChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
13
|
+
export declare const handleInfoTitleChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
14
|
+
export declare const handleInfoCustomTitleChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
15
|
+
export declare const handleInfoCustomContentChange: (event: React.ChangeEvent<HTMLInputElement>, setPillData: SetPillData) => void;
|
|
16
|
+
export declare const handleNavItemLabelChange: (event: React.ChangeEvent<HTMLInputElement>, index: number, setPillData: SetPillData) => void;
|
|
17
|
+
export declare const handleNavItemLinkChange: (event: React.ChangeEvent<HTMLInputElement>, index: number, setPillData: SetPillData) => void;
|
|
18
|
+
export declare const handleNavItemIconChange: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>, index: number, setPillData: SetPillData) => void;
|
|
19
|
+
export declare const handleAddNavItem: (setPillData: SetPillData) => void;
|
|
20
|
+
export declare const handleDeleteNavItem: (index: number, setPillData: SetPillData) => void;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const Icons: {
|
|
2
|
+
checkmark: () => import("react").JSX.Element;
|
|
3
|
+
coupon: () => import("react").JSX.Element;
|
|
4
|
+
info: () => import("react").JSX.Element;
|
|
5
|
+
questionmark: () => import("react").JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export declare const CTAIcons: {
|
|
8
|
+
arrow: () => import("react").JSX.Element;
|
|
9
|
+
box: () => import("react").JSX.Element;
|
|
10
|
+
checkmark: () => import("react").JSX.Element;
|
|
11
|
+
cross: () => import("react").JSX.Element;
|
|
12
|
+
mail: () => import("react").JSX.Element;
|
|
13
|
+
plus: () => import("react").JSX.Element;
|
|
14
|
+
quotation: () => import("react").JSX.Element;
|
|
15
|
+
tel: () => import("react").JSX.Element;
|
|
16
|
+
undo: () => import("react").JSX.Element;
|
|
17
|
+
};
|
|
18
|
+
export declare function getIconComponent(iconName: string, iconsMap: Record<string, React.ComponentType<React.SVGProps<SVGSVGElement>>>): import("react").ComponentType<import("react").SVGProps<SVGSVGElement>> | null;
|
package/package.json
CHANGED
|
@@ -1,42 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magic-pill",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"description": "A new way to guide your audience and bring them contextual information through your app",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/CedricTheveneau/Magic-Pill"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "rollup -c && cp src/
|
|
14
|
-
"prepare": "npm run build"
|
|
13
|
+
"build": "rollup -c && cp src/magicpill.css dist/magicpill.css",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
17
18
|
"next": ">=14.0.0",
|
|
18
19
|
"react": ">=18.0.0",
|
|
19
|
-
"react-dom": ">=18.0.0"
|
|
20
|
+
"react-dom": ">=18.0.0",
|
|
21
|
+
"typescript": ">=5.0.0"
|
|
20
22
|
},
|
|
21
23
|
"keywords": [
|
|
22
24
|
"notifications",
|
|
23
25
|
"magicpill",
|
|
24
|
-
"magic pill"
|
|
26
|
+
"magic pill",
|
|
27
|
+
"navbar",
|
|
28
|
+
"dynamic island",
|
|
29
|
+
"typescript",
|
|
30
|
+
"react",
|
|
31
|
+
"nextjs",
|
|
32
|
+
"ui",
|
|
33
|
+
"component",
|
|
34
|
+
"toast",
|
|
35
|
+
"navigation"
|
|
25
36
|
],
|
|
26
37
|
"author": "Cédric THEVENEAU",
|
|
27
38
|
"license": "MIT",
|
|
39
|
+
"homepage": "https://github.com/CedricTheveneau/Magic-Pill#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/CedricTheveneau/Magic-Pill/issues"
|
|
42
|
+
},
|
|
43
|
+
"cdn": {
|
|
44
|
+
"url": "https://cdn.jsdelivr.net/npm/magic-pill@latest/dist/index.js",
|
|
45
|
+
"style": "https://cdn.jsdelivr.net/npm/magic-pill@latest/dist/magicpill.css"
|
|
46
|
+
},
|
|
28
47
|
"devDependencies": {
|
|
29
48
|
"@babel/core": "^7.26.0",
|
|
30
49
|
"@babel/preset-env": "^7.26.0",
|
|
31
50
|
"@babel/preset-react": "^7.25.9",
|
|
51
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
32
52
|
"@rollup/plugin-babel": "^6.0.4",
|
|
53
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
54
|
+
"@types/react": "^18.2.64",
|
|
55
|
+
"@types/react-dom": "^18.2.21",
|
|
33
56
|
"rollup": "^2.79.2",
|
|
34
57
|
"rollup-plugin-postcss": "^4.0.2",
|
|
35
|
-
"rollup-plugin-terser": "^7.0.2"
|
|
58
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
59
|
+
"tslib": "^2.6.2",
|
|
60
|
+
"typescript": "^5.4.2"
|
|
36
61
|
},
|
|
37
62
|
"files": [
|
|
38
63
|
"dist",
|
|
39
|
-
"index.d.ts",
|
|
40
64
|
"CHANGELOG.md",
|
|
41
65
|
"LICENSE.md",
|
|
42
66
|
"NOTICE.md"
|
package/dist/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap");:root{--themeDark:#141414;--themeLight:#f9f9f9;--font-family:"Overlock",sans-serif;--normal:normal;--italic:italic;--medium:400;--bold:700;--black:900}*,:after,:before{box-sizing:border-box;font-family:var(--font-family);margin:0;padding:0}.magicpill{background-color:var(--themeDark);border-radius:100px;color:var(--themeLight);display:flex;gap:25px;padding:25px}
|
package/dist/index.esm.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css2?family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap");:root{--themeDark:#141414;--themeLight:#f9f9f9;--font-family:"Overlock",sans-serif;--normal:normal;--italic:italic;--medium:400;--bold:700;--black:900}*,:after,:before{box-sizing:border-box;font-family:var(--font-family);margin:0;padding:0}.magicpill{background-color:var(--themeDark);border-radius:100px;color:var(--themeLight);display:flex;gap:25px;padding:25px}
|