1.0.0 • Published 9 months ago

@precooked/react-markdown-preview-modal v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

@precooked/react-markdown-preview-modal

Precooked Logo

@precooked/react-markdown-preview-modal is a modal component for rendering Markdown content in React projects. It supports GitHub Flavored Markdown (GFM) syntax, making it ideal for previews.

Installation

npm install @precooked/react-markdown-preview-modal react-markdown remark-gfm

Props

PropTypeDefaultDescription
isOpenbooleanrequiredControls the modal's visibility.
onClose() => voidrequiredCallback function to close the modal.
markdownContentstringrequiredThe Markdown content to display inside the modal.
backdropStylesReact.CSSPropertiesundefinedCustom styles for the modal's backdrop.
windowStylesReact.CSSPropertiesundefinedCustom styles for the modal window.
closeButtonStylesReact.CSSPropertiesundefinedCustom styles for the close button.
closeIconstring"close"Icon for the close button.
closeIconPathsany[]undefinedCustom paths for DynamicIcon if needed for the close button.
closeIconSizenumber24Size of the close button icon.

Example Usage

import React, { useState } from 'react';
import MarkdownPreviewModal from '@precooked/react-markdown-preview-modal';

const MyComponent = () => {
    const [isOpen, setIsOpen] = useState(false);
    const markdownContent = `
# Sample Markdown
This is an example of **Markdown** content with support for GFM.

- List item 1
- List item 2
- [Link](https://example.com)

| Column 1 | Column 2 |
|----------|----------|
| Cell 1   | Cell 2   |
`;

    return (
        <div>
            <button onClick={() => setIsOpen(true)}>Open Markdown Preview</button>
            <MarkdownPreviewModal
                isOpen={isOpen}
                onClose={() => setIsOpen(false)}
                markdownContent={markdownContent}
                backdropStyles={{ backgroundColor: "rgba(0, 0, 0, 0.6)" }}
                windowStyles={{ padding: "20px", maxWidth: "600px" }}
            />
        </div>
    );
};

export default MyComponent;

License

MIT


For more information, visit Precooked.

1.0.0

9 months ago