@misnpm/design-blog
v1.0.62
Published
This project provides a flexible and customizable Design Blog Manager component for React applications. It allows developers to easily integrate and style blog post displays with various UI designs.
Downloads
657
Keywords
Readme
Design Blog Manager Component Library
This project provides a flexible and customizable Design Blog Manager component for React applications. It allows developers to easily integrate and style blog post displays with various UI designs.
The Design Blog Manager is a versatile component that can render different UI layouts for blog posts. It's built with TypeScript and React, offering a type-safe and component-based approach to displaying blog content. The library is bundled using Rollup, ensuring compatibility with various module systems.
Key features include:
- Multiple UI design options for blog post displays
- Customizable styling through props
- TypeScript support for type safety
- Storybook integration for component development and testing
- Easy integration with existing React projects
- Edit mode for managing blog posts
- Color customization for various elements
- Add and delete functionality for blog posts
Repository Structure
.
├── dist
│ ├── components
│ │ ├── buttons
│ │ ├── desings
│ │ │ ├── cards
│ │ │ ├── detalle
│ │ │ └── title
│ │ ├── form
│ │ └── modals
│ ├── index.cjs.js
│ ├── index.d.ts
│ ├── index.esm.js
│ └── utils
├── src
│ ├── components
│ │ ├── buttons
│ │ ├── desings
│ │ │ ├── cards
│ │ │ ├── detalle
│ │ │ └── title
│ │ ├── form
│ │ └── modals
│ ├── index.tsx
│ └── utils
├── .storybook
├── package.json
├── README.md
├── rollup.config.js
└── tsconfig.json
Key Files:
src/index.tsx
: Entry point that exports theDesignBlogManager
componentsrc/components/DesignBlogManager.tsx
: Main component for managing blog post UIsrc/components/desings/cards/UI1/UI1.tsx
: Example UI design implementation for cardssrc/components/desings/detalle/UI1/UI1Detail.tsx
: Example UI design implementation for detailed viewsrc/components/form/BlogForm.tsx
: Form component for adding and editing blog postsrollup.config.js
: Rollup configuration for building the librarytsconfig.json
: TypeScript configuration file
Usage Instructions
Installation
Prerequisites:
- Node.js (version 12 or higher)
- npm or yarn
To install the package in your project, run:
npm install @misnpm/design-blog
or if you're using yarn:
yarn add @misnpm/design-blog
Getting Started
- Import the
DesignBlogManager
component in your React application:
import { DesignBlogManager } from '@misnpm/design-blog';
- Use the component in your JSX, specifying the props:
<DesignBlogManager
propsUI={{
titleSection: "Latest Blog Posts",
colorTitleSection: "#333333",
title: "My First Blog Post",
titleTextColor: "#000000",
image: "https://example.com/image.jpg",
id: "1",
shortDescription: "This is a short description of the blog post.",
shortDescriptionTextColor: "#666666",
tag: "Technology",
tagTextColor: "#FFFFFF",
tagColor: "#007BFF",
date: "2023-04-01",
dateTextColor: "#999999",
buttonTextColor: "#007BFF",
buttonText: "Read More",
buttonAction: (id) => console.log(`Read more clicked for post ${id}`),
editMode: false,
onEdit: () => console.log("Edit clicked"),
onDelete: () => console.log("Delete clicked"),
onAdd: () => console.log("Add clicked")
}}
/>
Configuration Options
The DesignBlogManager
component accepts the following main prop:
propsUI
: An object containing the props for the UI design
The available props for the UI design include:
titleSection
: The title of the blog sectioncolorTitleSection
: Color of the section titletitle
: Title of the blog posttitleTextColor
: Color of the blog post titleimage
: URL of the blog post imageid
: Unique identifier for the blog postshortDescription
: Brief description of the blog postshortDescriptionTextColor
: Color of the short description texttag
: Tag or category of the blog posttagTextColor
: Color of the tag texttagColor
: Background color of the tagdate
: Publication date of the blog postdateTextColor
: Color of the date textbuttonTextColor
: Color of the "Read More" button textbuttonText
: Text for the "Read More" buttonbuttonAction
: Function to be called when the "Read More" button is clickededitMode
: Boolean to enable or disable edit modeonEdit
: Function to be called when the edit button is clickedonDelete
: Function to be called when the delete button is clickedonAdd
: Function to be called when the add button is clicked
Testing & Quality
To run the Storybook development environment for testing and developing components:
npm run storybook
This will start the Storybook server on port 6006. You can then view and interact with the components in your browser.
Troubleshooting
Common issues and solutions:
Problem: Components not rendering correctly
- Error message: "Error: UI not found."
- Diagnostic process:
- Check that all required props are provided in the
propsUI
object - Verify that the component is being used correctly
- Check that all required props are provided in the
- Solution: Ensure you're providing all necessary props
Problem: TypeScript errors when using the component
- Error message: "Property 'X' is missing in type '{ ... }' but required in type 'UI1Props'"
- Diagnostic process:
- Check the prop types defined in the UI component (e.g.,
UI1Props
interface) - Ensure all required props are being passed to the
DesignBlogManager
- Check the prop types defined in the UI component (e.g.,
- Solution: Provide all required props as defined in the component's interface
For debugging, you can enable more verbose console logging by setting the DEBUG
environment variable:
DEBUG=design-blog:* npm start
This will output additional information to the console, which can help identify issues with prop passing or component rendering.
Data Flow
The Design Blog Manager component follows a unidirectional data flow:
- The parent component provides props to
DesignBlogManager
DesignBlogManager
renders the appropriate UI components based on the provided props- The UI components (e.g., UI1, UI1Detail) receive props and render the blog post
- User interactions (e.g., clicking "Read More", "Edit", "Delete", or "Add") trigger callbacks passed as props
- The parent component handles these callbacks and updates the state or performs necessary actions
[Parent Component]
|
| (props, including editMode and callbacks)
v
[DesignBlogManager]
|
| (props)
v
[UI Components]
|
| (render)
v
[User Interface]
|
| (interactions: read more, edit, delete, add)
v
[Callback Functions]
Note: The buttonAction
, onEdit
, onDelete
, and onAdd
props allow for custom handling of user interactions, enabling integration with navigation or state management systems in the parent application.