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

@aurigma/ui-framework

v4.46.68

Published

A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.

Downloads

1,111

Readme

UI-framework

The ordering and personalization process can be organized on a step-by-step basis. For example, your users may:

  1. Edit the front side of the product.
  2. Select an envelope.
  3. Edit the back side.
  4. Specify any order options.

Even more complicated workflows may exist.

UI-framework allows you to implement such a step sequence by composing your application from widgets like from building blocks in a configuration file. That allows for the flexible Customer's Canvas even by non-programmers, no matter if you need a simple editor or a multi-step wizard.

How to use it

Download

To download the UI Framework, just run:

npm install @aurigma/ui-framework

The package is already compiled and bundled, there is no need to re-build it.

If you don't want to install it locally, you can use Azure CDN:

https://staticjs-aurigma.azureedge.net/ui-framework/latest

Load the editor on a page

Starting with UI Framework 4.0, you should load the editor to the page as follows:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
    integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
  <style>
    .editor-container {
      padding-top: 16px;
      height: 90vh;
    }
  </style>
  <title>UI Framework Sample</title>
</head>

<body>
  <div class="container-fluid">
    <div id="editor-container" class="editor-container"></div>

    <script type="module">
      const uiFrameworkBaseUrl = "https://staticjs-aurigma.azureedge.net/ui-framework/latest";
      import moduleLoader from "https://staticjs-aurigma.azureedge.net/ui-framework/latest/moduleLoader.js";
      document.addEventListener('DOMContentLoaded', async () => {

        // See https://customerscanvas.com/dev/editors/ui-framework/ecommerce-driver.html
        // for more details.
        const prodRequest = await fetch('./sample/product.json');
        const product = await prodRequest.json();

        // See https://customerscanvas.com/dev/editors/ui-framework/overview.html for 
        // the syntax explanation and widget reference. 
        const confRequest = await fetch('./sample/config.json')
        const config = await confRequest.json();

        let driver = (await moduleLoader.dynamicImport("ecommerceDriver", `${uiFrameworkBaseUrl}/drivers/default-driver.js`)).ecommerceDriver;
        let editor = (await moduleLoader.dynamicImportDefault("editor", `${uiFrameworkBaseUrl}/editor.js`)).editor;

        // Don't forget to specify actual link to your instance of Customer's Canvas as a value of customersCanvasBaseUrl
        let ecommerce = await driver.init(product, editor, config, /* settings */ { customersCanvasBaseUrl: "" }, /* restore data */ null, /*quantity*/ 1, /* user info*/ { id: 'test-user' });
        ecommerce.products.current.renderEditor(document.getElementById("editor-container"));

        // How to receive data from the editor after the user finishes editing it
        ecommerce.cart.onSubmitted.subscribe(function (data) {
          console.log("submitted");
          data.lineItems.forEach(function (order) {
            console.log(order);
          })
        });

      });
    </script>
</body>

</html>

A few comments on this:

  1. Create a div element which will be a container for the editor.
  2. The editor is loaded to the page using the moduleLoader script which allows dynamically importing of ES6 modules.
  3. All modules are located from the location you configure with the uiFrameworkBaseUrl variable. Since the import keyword in JavaScript supports only string literals, you have to duplicate the URL there as well.
  4. There are two JSON object you have to prepare to pass to the editor - the product and the config. In this demo they are harcoded, however, in a real-life application you should either send them from back end or create dynamically.
    • The product contains a definition of the product from the ecommerce system. See the Working With E-commerce Driver article for details.
    • The config describes the user interface and the behavior of the editor. This sample illustrates the simplest possible config which does nothing for brevity. See the Introduction to UI Framework and other documentation articles to learn how to create more useful configs.
  5. You should load a couple of UI Framework modules (ecommerce driver and the editor) and initialize them using the driver.init(...) method where you pass product, config, and some other data. After that you are using the renderEditor method where you pass the container element you created on the step 1.
  6. To get the information from the editor when the user finishes editing, you can subscribe for the onSubmitted event handler. Other events also exist.