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

react-cms-builder

v2.0.2

Published

A ReactJS CMS library for building HTML content dynamically.

Downloads

46

Readme

React CMS - DynamicCMSPanel

DynamicCMSPanel is a flexible drag-and-drop content management system (CMS) for React applications. It allows users to dynamically build HTML content with customizable components like text, title, paragraph, images, banner, videos, buttons, and more.

Installation

To install this package, run the following command:

npm install react-cms-builder

Usage

import React from 'react';
import { DynamicCMSPanel } from 'react-cms-builder';

const handleSave = (data) => {
  console.log('Saved JSON:', data);
  // You can send the JSON to a server or store it in localStorage here
};

const MyApp = () => (
  <div>
    <h1>Dynamic CMS</h1>
    <DynamicCMSPanel handleSave={handleSave} />
  </div>
);

export default MyApp;

Editable Content

If you have previously saved data, you can send props as data. After that, you can perform editing operations on it.
Sample Data

const data = [
  {
    id: 1729145639972,
    type: "container",
    data: [
      {
        id: 1729145639973,
        type: "column",
        content: [
          {
            type: "title",
            props: {
              level: 1,
              text: "<p>Click here to edit<strong> this title!</strong></p>",
              alignment: "center",
              classNames: "custom-title",
            },
          },
        ],
      },
      {
        id: 1729145655752,
        type: "column",
        content: [
          {
            type: "button",
            props: {
              text: "Edit Button Text",
              backgroundColor: "#b80000",
              borderRadius: "20",
              alignment: "center",
            },
          },
          {
            type: "paragraph",
            props: { content: "<p>Click here to edit this paragraph</p>" },
          },
          {
            type: "text",
            props: {
              text: '<p>Click here<strong style="color: rgb(153, 51, 255);"> to edit this textaasdsd</strong></p>',
            },
          },
        ],
      },
    ],
  },
  {
    id: 1729145740140,
    type: "container",
    data: [
      {
        id: 1729145740141,
        type: "column",
        content: [
          {
            type: "image",
            props: {
              src: "https://sehrimbu.com/images/places_image_two-1723977907871-932935019.jpeg",
              alt: "test",
              objectFit: "fill",
              borderRadius: "20",
              classNames: "custom-image",
            },
          },
        ],
      },
      {
        id: 1729145801028,
        type: "column",
        content: [
          {
            type: "paragraph",
            props: { content: "Click here to edit this paragraph" },
          },
        ],
      },
    ],
  },
];

 <DynamicCMSPanel handleSave={handleSave} data={data} />

Components Overview

DynamicCMSPanel provides the following components, which can be dragged from the sidebar and dropped into the canvas to build a page:

  • Container: Main container that can hold multiple columns.
  • Column: Used to layout components inside a container. You can add multiple columns within a container.
  • Text: A block of text that can be customized with rich text editing features.
  • Image: Add and customize images, with properties like src, alt, and objectFit.
  • Button: Add buttons with customizable styles, onClick actions, and other attributes.
  • Video: Embed videos from YouTube or other sources with options like controls, autoPlay, and borderRadius.
  • Title: Add headings (h1, h2, etc.) to your layout.
  • Paragraph: Add paragraphs with customizable text.
  • Banner: Add banners with customizable text and background images or colors.

DynamicCMSPanel props

| Props | type | | ----------------- | ------------------------------------------------------------------ | | handleSave | func

DynamicCMSRenderer

To display the data created with DynamicCMSPanel on the screen

import React from 'react';
import { DynamicCMSRenderer } from 'react-cms-builder';

const MyApp = () => (
  <div>
    <h1>Dynamic CMS Render</h1>
    <DynamicCMSRenderer data={data} />
  </div>
);

export default MyApp;

DynamicCMSRenderer props

| Props | type | | ----------------- | ------------------------------------------------------------------ | | data | array |

JSON Output

[
  {
    "id": 1,
    "type": "container",
    "data": [
      {
        "id": 2,
        "type": "column",
        "content": [
          {
            "type": "text",
            "props": {
              "text": "<p>This is a sample text</p>",
              "alignment": "center"
            }
          },
          {
            "type": "image",
            "props": {
              "src": "https://via.placeholder.com/150",
              "alt": "Sample Image",
              "objectFit": "cover"
            }
          }
        ]
      }
    ]
  }
]

JSON Structure

  • id: Unique identifier for each component or container.

  • type: Defines the type of the component (container, column, text, image, button, etc.).

  • props: Contains the properties of the component (e.g., text, src, alt, alignment...).

Support buymeacoffee

buymeacoffee

Demo Application

app app app app app app app

Related Projects

react-dnd

Support buymeacoffee

buymeacoffee

Lisans

License This project is licensed under the MIT License. See the LICENSE file for more details.