1.4.3 • Published 2 months ago

@simondmc/popup-js v1.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

popup-js

A sleek and highly customizable JavaScript library used to generate full-screen infographic popups with minimal effort.

Installation

Install popup-js with the following script tag:

<script src="https://cdn.jsdelivr.net/npm/@simondmc/popup-js@1.4.3/popup.min.js"></script>

Documentation

A full documentation is available here.

Usage/Examples

Create a popup by instantiating the Popup class with customization parameters.

const myPopup = new Popup({
    id: "my-popup",
    title: "My First Popup",
    content: `
        An example popup.
        Supports multiple lines.`,
});

Display the popup by calling the .show() method.

myPopup.show();

Examples of a more complex popup:

/* A demo popup showing a lot of the library features. */
const popup = new Popup({
    id: "demo-popup",
    title: "Demo Popup",
    content: `
        This is a demo of the popup library.
        big-margin§This line has a larger top margin.
        This is an example of {a-https://example.com}[a link].
        This is an example of {btn-red-button}[a red button].
        This text is {red}[red] {bold green}[bold green] {blue}[blue]].
        This text has a                lot of spaces.
        big-margin space-out§This line and the next {btn-b1}[Button 1]
        space-out§are left aligned. {btn-b2}[Button 2]
        big-margin§This text {shadow}[has {white}[some] shadow].`,
    titleColor: "#4842f5",
    backgroundColor: "#bff7ff",
    showImmediately: true,
    sideMargin: "15%",
});
/* A popup from one of my projects showing its usage. */
const infoPopup = new Popup({
    id: "color-info",
    title: "Color Guesser",
    content: `
        You are presented with a color.
        Estimate the hex code of the color.
        Six characters, ranging from 00-FF for 3 channels.
        Values are in {a-https://learn.sparkfun.com/tutorials/hexadecimal/hex-basics}[Base-16].
        big-margin§{bold}[#{red}[E4]{green}[F2]{blue}[DB]]
        big-margin§{black bold}[#000000] is black.             {white bold shadow}[#FFFFFF] is white.
        big-margin§Good luck.`,
    titleColor: "rgb(92, 0, 95)",
    titleMargin: "0",
    backgroundColor: "#ffebfe",
    showImmediately: true,
    showOnce: true,
});

Color Guesser Popup Showcase

Cheat Sheet

Below is a table of all the parameters you can use to customize your popup.

ParameterTypeDefaultDescription
idstringpopupThe ID of the popup (must be unique).
titlestringPopup TitleThe title of the popup.
contentstringPopup ContentThe content of the popup.
titleColorcolor#000000The color of the title.
backgroundColorcolor#FFFFFFThe color of the popup background.
textColorcolor#000000The color of the content.
closeColorcolor#000000The color of the close button.
linkColorcolor#383838The color of links.
fixedHeightbooleanfalseWhether the popup should have a fixed height.
widthMultipliernumber1How wide should the popup be relatively to the default width.
heightMultipliernumber0.66How tall should the popup be relatively to the default width (only used if fixedHeight is true).
fontSizeMultipliernumber1How large should the content font be relatively to the default content font size.
fontstringInterThe popup font.
titleMarginlength2%The space between the popup title and content.
sideMarginlength3%The space between the content and the edge of the popup.
lineSpacinglengthautoThe spacing between lines in the popup body.
buttonWidthlengthfit-contentThe width of buttons in the popup body.
borderWidthlength0The width of the popup border.
borderColorcolor#000000The color of the popup border.
borderRadiuslength15pxThe popup border radius (controls how rounded the corners are).
showImmediatelybooleanfalseWhether the popup should be shown immediately after being created (usually on page load).
showOncebooleanfalseWhether the popup should only be shown once.
hideCloseButtonbooleanfalseWhether the popup should display without a close button.
hideTitlebooleanfalseWhether the popup should display without a title.
disableScrollbooleantrueWhether page scrolling should be disabled while the popup is open.
underlineLinksbooleanfalseWhether links should be underlined.
allowClosebooleantrueWhether the popup should be closeable by the user.
textShadowstringnoneThe text shadow of the popup body.
fadeTimetime0.3sThe time it should take for the popup to fade in and out.
hideCallbackfunctionundefinedA function to be called when the popup is closed.
loadCallbackfunctionundefinedA function to be called when the popup - and all its elements - are first loaded.
cssstring""Custom CSS to be applied to the popup.

For a full explanation of the parameters, see the documentation.

License

This project is released under the MIT license.

Contributing

Contributions are always welcome!

If you want a feature which currently doesn't exist, feel free to open a pull request.

1.4.3

2 months ago

1.4.2

10 months ago

1.4.1

10 months ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago