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

@openlettermarketing/olc-react-sdk

v1.2.0

Published

Simplify template builder integration for any product.

Downloads

944

Readme

Integration Guide

OLC React SDK Integration Guide

Introduction

The OLC React SDK allows developers to integrate a customizable template builder into their applications. This guide provides step-by-step instructions to help you install, configure, and use the SDK.

1. Installation

Start by installing the OLC React SDK via NPM.

npm install @openlettermarketing/olc-react-sdk

2. Importing and Initializing the SDK

After installation, import the SDK into your React application and configure the required properties to initialize the TemplateBuilder component.

Complete coverage usage:.

The following example shows the demo of all props minimalist usage, For the real case integration, see integration example.

import TemplateBuilder from '@openlettermarketing/olc-react-sdk';

const templateBuilderProps = {
  container: document.getElementById('element-id'),
  secretKey: 'your-secret-key',
  basicAuthUsername: 'your-username',
  basicAuthPassword: 'your-password',
  platformName: 'Your Platform Name',
  createTemplateRoute: '/create-template',
  templateBuilderRoute: '/edit-template',
  olcTemplate: yourTemplateObject,
  sandbox: true,
  onReturnAndNavigate () {
    // TODO: Define what happens when the user returns and navigates.
  },
  async onGetOneTemplate (payload) => {
    // TODO: Fetch a specific template.
  },
  async onGetTemplates (payload) => {
    // TODO: Fetch all templates.
  },
  async onGetCustomFields () => {
    // TODO: Fetch custom fields for the templates.
  },
  async onSubmit (payload) => {
    // TODO: Handle the submission of a template.
  },
  styles: {
    root: {
      // Custom CSS properties for the root element.
    },
  },
};

TemplateBuilder(templateBuilderProps);

3. Configuration through Props

The SDK uses several properties to manage its behavior. Below is a breakdown of key props:

| Prop name | Type | Description | Required | Example / Usage | |------------------------|:-----------------|----------------------------------------------------------------------------------------------------------------|----------|:-----------------------------------------------------------| | container | HTMLDivElement | An HTML DOM element to render the template builder component. | ✓ | document.getElementById('template-builder-container') | | secretKey | string | That key is used to communicate Polotno Editor (Builder) with API requests. | ✓ | 'your-secret-key' | | basicAuthUsername | string | Username for basic authentication. | ✓ | 'your-username' | | basicAuthPassword | string | Password for basic authentication. | ✓ | 'your-password' | | platformName | string | The name of your platform. | ⤫ | 'My App' | | createTemplateRoute | string | The route/path for creating new templates. (begins with slash /) | ⤫ | '/create-template' | | templateBuilderRoute | string | The route/path for editing existing templates. (begins with slash /) | ⤫ | '/edit-template' | | olcTemplate | object | The template object to be edited or used as a base. | ⤫ | { ... } | | sandbox | boolean | The sandbox setting can be either true or false. Set to true for demo purposes and false for production. | ⤫ | true | | onReturnAndNavigate | function | An event which triggers when a user navigates away. | ⤫ | onReturnAndNavigate () { ... } | | onGetOneTemplate | function | An event which triggers when fetching a specific template. | ⤫ | onGetOneTemplate ( payload ) { ... } | | onGetTemplates | function | An event which triggers when fetching all templates. | ⤫ | onGetTemplates ( payload ) { ... } | | onGetCustomFields | function | An event which triggers when fetching custom fields for templates. | ⤫ | onGetCustomFields () { ... } | | onSubmit | function | An event which triggers upon template submission. | ⤫ | onSubmit () { ... } | | styles | object | An object of JSS props for customize styling of template builder. | ⤫ | { root: { ... } } |

4. API Integration

To integrate the SDK’s API, ensure that your backend securely communicates with the OLC Backend, returning the necessary data to the SDK frontend.

5. Customization and Styling

The SDK allows for extensive customization of the template builder’s appearance. Use the styles prop to apply custom CSS properties and match the look and feel of your application.

6. Real-case of usage

Below is an example of how to use the SDK within a React component:

import { useEffect } from 'react';

// SDKs
import TemplateBuilder from '@openlettermarketing/olc-react-sdk';

// styles
import '@blueprintjs/core/lib/css/blueprint.css';

const App = () => {
  useEffect(() => {
    TemplateBuilder({
      container: document.getElementById('template-builder-container'),
      secretKey: 'your-secret-key',
      basicAuthUsername: 'your-username',
      basicAuthPassword: 'your-password',
      sandbox: false,
      async onSubmit (payload) {
        console.log('Template submitted:', payload);
        // Implement your submission logic here
      },
    });
  }, []);

  return (
    <>
      {/** ... */}
      <div id="template-builder-container" />
    </>
  );
}

export default App;