Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@amplience/dc-integration-stylitics
Advanced tools
Library of utilities to make using Amplience and Stylitics together simpler.
Readme
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.
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
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.
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>
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
FAQs
Library of utilities to make using Amplience and Stylitics together simpler.
The npm package @amplience/dc-integration-stylitics receives a total of 40 weekly downloads. As such, @amplience/dc-integration-stylitics popularity was classified as not popular.
We found that @amplience/dc-integration-stylitics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.