magic-pill 7.1.3 → 8.0.1
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 +48 -0
- package/README.md +286 -71
- package/dist/MagicPill.d.ts +8 -0
- package/dist/Navbar/Navbar.d.ts +9 -0
- package/dist/Notification/Notification.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 +61 -4
- package/dist/types/index.d.ts +3 -0
- package/dist/types/magicPill.d.ts +50 -0
- package/dist/types/navbar.d.ts +27 -0
- package/dist/types/notification.d.ts +140 -0
- package/dist/utils/handlers.d.ts +19 -0
- package/dist/utils/icons.d.ts +18 -0
- package/package.json +33 -9
- package/dist/index.css +0 -1
- package/dist/index.esm.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [8.0.1] - 2024-03-21
|
|
4
|
+
### Added
|
|
5
|
+
- Added `*.tsbuildinfo` to `.gitignore`
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Minor improvements to typing with better TypeScript interfaces
|
|
9
|
+
- Reduced package size by removing unnecessary files and reworking all the handlers
|
|
10
|
+
- Updated the "How to use" section of the `README.md` file to better reflect real usage of the package with Context API and added comprehensive documentation for icons and handlers
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fixed the behavior of the entry and exit animations of Magic Pill
|
|
14
|
+
- Improved navbar mode's semantic HTML structure for better accessibility
|
|
15
|
+
- Enhanced navbar's active state behavior and link transitions
|
|
16
|
+
|
|
17
|
+
## [8.0.0] - 2025-06-24
|
|
18
|
+
### Added
|
|
19
|
+
- Complete TypeScript rewrite with comprehensive type definitions
|
|
20
|
+
- New Navbar mode for Magic Pill with full TypeScript support
|
|
21
|
+
- Improved component architecture with separate Notification and Navbar components
|
|
22
|
+
- Enhanced type safety with discriminated unions for different modes
|
|
23
|
+
- New strongly-typed icon system
|
|
24
|
+
- Added TypeScript build configuration with proper source maps
|
|
25
|
+
- Added proper TypeScript development tools and dependencies
|
|
26
|
+
- Added comprehensive JSDoc comments for better IDE support
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- Migrated entire codebase to TypeScript
|
|
30
|
+
- Updated build system to handle TypeScript files
|
|
31
|
+
- Improved code organization with feature-based directory structure
|
|
32
|
+
- Enhanced type definitions for better developer experience
|
|
33
|
+
- Updated documentation to reflect TypeScript support
|
|
34
|
+
- Improved error messages with type-aware validation
|
|
35
|
+
- Refactored component props for better type inference
|
|
36
|
+
- Updated all examples in documentation to use TypeScript
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
- Improved type safety across the entire codebase
|
|
40
|
+
- Better handling of optional properties with proper TypeScript nullability
|
|
41
|
+
- More consistent prop types and interfaces
|
|
42
|
+
- Fixed potential type-related runtime errors
|
|
43
|
+
- Improved type checking for icon variants
|
|
44
|
+
|
|
45
|
+
### Breaking Changes
|
|
46
|
+
- Removed deprecated JavaScript files
|
|
47
|
+
- Updated minimum TypeScript version requirement to 5.0
|
|
48
|
+
- Changed some prop types to be more strict
|
|
49
|
+
- Removed support for untyped icon strings
|
|
50
|
+
|
|
3
51
|
## [7.1.3]
|
|
4
52
|
### Updated
|
|
5
53
|
- Updated the "Disclaimer" and "What's next ?" sections of the README file
|
package/README.md
CHANGED
|
@@ -1,121 +1,336 @@
|
|
|
1
|
-
|
|
2
1
|
# Magic Pill
|
|
3
2
|
Let it empower you.
|
|
3
|
+
|
|
4
4
|
## Disclaimer
|
|
5
5
|
Even though Magic Pill is already available to everyone, please keep in mind that its development is not over yet.
|
|
6
|
-
You can technically use it but
|
|
6
|
+
You can technically use it but the documentation is still being improved.
|
|
7
7
|
I'll update this section once a real usable version is released.
|
|
8
|
+
|
|
8
9
|
#### Thank you !!
|
|
9
10
|
Thank you for your patience and to all people who already have shown interest in Magic Pill, it's my very first npm package and I couldn't ask for a better reception of my package after only a few days after its initial release.
|
|
11
|
+
|
|
10
12
|
## Badges
|
|
11
13
|

