npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

magic-pill

v7.1.3

Published

A new way to guide your audience and bring them contextual information through your app

Downloads

2,391

Readme

Magic Pill

Let it empower you.

Disclaimer

Even though Magic Pill is already available to everyone, please keep in mind that its development is not over yet. You can technically use it but there's no real documentation yet. I'll update this section once a real usable version is released.

Thank you !!

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.

Badges

npm version npm downloads DeepScan grade Known Vulnerabilities

Introduction

Magic Pill is a simple yet powerful React component that lets you show contextual information to your users. It mimicks Apple's Dynamic Island's behavior and is inspired by Xbox's achievement notification as well. You can show notifications with a quick action, or even some additional content based on the content the users are seeing.

Magic Pill helps you build elegant and sober yet impactful interactions with your audience really easily. The goal is to empower both you, and your users.

What comes with it ?

  • [X] Highly customizable React component with various props configurations
  • [X] Fully customized styling based on CSS variables for easy adaptation to your theme if needed
  • [X] Built with NextJS in mind right from the start, also works with vanilla React
  • [X] No external library dependency (appart from bundling)
  • [X] Lightweight and efficient

Installation

Magic Pill is available on npm, simply use the following command and you're ready to go !

npm install magic-pill

How to use it ?

Import styles

For it to work properly, you need to import styles in your app (we recommend importing it into your app.js file).

// Import dans votre projet Next.js ou React
import 'magic-pill/dist/magicpill.css';

Usage with React

Add Magic Pill to any project simply by importing it into your app and calling it inside the component :

import React from 'react';
import MagicPill from 'magic-pill';

export default function App() {
// pillData would be stored in a global Context and updated dynamically through other components
const  pillData  = {
	icon: "checkmark", // Value can be : "checkmark", "coupon", "info", "questionmark"
	message:  "Congrats, you've earned a coupon!",
	cta: {
		icon:  "arrow", // Value can be : "arrow", "box", "checkmark", "cross", "mail", "plus", "quotation", "tel", "undo"
		label:  "Discover our offer",
		link:  "https://www.example.com"  // Link for the CTA (will be set to null if nothing is specified)
	},
	info: {
		title:  "Details of the offer", // Title for the "read more" section
		content:  "<p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur vos prochains achats avec ce coupon !</p><p>Profitez de 10% de réduction sur v", // HTML content to insert in the "read more" section
		closeLabel:  "Close"  // Label of the "read more" section closing button
}
};
  return (
    <MagicPill pillData={pillData}/>
  );
}

Please note : as Magic Pill was intended to be a system-wide glorified toast solution, we recommend adding it to your App component and keeping its props in a global Context, in which you could send contextual data from any component that uses the Context.

Customization

As said before, Magic Pill is easily customizable, it was intended to be right from the start. We used CSS variables to define its style. Simply replace the theme colors or fonts by changing the values in the variables set in ":root".

/* Font import */
@import  url('https://fonts.googleapis.com/css2?family=Lexend:[email protected]&family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap');

/* CSS variables */
:root {
--themeDark: #141414;
--themeLight: #F9F9F9;
--font-text: "Overlock", sans-serif;
--font-accent: "Lexend", sans-serif;
--normal: normal;
--italic: italic;
--medium: 400;
--bold: 700;
--black: 900;
--success: #3F7253;
--danger: #FC5D6A;
--textSize: 19.4px;
--titleSize: 31.42px;
}

Build your own

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.

Here's how to proceed :

  1. Clone the project :
git clone https://github.com/CedricTheveneau/Magic-Pill.git
  1. Install all dependencies
npm install
  1. You're good to go ! Though, for easier development, we recommend creating a NextJS / React 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 NextJS app.
npx create-next-app@latest // Answer the various questions, note that Magic Pill doesn't use TypeScript for now
npm link // Place yourself in the cloned repo's src/ folder
npm link // Place yourself in the app/ folder of your NextJS app

Troubleshooting / Contact

Magic Pill is still under development, you'll certainly encounter issues with it. You can send me emails anytime at [email protected], I'll try my best to help you out.

License

As stated before, Magic Pill is distributed under the MIT License.

What's next ?

| TODO | DOING | |-----------|-----------| | Implementation with APIs | Better conditioning of displays depending on props | | Proper testing | Animation fixes | | Full documentation | Responsive version + Proportions rework |