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

@giftme/partner-checkout

v1.0.4

Published

The `@giftme/partner-checkout` package enables Giftme partners to integrate a seamless gift card purchasing experience into their websites. This enhances the e-commerce capabilities of partners by allowing them to feature a custom-branded storefront for G

Downloads

16

Readme

@giftme/partner-checkout

The @giftme/partner-checkout package enables Giftme partners to integrate a seamless gift card purchasing experience into their websites. This enhances the e-commerce capabilities of partners by allowing them to feature a custom-branded storefront for Giftme's diverse range of eGift cards.

Installation

Install the package with npm to include it in your project. This step is required before you can utilize the functionality provided by @giftme/partner-checkout.

npm install @giftme/partner-checkout

API Overview

Store Interface

The store interface contains methods for initializing and destroying the store modal. It ensures that the modal is correctly bound to the appropriate elements on the website for user interaction.

interface store {
    init: () => void; // Initializes the store and binds to elements.
    destroy: () => void; // Removes bindings and cleans up.
}

Widget Interface

The widget interface governs the display and behavior of a customizable button widget on the webpage, allowing users to interact and initiate the gift card purchasing process.

interface widget {
    attach: (config: WidgetConfig) => void; // Attaches a customizable 'Buy eGift cards' button to the page.
    destroy: () => void; // Removes the widget from the page when not needed.
    show: () => void; // Reveals the widget on the page.
    hide: () => void; // Conceals the widget from the user's view.
}

export interface WidgetConfig {
    url: string;
    position: Position;
    theme?: WidgetTheme;
    size?: WidgetSize;
}

export type WidgetTheme = 'primary' | 'secondary' | 'tertiary' | 'dark' | 'light' | '';
export type WidgetSize = 'xs' | 'sm' | 'base' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';

Positioning and Units

This section defines how to use CSS strings to position elements managed by the package, allowing for a responsive and adaptable layout.

export type PositionString = 'tr' | 'tl' | 'br' | 'bl'; // Corner positions shorthand: tr for top-right, tl for top-left, br for bottom-right, bl for bottom-left.
export type PositionObject = {
    top?: string; // Any valid CSS size value like '10px', '10rem', etc.
    left?: string;
    right?: string;
    bottom?: string;
    zIndex?: number;
};
export type Position = PositionString | PositionObject; // Allows for simple or detailed positioning.

Basic Usage

Widget Management

The widget management section guides you through adding the eGift card purchase button to your page, positioning it, and customizing its appearance and size.

import { widget } from '@giftme/partner-checkout';

widget.attach({
    url: 'https://<partner_id>shopgiftme.com',
    position: 'br', // Positioning options.
    theme: 'primary', // Theme options: 'primary', 'secondary', etc.
    size: 'xl', // Size options: 'xs', 'sm', 'lg', etc.
});

// Programatically show or hide the widget:
widget.show();
widget.hide();

// Remove the widget from the page when it's no longer required:
widget.destroy();

Widget Positioning and Customization Example

Examples showing how to position the eGift card widget using both shorthand positions and specific positioning objects, and how to apply themes and sizes.

// Customizing positioning, theme, and size
widget.attach({
    url: 'https://<partner_id>.shopgiftme.com',
    position: 'tr', // top-right
    theme: 'dark',
    size: 'md',
});

// Object positioning with theme and size
widget.attach({
    url: 'https://<partner_id>.shopgiftme.com',
    position: { bottom: '20px', right: '20px' },
    theme: 'light',
    size: '2xl',
});

Advance Usage

Store Initialization

Initializing the store sets up the necessary bindings to HTML elements with data-gpc-url, preparing them to open the store modal when interacted with.

import { store } from '@giftme/partner-checkout';

store.init();

HTML Element Example

Bind the store modal to an HTML element to provide users with direct access to the Giftme checkout interface.

<button type="button" data-gpc-url="https://<partner_id>.shopgiftme.com/store">Buy eGift Cards</button>

or

<a href="#" data-gpc-url="https://<partner_id>.shopgiftme.com/buy-gift-cards/<merchant>"> (Merchant) Gift Card </a>

Store Destruction

Destroying the store is crucial for cleaning up and ensuring that the modal bindings do not interfere with other JavaScript on the page when they are no longer needed.

import { store } from '@giftme/partner-checkout';

store.destroy();

Browser Usage

If your website does not use a build process with module bundlers, you can include the script directly in your HTML to use the package.

<script
    type="text/javascript"
    src="https://cdn.jsdelivr.net/npm/@giftme/[email protected]/dist/index.umd.js"
></script>

Example

<script type="text/javascript">
    // Assuming the global object `gpc` is exposed by the package
    window.gpc.store.init();

    // To destroy the instance when needed
    window.gpc.store.destroy();

    // Attaches widget to page
    window.gpc.widget.attach({
        url: 'https://<partner_id>.shopgiftme.com',
        position: 'br', // or an object like { bottom: '20px', right: '20px' }
    });
</script>

Support

Should you encounter any issues or require assistance, this section provides contact information for reaching out to the support team.