|
|
12
14
|

|
|
13
15
|
[](https://deepscan.io/dashboard#view=project&tid=23515&pid=28307&bid=911491)
|
|
14
16
|
[](https://snyk.io/test/github/CedricTheveneau/Magic-Pill)
|
|
17
|
+
[](https://packagephobia.com/result?p=magic-pill@latest)
|
|
18
|
+
[<svg width=20 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 96"><path d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"></path></svg>](https://github.com/CedricTheveneau/Magic-Pill)
|
|
19
|
+
[<svg width=20 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 7.334v8h6.666v1.332H12v-1.332h12v-8zm6.666 6.664H5.334v-4H3.999v4H1.335V8.667h5.331zm4 0v1.336H8.001V8.667h5.334v5.332zm12.001 0h-1.33v-4h-1.336v4h-1.335v-4h-1.33v4h-2.671V8.667h8.002z"></path><path d="M10.665 10H12v2.667h-1.335z"></path></svg>](https://www.npmjs.com/package/magic-pill)
|
|
20
|
+
|
|
15
21
|
## Introduction
|
|
16
|
-
Magic Pill is a
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- [X] Highly customizable React component with
|
|
22
|
-
- [X] Fully customized styling based on CSS variables for easy
|
|
23
|
-
- [X] Built with NextJS in mind
|
|
24
|
-
- [X] No external library dependency (
|
|
22
|
+
Magic Pill is a powerful React component that lets you show contextual information to your users in multiple ways. It can function as a notification system mimicking Apple's Dynamic Island, or as a dynamic navbar for seamless navigation. Built with TypeScript for enhanced type safety and developer experience.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
- [X] Multiple modes: Notification system and Dynamic Navbar
|
|
26
|
+
- [X] Written in TypeScript with comprehensive type definitions
|
|
27
|
+
- [X] Highly customizable React component with strongly typed props
|
|
28
|
+
- [X] Fully customized styling based on CSS variables for easy theme adaptation
|
|
29
|
+
- [X] Built with NextJS in mind, also works with vanilla React
|
|
30
|
+
- [X] No external library dependency (apart from bundling)
|
|
25
31
|
- [X] Lightweight and efficient
|
|
32
|
+
- [X] Full TypeScript support with proper type checking
|
|
33
|
+
|
|
26
34
|
## Installation
|
|
27
|
-
|
|
35
|
+
### CDN
|
|
36
|
+
Want to quickly give it a try? Add Magic Pill to any React/NextJS project within 10 seconds with our CDN links!
|
|
37
|
+
#### jsDelivr
|
|
38
|
+
```html
|
|
39
|
+
<script src="https://cdn.jsdelivr.net/npm/magic-pill/dist/index.js"></script>
|
|
40
|
+
<link href="https://cdn.jsdelivr.net/npm/magic-pill@latest/dist/magicpill.css" rel="stylesheet" />
|
|
41
|
+
```
|
|
42
|
+
#### unpkg
|
|
43
|
+
```html
|
|
44
|
+
<script src="https://unpkg.com/magic-pill@latest/dist/index.js"></script>
|
|
45
|
+
<link href="https://unpkg.com/magic-pill@latest/dist/magicpill.css" rel="stylesheet" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### npm
|
|
49
|
+
Magic Pill is available on npm, simply use the following command and you're ready to go!
|
|
28
50
|
```bash
|
|
29
51
|
npm install magic-pill
|
|
30
52
|
```
|
|
31
|
-
|
|
53
|
+
|
|
54
|
+
## How to use it?
|
|
32
55
|
### Import styles
|
|
33
|
-
For it to work properly, you need to import styles in your app (we recommend importing it into your app.
|
|
34
|
-
```
|
|
35
|
-
// Import
|
|
36
|
-
import
|
|
56
|
+
For it to work properly, you need to import styles in your app (we recommend importing it into your app.tsx file).
|
|
57
|
+
```typescript
|
|
58
|
+
// Import in your Next.js or React project
|
|
59
|
+
import "magic-pill/dist/magicpill.css";
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Usage with React/Next.js
|
|
63
|
+
Magic Pill is designed to be used with a Context to manage its state globally. Here's how to set it up:
|
|
64
|
+
|
|
65
|
+
1. First, create a context for Magic Pill (e.g., in `app/contexts/magicPill.tsx`):
|
|
66
|
+
```typescript
|
|
67
|
+
"use client"
|
|
68
|
+
import React, { createContext, useContext, useState } from "react";
|
|
69
|
+
import { MagicPillType, Mode, NotificationIcon, CTAIcon, MagicPillNavbarItem } from "magic-pill";
|
|
70
|
+
import { updateMode, updateNotificationIcon, updateNotificationMessage, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoTitle, updateInfoContent, updateInfoCloseLabel, updateNavItemLabel, updateNavItemLink, updateNavItemIcon, addNavItem, deleteNavItem } from "magic-pill";
|
|
71
|
+
|
|
72
|
+
const defaultPillData: MagicPillType = {
|
|
73
|
+
mode: "navbar",
|
|
74
|
+
navbar: {
|
|
75
|
+
navItems: [
|
|
76
|
+
{
|
|
77
|
+
icon: "arrow",
|
|
78
|
+
label: "mp-test",
|
|
79
|
+
link: "/mp-test"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
icon: "cross",
|
|
83
|
+
label: "demo",
|
|
84
|
+
link: "/demo"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
interface MagicPillContextType {
|
|
91
|
+
pillData: MagicPillType;
|
|
92
|
+
setPillData: (data: MagicPillType) => void;
|
|
93
|
+
// Direct data manipulation methods
|
|
94
|
+
updateMode: (mode: Mode) => void;
|
|
95
|
+
updateNotificationIcon: (icon: NotificationIcon) => void;
|
|
96
|
+
updateNotificationMessage: (message: string) => void;
|
|
97
|
+
updateCTAIcon: (icon: CTAIcon) => void;
|
|
98
|
+
updateCTALabel: (label: string) => void;
|
|
99
|
+
updateCTALink: (link: string) => void;
|
|
100
|
+
updateInfoTitle: (title: string) => void;
|
|
101
|
+
updateInfoContent: (content: string) => void;
|
|
102
|
+
updateInfoCloseLabel: (closeLabel: string) => void;
|
|
103
|
+
updateNavItemLabel: (label: string, index: number) => void;
|
|
104
|
+
updateNavItemLink: (link: string, index: number) => void;
|
|
105
|
+
updateNavItemIcon: (icon: CTAIcon, index: number) => void;
|
|
106
|
+
addNavItem: (navItem: MagicPillNavbarItem) => void;
|
|
107
|
+
deleteNavItem: (index: number) => void;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const MagicPillContext = createContext<MagicPillContextType>({
|
|
111
|
+
pillData: null,
|
|
112
|
+
setPillData: () => {},
|
|
113
|
+
updateMode: () => {},
|
|
114
|
+
updateNotificationIcon: () => {},
|
|
115
|
+
updateNotificationMessage: () => {},
|
|
116
|
+
updateCTAIcon: () => {},
|
|
117
|
+
updateCTALabel: () => {},
|
|
118
|
+
updateCTALink: () => {},
|
|
119
|
+
updateInfoTitle: () => {},
|
|
120
|
+
updateInfoContent: () => {},
|
|
121
|
+
updateInfoCloseLabel: () => {},
|
|
122
|
+
updateNavItemLabel: () => {},
|
|
123
|
+
updateNavItemLink: () => {},
|
|
124
|
+
updateNavItemIcon: () => {},
|
|
125
|
+
addNavItem: () => {},
|
|
126
|
+
deleteNavItem: () => {},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export const useMagicPill = () => {
|
|
130
|
+
const context = useContext(MagicPillContext);
|
|
131
|
+
if (!context) {
|
|
132
|
+
throw new Error("useMagicPill must be used within a MagicPillProvider");
|
|
133
|
+
}
|
|
134
|
+
return context;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const MagicPillProvider = ({
|
|
138
|
+
children
|
|
139
|
+
}: {
|
|
140
|
+
children: React.ReactNode
|
|
141
|
+
}) => {
|
|
142
|
+
const [pillData, setPillData] = useState<MagicPillType>(defaultPillData);
|
|
143
|
+
|
|
144
|
+
// Create wrapper functions that use the handlers with the local setPillData
|
|
145
|
+
const contextValue: MagicPillContextType = {
|
|
146
|
+
pillData,
|
|
147
|
+
setPillData,
|
|
148
|
+
updateMode: (mode: Mode) => updateMode(mode, setPillData),
|
|
149
|
+
updateNotificationIcon: (icon: NotificationIcon) => updateNotificationIcon(icon, setPillData),
|
|
150
|
+
updateNotificationMessage: (message: string) => updateNotificationMessage(message, setPillData),
|
|
151
|
+
updateCTAIcon: (icon: CTAIcon) => updateCTAIcon(icon, setPillData),
|
|
152
|
+
updateCTALabel: (label: string) => updateCTALabel(label, setPillData),
|
|
153
|
+
updateCTALink: (link: string) => updateCTALink(link, setPillData),
|
|
154
|
+
updateInfoTitle: (title: string) => updateInfoTitle(title, setPillData),
|
|
155
|
+
updateInfoContent: (content: string) => updateInfoContent(content, setPillData),
|
|
156
|
+
updateInfoCloseLabel: (closeLabel: string) => updateInfoCloseLabel(closeLabel, setPillData),
|
|
157
|
+
updateNavItemLabel: (label: string, index: number) => updateNavItemLabel(label, index, setPillData),
|
|
158
|
+
updateNavItemLink: (link: string, index: number) => updateNavItemLink(link, index, setPillData),
|
|
159
|
+
updateNavItemIcon: (icon: CTAIcon, index: number) => updateNavItemIcon(icon, index, setPillData),
|
|
160
|
+
addNavItem: (navItem: MagicPillNavbarItem) => addNavItem(navItem, setPillData),
|
|
161
|
+
deleteNavItem: (index: number) => deleteNavItem(index, setPillData),
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<MagicPillContext.Provider value={contextValue}>
|
|
166
|
+
{children}
|
|
167
|
+
{pillData && <div id="magic-pill-root" />}
|
|
168
|
+
</MagicPillContext.Provider>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
37
171
|
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
closeLabel: "Close" // Label of the "read more" section closing button
|
|
172
|
+
|
|
173
|
+
2. Wrap your app with the provider (in `app/layout.tsx`):
|
|
174
|
+
```typescript
|
|
175
|
+
import "magic-pill/dist/magicpill.css";
|
|
176
|
+
import { MagicPillProvider } from "./contexts/magicPillContext";
|
|
177
|
+
import { MagicPillInitializer } from "./contexts/magicPillInitializer";
|
|
178
|
+
|
|
179
|
+
export default function RootLayout({ children }) {
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<html lang="fr">
|
|
183
|
+
<body>
|
|
184
|
+
<MagicPillProvider>
|
|
185
|
+
{children}
|
|
186
|
+
<MagicPillInitializer />
|
|
187
|
+
</MagicPillProvider>
|
|
188
|
+
</body>
|
|
189
|
+
</html>
|
|
190
|
+
);
|
|
58
191
|
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
3. Create an initializer file for Magic Pill (e.g., in `app/contexts/magicPillInitializer.tsx`):
|
|
195
|
+
```tsx
|
|
196
|
+
"use client"
|
|
197
|
+
import MagicPill from "magic-pill";
|
|
198
|
+
import { useMagicPill } from "./magicPillContext";
|
|
199
|
+
|
|
200
|
+
export const MagicPillInitializer = () => {
|
|
201
|
+
const { pillData } = useMagicPill();
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<MagicPill pillData={pillData}/>
|
|
205
|
+
)
|
|
59
206
|
};
|
|
207
|
+
```
|
|
208
|
+
> **🎉 | At this point, if you launch you app, Magic Pill should appear in your view**
|
|
209
|
+
|
|
210
|
+
4. Use Magic Pill anywhere in your app (e.g., in `app/demo/page.tsx`):
|
|
211
|
+
```typescript
|
|
212
|
+
"use client"
|
|
213
|
+
import { useEffect } from "react";
|
|
214
|
+
import { useMagicPill } from "../contexts/magicPillContext";
|
|
215
|
+
|
|
216
|
+
export default function MPTest() {
|
|
217
|
+
const { setPillData } = useMagicPill();
|
|
218
|
+
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
setPillData({ mode: "notification", notification: { icon: "info", message: "Hello, world!" } });
|
|
221
|
+
}, []);
|
|
222
|
+
|
|
60
223
|
return (
|
|
61
|
-
|
|
224
|
+
<h1>Magic Pill Demo Page</h1>
|
|
62
225
|
);
|
|
63
226
|
}
|
|
64
227
|
```
|
|
65
|
-
|
|
228
|
+
> **It really is as simple as that, to use Magic Pill, once the setup is done**
|
|
229
|
+
|
|
230
|
+
### Update Magic Pill's content granularly
|
|
231
|
+
Magic Pill, right from the start, has been thought out to be as highly customizable as possible.
|
|
232
|
+
To help you use it in the best way possible, a collection of handlers is part of the package.
|
|
233
|
+
|
|
234
|
+
- `updateMode` - Change Magic Pill's mode between "notification" and "navbar"
|
|
235
|
+
- `updateNotificationIcon` - Change the main notification icon
|
|
236
|
+
- `updateNotificationMessage` - Change the main notification message
|
|
237
|
+
- `updateCTAIcon` - Change the notification's CTA (Call To Action) icon
|
|
238
|
+
- `updateCTALabel` - Change the notification's CTA (Call To Action) label
|
|
239
|
+
- `updateCTALink` - Change the notification's CTA (Call To Action) redirection link
|
|
240
|
+
- `updateInfoTitle` - Change the notification's expanded info title
|
|
241
|
+
- `updateInfoContent` - Change the notification's expanded info main content
|
|
242
|
+
- `updateInfoCloseLabel` - Change the notification's expanded info close button's label
|
|
243
|
+
- `updateNavItemLabel` - Change a navbar item's label
|
|
244
|
+
- `updateNavItemLink` - Change a navbar item's link
|
|
245
|
+
- `updateNavItemIcon` - Change a navbar item's icon
|
|
246
|
+
- `handleActiveNavItem` - Automatically working handler directly used by the navbar to update the active link
|
|
247
|
+
- `addNavItem` - Add an item to the navbar
|
|
248
|
+
- `deleteNavItem` - Delete an item to the navbar
|
|
249
|
+
|
|
250
|
+
### Available Icons
|
|
251
|
+
#### Notification Icons
|
|
252
|
+
- `"info"` - Information icon
|
|
253
|
+
- `"checkmark"` - Success/confirmation icon
|
|
254
|
+
- `"questionmark"` - Help/question icon
|
|
255
|
+
- `"coupon"` - Coupon/offer icon
|
|
256
|
+
- `""` - No icon
|
|
257
|
+
|
|
258
|
+
#### CTA (Call to Action) Icons
|
|
259
|
+
- `"arrow"` - Arrow icon
|
|
260
|
+
- `"box"` - Box icon
|
|
261
|
+
- `"checkmark"` - Checkmark icon
|
|
262
|
+
- `"cross"` - Cross/close icon
|
|
263
|
+
- `"info"` - Information icon
|
|
264
|
+
- `"mail"` - Mail/email icon
|
|
265
|
+
- `"plus"` - Plus/add icon
|
|
266
|
+
- `"quotation"` - Quote/speech icon
|
|
267
|
+
- `"tel"` - Phone/telephone icon
|
|
268
|
+
- `"undo"` - Undo/back icon
|
|
269
|
+
- `""` - No icon
|
|
270
|
+
|
|
66
271
|
### Customization
|
|
67
|
-
|
|
272
|
+
Magic Pill is easily customizable through CSS variables. Simply replace the theme colors or fonts by changing the values in the variables set in ":root".
|
|
273
|
+
|
|
68
274
|
```css
|
|
69
275
|
/* Font import */
|
|
70
|
-
@import
|
|
276
|
+
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap');
|
|
71
277
|
|
|
72
278
|
/* CSS variables */
|
|
73
279
|
:root {
|
|
74
|
-
--themeDark: #141414;
|
|
75
|
-
--themeLight: #F9F9F9;
|
|
76
|
-
--font-text: "Overlock", sans-serif;
|
|
77
|
-
--font-accent: "Lexend", sans-serif;
|
|
78
|
-
--normal: normal;
|
|
79
|
-
--italic: italic;
|
|
80
|
-
--medium: 400;
|
|
81
|
-
--bold: 700;
|
|
82
|
-
--black: 900;
|
|
83
|
-
--success: #3F7253;
|
|
84
|
-
--danger: #FC5D6A;
|
|
85
|
-
--textSize: 19.4px;
|
|
86
|
-
--titleSize: 31.42px;
|
|
280
|
+
--themeDark: #141414;
|
|
281
|
+
--themeLight: #F9F9F9;
|
|
282
|
+
--font-text: "Overlock", sans-serif;
|
|
283
|
+
--font-accent: "Lexend", sans-serif;
|
|
284
|
+
--normal: normal;
|
|
285
|
+
--italic: italic;
|
|
286
|
+
--medium: 400;
|
|
287
|
+
--bold: 700;
|
|
288
|
+
--black: 900;
|
|
289
|
+
--success: #3F7253;
|
|
290
|
+
--danger: #FC5D6A;
|
|
291
|
+
--textSize: 19.4px;
|
|
292
|
+
--titleSize: 31.42px;
|
|
87
293
|
}
|
|
88
294
|
```
|
|
295
|
+
|
|
89
296
|
## Build your own
|
|
90
|
-
Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under MIT License, which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
|
|
297
|
+
Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under [MIT License](https://www.tldrlegal.com/license/mit-license), which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
|
|
91
298
|
|
|
92
|
-
Here's how to proceed
|
|
93
|
-
1. Clone the project
|
|
299
|
+
Here's how to proceed:
|
|
300
|
+
1. Clone the project:
|
|
94
301
|
```bash
|
|
95
302
|
git clone https://github.com/CedricTheveneau/Magic-Pill.git
|
|
96
303
|
```
|
|
97
|
-
|
|
304
|
+
|
|
305
|
+
2. Install all dependencies:
|
|
98
306
|
```bash
|
|
99
307
|
npm install
|
|
100
308
|
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
npx create-next-app@latest // Answer the various questions, note that Magic Pill doesn't use TypeScript for now
|
|
104
|
-
```
|
|
105
|
-
```bash
|
|
106
|
-
npm link // Place yourself in the cloned repo's src/ folder
|
|
107
|
-
```
|
|
309
|
+
|
|
310
|
+
3. You're good to go! For easier development, we recommend creating a Next.js app and creating a symbolic link between the app and the package. Now, when you're making changes to the code in src/, the changes should be reflected in your Next.js app.
|
|
108
311
|
```bash
|
|
109
|
-
|
|
312
|
+
# Create a new Next.js app
|
|
313
|
+
npx create-next-app@latest my-app --typescript
|
|
314
|
+
|
|
315
|
+
# Link the package (from the Magic-Pill directory)
|
|
316
|
+
npm link
|
|
317
|
+
|
|
318
|
+
# Link to your app (from your app directory)
|
|
319
|
+
npm link magic-pill
|
|
110
320
|
```
|
|
321
|
+
|
|
111
322
|
## Troubleshooting / Contact
|
|
112
323
|
Magic Pill is still under development, you'll certainly encounter issues with it.
|
|
113
324
|
You can send me emails anytime at [theveneacedricpro@gmail.com](mailto:theveneacedricpro@gmail.com), I'll try my best to help you out.
|
|
325
|
+
|
|
114
326
|
## License
|
|
115
|
-
|
|
116
|
-
|
|
327
|
+
Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/license/mit-license).
|
|
328
|
+
|
|
329
|
+
## What's next?
|
|
117
330
|
| TODO | DOING |
|
|
118
331
|
|-----------|-----------|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
332
|
+
| Support of custom svg icons | Animation fixes |
|
|
333
|
+
| Transition between two modes | Responsive version + Proportions rework |
|
|
334
|
+
| Implementation of function triggers on CTAs | Full documentation |
|
|
335
|
+
| Transition between two modes | Proper testing |
|
|
336
|
+
| Add new modes | |
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "../magicpill.css";
|
|
3
|
+
import { MagicPillNavbar } from "../types";
|
|
4
|
+
interface NavItemsProps {
|
|
5
|
+
mode: "navbar";
|
|
6
|
+
navbar: MagicPillNavbar;
|
|
7
|
+
}
|
|
8
|
+
declare const Navbar: ({ navbar }: NavItemsProps) => React.JSX.Element;
|
|
9
|
+
export default Navbar;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "../magicpill.css";
|
|
3
|
+
import { MagicPillNotification } from "../types";
|
|
4
|
+
interface NotificationProps {
|
|
5
|
+
mode: "notification";
|
|
6
|
+
notification: MagicPillNotification;
|
|
7
|
+
}
|
|
8
|
+
declare const Notification: ({ notification }: NotificationProps) => React.JSX.Element;
|
|
9
|
+
export default Notification;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const ArrowLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
6
|
-
export const BoxLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
7
|
-
export const CheckmarkLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
8
|
-
export const CrossLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
9
|
-
export const MailLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
10
|
-
export const PlusLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
11
|
-
export const QuotationLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
12
|
-
export const TelLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
13
|
-
export const UndoLabel: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
14
|
-
|
|
15
|
-
export const CheckmarkIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
16
|
-
export const CouponIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
17
|
-
export const InfoIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
18
|
-
export const QuestionmarkIcon: React.FC<React.SVGProps<SVGSVGElement>>;
|
|
19
|
-
|
|
20
|
-
// Déclaration des types pour le props de MagicPill
|
|
21
|
-
export interface MagicPillProps {
|
|
22
|
-
pillData: {
|
|
23
|
-
icon: 'checkmark' | 'coupon' | 'info' | 'questionmark'; // Types d'icônes disponibles
|
|
24
|
-
message: string;
|
|
25
|
-
cta?: {
|
|
26
|
-
icon: 'arrow' | 'box' | 'checkmark' | 'cross' | 'mail' | 'plus' | 'quotation' | 'tel' | 'undo'; // Types d'icônes CTA disponibles
|
|
27
|
-
label: string;
|
|
28
|
-
link: string;
|
|
29
|
-
};
|
|
30
|
-
info?: {
|
|
31
|
-
title: string;
|
|
32
|
-
content: string;
|
|
33
|
-
closeLabel: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Déclaration du composant MagicPill
|
|
39
|
-
const MagicPill: React.FC<MagicPillProps>;
|
|
40
|
-
|
|
41
|
-
export default MagicPill;
|
|
42
|
-
}
|
|
1
|
+
export { default } from './MagicPill';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './utils/handlers';
|
|
4
|
+
export * from './utils/icons';
|