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

@amplience/dc-integration-stylitics

v1.0.0

Published

Library of utilities to make using Amplience and Stylitics together simpler.

Downloads

100

Readme

@amplience/dc-integration-stylitics

Stylitics Widgets)

A library for managing Stylitics Widgets within modern web frameworks, configuring them with content items from Amplience, as well as a collection of Content Types and Schemas you can install to make integrating Stylitics with Amplience considerably easier.

⚙️ Features

  • Convert Content Item into Stylitics arguments
  • Automatically create Stylitics Widgets
  • Import Schemas, Content Types, sample Content Items into a Dynamic Content hub
  • Use provided Templates for Content Rendering Service visualisation and cards

🏁 Quickstart

Using the Stylitics integration library requires a simple import from NPM or linking a prebuilt js file.

Once imported, the following two methods can be used:

  • fromContentItem: Convert from a content item containing Stylitics widget configuration into arguments you can provide to create the widget.
  • createWidget: Create a Stylitics widget with a given set of arguments, including view type and account. Automatically loads necessary scripts for the view type asynchronously, and keeps them loaded for future requests.

These can be used regardless of implementation type (NodeJS project, Simple HTML/JS/CSS project or even using the Amplience Content Rendering Service)

The examples below show how you would use in each implementation type. We would recommend using the Amplience DC Delivery SDK to fetch your content

NodeJS Usage Example

Install the package from NPM:

npm i @amplience/dc-integration-stylitics

You can use it in your project as follows:

import { fromContentItem, createWidget } from '@amplience/dc-integration-stylitics';

// Fetch from DC, in the format found in the automation.
const contentItem = {
    ...
}

const element = document.getElementById('widget');

const args = fromContentItem(contentItem);
const widget = await createWidget(element, args);

widget.start();

Similar to using the Stylitics widget manually, you can set overrides before starting the widget, refresh it with new arguments, or destroy() it when finished.

Usage HTML / JavaScript / CSS

For projects that don't use node, you can import a pre-packaged script that places the module in the global scope as ampStylitics:

<script src="https://unpkg.com/@amplience/dc-integration-stylitics/dist/ampStylitics.browser.umd.min.js"></script>

<div id="widget"></div>

<script>
    // Fetch from DC, in the format found in the automation.
    const contentItem = {
        ...
    }

    const element = document.getElementById('widget');

    const args = ampStylitics.fromContentItem(contentItem);
    ampStylitics.createWidget(element, args).then(
        widget => widget.start()
    );
</script>

Example

In the /examples folder you will see an implementation with the following files that includes fetching an item, instantiating the widget and support for real-time visualisation:

HTML Example: examples/stylitics-generic-html.html

JavaScript used to fetch content / visualisation: examples/stylitics-widget.js

🌍 Useful Links